• Advertisement
Sign in to follow this  

how drive an object in a full circle?

This topic is 3366 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, 3D Math Noob here. I have an object that starts at, say, x,y,z. I would like it to go to point x2,y2,z2 ... xN,yN,zN, until it has done a full revolution. What is the way to think about this problem? THANKS!

Share this post


Link to post
Share on other sites
Advertisement
To rotate an object in a circle in 3D space, you need an axis to rotate it around, and a radius.

The simplest case is when your circle is in the x,z plane (i.e. flat on the ground), and you want to rotate around the y-axis, centred on the origin. In this case you just need basic trigonometry (in particular the parametric equation of a circle), and you will end up with something like this:
def position_on_circle(time):

radius = 1.0

x = cos(time) * radius
y = 0
z = sin(time) * radius

return x, y, z


[Edited by - swiftcoder on December 4, 2008 9:16:39 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by cellis
how could i generate an even distribution of x,z points?
An even distribution around that circle on the x,z plane? By feeding uniform values into that function:
points = []

for f in range(0, 2*pi, 0.1):
points.append( position_on_circle(f) )

Keep in mind that sin and cos take arguments in radians, so one entire circle is 2*pi radians.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement