I am working with this function that moves an object around a center point in a perfect circle and am trying to modify it to move it in an oval shape that is 1/2 as high as it is wide?
Basically, I have a set speed
var myVelocity:Number = 0.25;
then I calculate my Sine and Cosine based on the speed
var myCos:Number = Math.cos(myVelocity);
var mySin:Number = Math.sin(myVelocity);
then I figure the distance of the the object from a fixed center points along each axis and
var x1:Number = myBall.x - centerX;
var y1:Number = myBall.y - centerY;
var x2:Number = myCos * x1 - mySin * y1;
var y2:Number = myCos * y1 + mySin * x1;
myBall.x = centerX + x2;
myBall.y = centerY + y2;
I have another function that figures x and y based upon myBall.x = centerX + cos(angle) * radius; that is easy enough to modify the radius to become an ellipse, but is there an easy way to mod the one above to become an ellipse? I want to do this to be more efficient with the code and reduce the number of math function calls