Velocity Reviews > moving object along circle

moving object along circle

sparx10@gmail.com
Guest
Posts: n/a

 11-21-2012
I'm trying to move an object along a circle (orbit), and I did come up withthis:

from math import sqrt
print(x, y)

however it moves faster at the beginning and end of the range (y value changes faster than x value) because the x value is changing at a constant ratebut the y value isn't. I can't think of a way to get something to move smoothly around in a circle though..

Steven D'Aprano
Guest
Posts: n/a

 11-21-2012
On Tue, 20 Nov 2012 19:35:00 -0800, sparx10 wrote:

> I'm trying to move an object along a circle (orbit), and I did come up
> with this:
>
> from math import sqrt
> print(x, y)
>
> however it moves faster at the beginning and end of the range (y value
> changes faster than x value) because the x value is changing at a
> constant rate but the y value isn't. I can't think of a way to get
> something to move smoothly around in a circle though..

Instead of using rectangular (x, y) coordinates directly, use polar
coordinates (r, θ) where r (radius) is the constant radius of your
circle, and θ (theta) smoothly varies between 0 and 360°.

http://www.teacherschoice.com.au/mat...conversion.htm

import math
for angle in range(0, 361):
print(x, y)

--
Steven