PDA

View Full Version : Circular Movement Help, Need the Math Explained Please?



babywax
August 28th, 2003, 07:53 PM
onClipEvent (load) {
var centerx = this._x;
var centery = this._y;
var speed = 20;
var degree = 0;
var radius = 30;
var radian;
}
onClipEvent (enterFrame) {
degree += speed;
radian = (degree/180)*Math.PI;
this._x = centerx + Math.cos(radian)*radius;
this._y = centery + Math.sin(radian)*radius;
}


This is something I wrote, with(quite obviously) a lot of help from the very nice circular movement (http://www.kirupa.com/developer/mx/circular.htm) tutorial on this web page. There are however a few things I do not understand, after a lot of searching, and a little posting here I found out what a radian was, but now I need to understand how the enterFrame clipevent section of this script exactly works.
degree += speed;
I believe I get that.... Just constantly increasing the degrees by 20 so it moves at 20 degrees a frame.
radian = (degree/180)*Math.PI;
I think I get that too... Converting the degrees into radians.

this._x = centerx + Math.cos(radian)*radius;
this._y = centery + Math.sin(radian)*radius;

That I don't get. I understand what it DOES, it changes where it is going... But what is the formula that Math.cos(and Math.sin) use to return whatever number they return? One more thing, why must it be multiplied by the radius? What exactly does it return?
Thank you for any help possible, and replies will be greatly appreciated.

senocular
August 28th, 2003, 10:28 PM
see http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12181

might help

babywax
August 29th, 2003, 12:41 AM
Thank you, that helped a lot, I think I am beginning to understand some of the geometry behind circles, and it only took me a day with almost no algebra experience, flash is just so cool!
I love my new hat too...
:p: