# Circular Motion

:whistle: 'Allo folks,

Urm… can someone explain the logic of circular motion (them radians and degrees). I’ve found the code for it and modified it a bit to make it do what I want.

But I haven’t a clue as to how it works…:puzzle:

This is a slightly modified code taken from the Kirupa Tutorial.

xcenter = 0;
ycenter =0;

[font=Courier New][size=2][color=#000080]onClipEvent[/color][/size][/font][font=Courier New][size=2][color=black] ([/color][/size][/font][font=Courier New][size=2][color=#000080]enterFrame[/color][/size][/font][font=Courier New][size=2][color=black]) {[/color][/size][/font]
degree += 22.5;
[font=Courier New][size=2][color=black]radian = (degree/180)*[/color][/size][/font][font=Courier New][size=2][color=#000080]Math.PI[/color][/size][/font][font=Courier New][size=2][color=black];
[/color][/size][/font][font=Courier New][size=2][color=#000080]this._x[/color][/size][/font][font=Courier New][size=2][color=black] = xcenter+[/color][/size][/font][font=Courier New][size=2][color=#000080]Math.cos[/color][/size][/font][font=Courier New][size=2]color=black*100;
[/color][/size][/font][font=Courier New][size=2][color=#000080]this._y[/color][color=black] = ycenter-[/color][color=#000080]Math.sin[/color]color=black*100;
}

The above code will change the position of the movieClip at every 22.5 degrees (thereby making sixteen distinct stops) and will trace a circle of radius 100 px.

Can anyone explain the trigo. concept behind the math equations? (I tried, I tell you… I really tried). :crying:

Thank ye…

/gopaldass/
[/color][/size][/font]

It’s a formula to calculate a position on a circle, here with radius 100 and with the center {xcenter, ycenter}. Cutout from my explanation in the Best of Kirupa thread:

The sine of angle is the opposing side divided by the hypotenuse. The hypotenuse is the radius of the circle. So we can say that Math.sin(angle) = y/radius. So this means that Math.sin(angle)*radius = y. Same goes for x. Math.cos(angle) = adjacent side divided by the hypotenuse. So Math.cos(angle) = x/radius. Which will lead us to Math.cos(angle)*radius = x. Using this simple formula, we can calculate the position on a circle given the angle and the radius.