View Single Post
  #4  
Old July 2nd, 2009, 01:04 AM
Jazzua's Avatar
Jazzua Jazzua is offline
Newbie
 
Join Date: Jul 2009
Location: Warners Bay, Australia
Posts: 8
Country:
Thanks: 0
Thanked 1 Time in 1 Post
Jazzua is on a distinguished road
Default

ok.... i found an equation that does what i want. but only for a circle.
here is the equations to find a points x,y so that it is always located on the perimeter of a circle.

x = centerX + cos(angle) * radius;
y = centerY + sin(angle) * radius;

and here's some actionscript 3 code to accomplish this, if anyone else stumbles across this looking for the same thing as me. maybe this'll help:

Code:
//this line just turns degrees into radians. it is a custom method with one line:
//return degrees * Math.PI / 180;
//i used 30 degrees, but this was just chosen at random. put in the degrees you want.
			
var angle:Number = inRadians(30);

//head in the following line is just an ellipse of which i want to find a point
//on the perimeter of. Also these lines are there because the x,y of an ellipse
//drawn in flash is by default the upper lefgt hand corner. 
//(imagining there's a box around the ellipse)
			
var centerX:Number = head.x + (head.width / 2);
var centerY:Number = head.y + (head.height / 2);
			
//this is the problematic line for calculating all this for an ellipse. 
//As the radius is different at different angles.
			
var radius:Number = head.width / 2;
			
//neck in the below lines is the point you are drawing on the perimeter of head.
			
neck.x = centerX + Math.cos(angle) * radius;
neck.y = centerY + Math.sin(angle) * radius;

anyone know where to go from here to get it working for an ellipse?
__________________
--------------------------------------------
"Life's far too important to be taken seriously"
--------------------------------------------
Reply With Quote