/**
 * jQuery Roundabout Shapes v1.1
 * http://fredhq.com/projects/roundabout-shapes/
 * 
 * Provides additional paths along which items can move for the
 * jQuery Roundabout plugin (v1.0+).
 *
 * Terms of Use // jQuery Roundabout Shapes
 *
 * Open source under the BSD license
 *
 * Copyright (c) 2009, Fred LeBlanc
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met:
 * 
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   - Redistributions in binary form must reproduce the above 
 *     copyright notice, this list of conditions and the following 
 *     disclaimer in the documentation and/or other materials provided 
 *     with the distribution.
 *   - Neither the name of the author nor the names of its contributors 
 *     may be used to endorse or promote products derived from this 
 *     software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 * POSSIBILITY OF SUCH DAMAGE.
 */
jQuery.extend(jQuery.roundabout_shape,
{
	theJuggler: function(r, a, t) {	
		return {
			x: Math.sin(r + a), 
			y: Math.tan(Math.exp(Math.log(r)) + a) / (t - 1), 
			z: (Math.cos(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		};
	},
	figure8: function(r, a, t) {
		return {
			x: Math.sin(r * 2 + a), 
			y: (Math.sin(r + Math.PI/2 + a) / 8) * t, 
			z: (Math.cos(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		};
	},
	waterWheel: function(r, a, t) {
		return {
			x: (Math.sin(r + Math.PI/2 + a) / 8) * t, 
			y: Math.sin(r + a) / (Math.PI/2), 
			z: (Math.cos(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		};
	},
	square: function(r, a, t) {
		var sq_x, sq_y, sq_z;
		
		if (r <= Math.PI/2) {
			sq_x = (2/Math.PI) * r;
			sq_y = -(2/Math.PI) * r + 1;
			sq_z = -(1/Math.PI) * r + 1;
		} else if (r > Math.PI/2 && r <= Math.PI) {
			sq_x = -(2/Math.PI) * r + 2;
			sq_y = -(2/Math.PI) * r + 1;
			sq_z = -(1/Math.PI) * r + 1;
		} else if (r > Math.PI && r <= (3 * Math.PI) / 2) {
			sq_x = -(2/Math.PI) * r + 2;
			sq_y = (2/Math.PI) * r - 3;
			sq_z = (1/Math.PI) * r - 1;
		} else {
			sq_x = (2/Math.PI) * r - 4;
			sq_y = (2/Math.PI) * r - 3;
			sq_z = (1/Math.PI) * r - 1;
		}
		
		return {
			x: sq_x,
			y: sq_y * t, 
			z: sq_z,
			scale: sq_z
		}
	},
	conveyorBeltLeft: function(r, a, t) {
		return {
			x: -Math.cos(r + a), 
			y: (Math.cos(r + 3*Math.PI/2 + a) / 8) * t, 
			z: (Math.sin(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		};
	},
	conveyorBeltRight: function(r, a, t) {
		return {
			x: Math.cos(r + a), 
			y: (Math.cos(r + 3*Math.PI/2 + a) / 8) * t, 
			z: (Math.sin(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		};
	},
	goodbyeCruelWorld: function(r, a, t) {
		return {
			x: Math.sin(r + a), 
			y: (Math.tan(r + 3*Math.PI/2 + a) / 8) * (t + 0.5), 
			z: (Math.sin(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		};
	},
	diagonalRingLeft: function(r, a, t) {
		return {
			x: Math.sin(r + a), 
			y: -Math.cos(r + Math.tan(Math.cos(a))) / (t + 1.5), 
			z: (Math.cos(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		};
	},
	diagonalRingRight: function(r, a, t) {
		alert("test");
		return {
			x: Math.sin(r + a), 
			y: Math.cos(r + Math.tan(Math.cos(a))) / (t + 1.5), 
			z: (Math.cos(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		};
	},
	rollerCoaster: function(r, a, t) {
		return {
			x: Math.sin(r + a), 
			y: Math.sin((2 + t) * r), 
			z: (Math.cos(r + a) + 1) / 2,
			scale: (Math.sin(r + Math.PI/2 + a) / 2) + 0.5
		}
	},tearDrop2: function(r, a, t) {
		
		
		var r1=r;
		
		var z1;		
		z1=(Math.cos(r1 + a) + 1) / 2;	
		var s=(Math.sin(r1 + Math.PI/2 + a) / 2) + 0.5;
		//s=1;
		var x1;
		x1= Math.sin(r + a);
		var y1;
		y1=-Math.sin(r/2 + t)-.8;
			
		if(z1<=.4038500360034191)
		{
			x1=0.2390419095775992;			
		}
		if(z1<=.6138500360034191)
		{
			z1=z1-0.2375554366779142;			
		}
		
	
		//alert(r);
		if(x1!=0.2390419095775992)
		{
			if(r>4.75238898038469 && r<=4.76238898038469)
			{
				r=r-.22;
			}
			else if(r>4.76238898038469 && r<=4.77238898038469)
			{
				r=r-.21;
			}
			else if(r>4.77238898038469 && r<=4.78238898038469)
			{
				r=r-.20;
			}
			else if(r>4.78238898038469 && r<=4.79238898038469)
			{
				r=r-.19;
			}
			else if(r>4.79238898038469 && r<=4.80238898038469)
			{
				r=r-.18;
			}
			else if(r>4.80238898038469 && r<=4.81238898038469)
			{
				r=r-.17;
			}
			else if(r>4.81238898038469 && r<=4.86238898038469)
			{
				r=r-.12;
			}
			else if(r>4.86238898038469 && r<4.91238898038469)
			{
				r=r-.08;
			}
			else if(r>4.91238898038469 && r<=4.96238898038469)
			{
				r=r-.05;
			}		
			else if(r>4.96238898038469 && r<=5.01238898038469)
			{
				r=r-.02;
			}
			else if(r>5.01238898038469 && r<=5.06238898038469)
			{
				r=r+.01;
			}
			else if(r>5.06238898038469 && r<5.105088062083414)
			{
				r=r+.04;
			}
			
			
			
			//
			else if(r>=5.105088062083414 && r<=5.8904862254808625)
			{
				r=r+.07;
			}
			
			
			//
			else if(r>5.8904862254808625 && r<=5.9404862254808625)
			{
				r=r+.065;
			}
			else if(r>5.9404862254808625 && r<=5.9904862254808625)
			{
				r=r+.06;
			}
			else if(r>5.9904862254808625 && r<=6.043185307179587)
			{
				r=r+.055;
			}
			else if(r>6.043185307179587 && r<=6.083185307179587)
			{
				r=r+.05;
			}
			else if(r>6.083185307179587 && r<=6.143185307179587)
			{
				r=r+.04;
			}
			else if(r>6.143185307179587 && r<=6.183185307179587)
			{
				r=r+.03;
			}
			else if(r>6.183185307179587 && r<6.243185307179587)
			{
				r=r+.02;
			}
			else if(r>6.243185307179587 && r<6.283185307179587)
			{
				r=r+.01;
			}
			
			//
			else if(r>0&& r<=0.04269908169872414)
			{
				r=r-.01;
			}
			else if(r>0.04269908169872414&& r<=0.09269908169872414)
			{
				r=r-.02;
			}
			else if(r>0.09269908169872414&& r<=0.14269908169872414)
			{
				r=r-.03;
			}
			else if(r>0.14269908169872414&& r<=0.19269908169872414)
			{
				r=r-.04;
			}
			else if(r>0.19269908169872414&& r<=0.24269908169872414)
			{
				r=r-.05;
			}
			else if(r>0.24269908169872414&& r<=0.29269908169872414)
			{
				r=r-.055;
			}
			else if(r>0.29269908169872414&& r<0.34269908169872414)
			{
				r=r-.06;
			}
			else if(r>0.34269908169872414&& r<0.39269908169872414)
			{
				r=r-.065;
			}
			
			//
			else if(r>=0.39269908169872414&& r<=1.1780972450961724)
			{
				r=r-.07;
			}		
			//
				
			else if(r>1.1780972450961724 && r<=1.2380972450961724)
			{
				r=r-.04;
			}	
			else if(r>1.2380972450961724&& r<=1.2780972450961724)
			{
				r=r-.01;
			}	
			else if(r>1.27809724509617249 && r<=1.3380972450961724)
			{
				r=r+.02;
			}
			else if(r>1.3380972450961724 && r<1.3707963267948966)
			{
				r=r+.05;
			}
			else if(r>1.3780972450961724 && r<=1.4380972450961724)
			{
				r=r+.08;
			}	
			else if(r>1.4380972450961724 && r<=1.4780972450961724)
			{
				r=r+.12;
			}	
			else if(r>1.47809724509617249 && r<=1.5380972450961724)
			{
				r=r+.17;
			}
			else if(r>1.5380972450961724 && r<1.5480972450961724)
			{
				r=r+.22;
			}
			x1= Math.sin(r + a);
		}
		
		return {
			x: x1, 
			y: y1, 
			z: z1,
			scale: s
		}
	},
	tearDrop1: function(r, a, t) {
		
		//alert(r);
		var r1=r;
	
		if(r==4.71238898038469)
		{
			r=r;
		}
		else if(r>=1.5707963267948966 && r < 3.9269908169872414)
		{
			r=r+.36;
			
		}
		else
		{
			r=r-.05;
		}
		
		
		
		
		return {
			x: Math.sin(r + a), 
			y: -Math.sin(r/2 + t)-.1, 
			z: (Math.cos(r1 + a) + 1) / 2,
			scale: (Math.sin(r1 + Math.PI/2 + a) / 2) + 0.5
		}
	},
	tearDrop: function(r, a, t) {
		
		/*if(r==4.71238898038469)
		{
			r=r-.23;
		}
		else if(r==5.105088062083414)
		{
			r=r+.17;
		}
		else if(r==5.497787143782138)
		{
			r=r+.12;
		}
		else if(r==5.8904862254808625)
		{
			r=r+.07;
		}
		else if(r==0.39269908169872414)
		{
			r=r-.07;
		}
		else if(r==0.7853981633974483)
		{
			r=r-.12;
		}
		else if(r==1.1780972450961724)
		{
			r=r-.17;
		}
		else if(r==1.5707963267948966)
		{
			r=r+.23;
		}	*/
		var r1=r;
		//Extra
		//alert(r);
		
		if(r>=4.0443211395569115 && r<=5.1906091954311355)
		{
			r1=r-.47;
			r=r-.71;
		}		
		//
		
		else if(r>=5.1906091954311355 && r <5.223753223368249)
		{
			r1=r-.47;
			r=r-.71;
		}		
		else if(r>=5.223753223368249 && r<5.263753223368249)
		{
			r1=r-.46;
			r=r-.25;
		}
		else if(r>=5.263753223368249 && r<5.303753223368249)
		{
			r1=r-.45;
			r=r-.24;
		}
		else if(r>=5.303753223368249 && r<5.343753223368249)
		{
			r1=r-.43;
			r=r-.23;
		}
		else if(r>=5.343753223368249 && r<5.383753223368249)
		{
			r1=r-.41;
			r=r-.22;
		}
		else if(r>=5.383753223368249 && r<5.423753223368249)
		{
			r1=r-.39;
			r=r-.21;
		}
		else if(r>=5.423753223368249 && r<5.463753223368249)
		{
			r1=r-.37;
			r=r-.20;
		}
		
		///
		else if(r>=5.463753223368249 && r<5.496897251305361)
		{
			r1=r-.35;
			r=r-.19;
		}
		else if(r>=5.496897251305361 && r<5.536897251305361)
		{
			r1=r-.33;
			r=r-.18;
		}
		else if(r>=5.536897251305361&& r<5.576897251305361)
		{
			r1=r-.31;
			r=r-.17;
		}
		else if(r>=5.576897251305361 && r<5.616897251305361)
		{
			r1=r-.27;
			r=r-.16;
		}
		else if(r>=5.616897251305361 && r<5.656897251305361)
		{
			r1=r-.26;
			r=r-.15;
		}
		else if(r>=5.656897251305361 && r<5.696897251305361)
		{
			r1=r-.25;
			r=r-.14;
		}
		else if(r>=5.696897251305361 && r<5.736897251305361)
		{
			r1=r-.24;
			r=r-.13;
		}
		
		//
		else if(r>=5.736897251305361 && r<5.770041279242474)
		{
			r1=r-.23;
			r=r-.12;
		}
		else if(r>=5.770041279242474 && r<5.810041279242474)
		{
			r1=r-.21;
			r=r-.11;
		}
		else if(r>=5.810041279242474 && r<5.850041279242474 )
		{
			r1=r-.19;
			r=r-.10;
		}
		else if(r>=5.850041279242474 && r<5.890041279242474)
		{
			r1=r-.17;
			r=r-.09;
		}
		else if(r>=5.890041279242474 && r<5.930041279242474)
		{
			r1=r-.15;
			r=r-.08;
		}
		else if(r>=5.930041279242474 && r<5.970041279242474)
		{
			r1=r-.13;
			r=r-.07;
		}
		else if(r>=5.970041279242474 &&r<6.010041279242474)
		{
			r1=r-.11;
			r=r-.06;
			
		}
		//
		else if(r>=6.010041279242474 && r<6.050041279242474)
		{
			r1=r-.09
			r=r-.05;
		}
		else if(r>=6.050041279242474 && r<6.090041279242474)
		{
			r1=r-.07
			r=r-.04;
		}
		else if(r>=6.090041279242474 && r<6.130041279242474)
		{
			r1=r-.05
			r=r-.03;
		}
		else if(r>=6.130041279242474 && r<6.170041279242474)
		{
			r1=r-.03
			r=r-.02;
		}
		else if(r>=6.170041279242474)
		{
			r1=r-.01;
			r=r-.01;
			
		}		
		//
		else if(r>0 && r<=0.1140166925631095)
		{
			r1=r+.01
			r=r+.01;
		}
		else if(r>0.1140166925631095 && r<=0.1540166925631095)
		{
			r1=r+.03
			r=r+.02;
		}
		else if(r>0.1540166925631095 && r<=0.1940166925631095)
		{
			r1=r+.05
			r=r+.03;
		}
		else if(r>0.1940166925631095 && r<=0.2340166925631095)
		{
			r1=r+.07
			r=r+.04;
		}
		else if(r>0.2340166925631095 && r<=0.27401669256310957)
		{
			r1=r+.09
			r=r+.05;
		}
		//
		else if(r>0.27401669256310957 & r<=0.3071607205002217)
		{
			r1=r+.11
			r=r+.06;
		}
		else if(r>0.3071607205002217 & r<=0.3471607205002217)
		{
			r1=r+.13
			r=r+.07;
		}
		else if(r>0.3471607205002217 & r<=0.3871607205002217)
		{
			r1=r+.15
			r=r+.08;
		}
		else if(r>0.3871607205002217 & r<=0.4271607205002217)
		{
			r1=r+.17
			r=r+.09;
		}
		else if(r>0.4271607205002217 & r<=0.4671607205002217)
		{
			r1=r+.19
			r=r+.10;
		}
		else if(r>0.4671607205002217 & r<=0.5071607205002217)
		{
			r1=r+.21
			r=r+.11;
		}
		else if(r>0.5071607205002217 & r<=0.5471607205002217)
		{
			r1=r+.23
			r=r+.12;
		}
		//
		
		else if(r>0.5471607205002217 & r<=0.58030474843733497)
		{
			r1=r+.24
			r=r+.13;
		}
		else if(r>0.5803047484373349 & r<=0.6203047484373349)
		{
			r1=r+.25
			r=r+.14;
		}
		else if(r>0.6203047484373349 & r<=0.6603047484373349)
		{
			r1=r+.27
			r=r+.15;
		}
		else if(r>0.6603047484373349 & r<=0.7003047484373349)
		{
			r1=r+.29
			r=r+.16;
		}
		else if(r>0.7003047484373349 & r<=0.7403047484373349)
		{
			r1=r+.31
			r=r+.17;
		}
		else if(r>0.7403047484373349 & r<=0.7803047484373349)
		{
			r1=r+.33
			r=r+.18;
		}
		else if(r>0.7803047484373349 & r<=0.8203047484373349)
		{
			r1=r+.35
			r=r+.19;
		}		
		
		///
		
		else if(r>0.8203047484373349 & r<=0.8603047484373349)
		{
			r1=r+.37
			r=r+.20;
		}
		else if(r>0.8603047484373349 & r<=0.9003047484373349)
		{
			r1=r+.39
			r=r+.21;
		}
		else if(r>0.9003047484373349 & r<=0.9403047484373349)
		{
			r1=r+.41
			r=r+.22;
		}
		else if(r>0.9403047484373349 & r<=0.9803047484373349)
		{
			r1=r+.43
			r=r+.23;
		}
		else if(r>0.9803047484373349 & r<=1.020304748437335)
		{
			r1=r+.45
			r=r+.24;
		}
		else if(r>1.020304748437335 & r<=1.060304748437335)
		{
			r1=r+.46
			r=r+.25;
		}
		else if(r>1.060304748437335 && r<=1.0934487763744472)
		{
			r1=r+.47;
			r=r+.71;
		}
		
		
		//Extra
		
		else if(r>1.0934487763744472 && r<=2.6397368322486725)
		{
			r1=r+.47;
			r=r+.71;
		}
		
		//
		
		/*
		if(r==5.1906091954311355 )
		{
			r=r-.60;
		}		
		//
		
		else if(r>4.71238898038469 && r<=4.72238898038469)
		{
			r=r-.22;
		}	
		else if(r>4.72238898038469 && r<=4.73238898038469)
		{
			r=r-.21;
		}	
		else if(r>4.73238898038469 && r<=4.74238898038469)
		{
			r=r-.20;
		}	
		else if(r>4.74238898038469 && r<=4.75238898038469)
		{
			r=r-.195;
		}	
		else if(r>4.75238898038469 && r<=4.76238898038469)
		{
			r=r-.19;
		}
		else if(r>4.76238898038469 && r<=4.77238898038469)
		{
			r=r-.18;
		}
		else if(r>4.77238898038469 && r<=4.78238898038469)
		{
			r=r-.17;
		}
		else if(r>4.78238898038469 && r<=4.79238898038469)
		{
			r=r-.16;
		}
		else if(r>4.79238898038469 && r<=4.80238898038469)
		{
			r=r-.155;
		}
		else if(r>4.80238898038469 && r<=4.81238898038469)
		{
			r=r-.15;
		}
		else if(r>4.81238898038469 && r<=4.86238898038469)
		{
			r=r-.11;
		}
		else if(r>4.86238898038469 && r<4.91238898038469)
		{
			r=r-.08;
		}
		else if(r>4.91238898038469 && r<=4.96238898038469)
		{
			r=r-.05;
		}		
		else if(r>4.96238898038469 && r<=5.01238898038469)
		{
			r=r-.02;
		}
		else if(r>5.01238898038469 && r<=5.06238898038469)
		{
			r=r+.01;
		}
		else if(r>5.06238898038469 && r<5.105088062083414)
		{
			r=r+.04;
		}
		
		
		
		//
		else if(r>=5.105088062083414 && r<=5.8904862254808625)
		{
			r=r+.07;
		}
		
		
		//
		else if(r>5.8904862254808625 && r<=5.9404862254808625)
		{
			r=r+.065;
		}
		else if(r>5.9404862254808625 && r<=5.9904862254808625)
		{
			r=r+.06;
		}
		else if(r>5.9904862254808625 && r<=6.043185307179587)
		{
			r=r+.055;
		}
		else if(r>6.043185307179587 && r<=6.083185307179587)
		{
			r=r+.05;
		}
		else if(r>6.083185307179587 && r<=6.143185307179587)
		{
			r=r+.04;
		}
		else if(r>6.143185307179587 && r<=6.183185307179587)
		{
			r=r+.03;
		}
		else if(r>6.183185307179587 && r<6.243185307179587)
		{
			r=r+.02;
		}
		else if(r>6.243185307179587 && r<6.283185307179587)
		{
			r=r+.01;
		}
		
		//
		else if(r>0&& r<=0.04269908169872414)
		{
			r=r-.01;
		}
		else if(r>0.04269908169872414&& r<=0.09269908169872414)
		{
			r=r-.02;
		}
		else if(r>0.09269908169872414&& r<=0.14269908169872414)
		{
			r=r-.03;
		}
		else if(r>0.14269908169872414&& r<=0.19269908169872414)
		{
			r=r-.04;
		}
		else if(r>0.19269908169872414&& r<=0.24269908169872414)
		{
			r=r-.05;
		}
		else if(r>0.24269908169872414&& r<=0.29269908169872414)
		{
			r=r-.055;
		}
		else if(r>0.29269908169872414&& r<0.34269908169872414)
		{
			r=r-.06;
		}
		else if(r>0.34269908169872414&& r<0.39269908169872414)
		{
			r=r-.065;
		}
		
		//
		else if(r>=0.39269908169872414&& r<=1.1780972450961724)
		{
			r=r-.07;
		}		
		//
			
		else if(r>1.1780972450961724 && r<=1.2380972450961724)
		{
			r=r-.04;
		}	
		else if(r>1.2380972450961724&& r<=1.2780972450961724)
		{
			r=r-.01;
		}	
		else if(r>1.27809724509617249 && r<=1.3380972450961724)
		{
			r=r+.02;
		}
		else if(r>1.3380972450961724 && r<1.3707963267948966)
		{
			r=r+.05;
		}
		else if(r>1.3780972450961724 && r<=1.4380972450961724)
		{
			r=r+.08;
		}	
		else if(r>1.4380972450961724 && r<=1.4780972450961724)
		{
			r=r+.11;
		}	
		else if(r>1.47809724509617249 && r<=1.5380972450961724)
		{
			r=r+.15;
		}
		else if(r>1.5380972450961724 && r<1.5480972450961724)
		{
			r=r+.19;
		}
		else if(r>1.5480972450961724 && r<1.550972450961724)
		{
			r=r+.20;
		}
		else if(r>1.5580972450961724 && r<1.5680972450961724)
		{
			r=r+.21;
		}
		else if(r>1.5680972450961724 && r<1.5707963267948966)
		{
			r=r+.22;
		}
		
		//
		else if(r==1.0934487763744472)
		{
			r=r+.60;
			
		}*/
		
		
		return {
			x: Math.sin(r + a), 
			y: -Math.sin(r1/2 + t) + 0.35, 
			z: (Math.cos(r1 + a) + 1) / 2,
			scale: (Math.sin(r1 + Math.PI/2 + a) / 2) + 0.5
		}
	}
});
