Sign in to follow this  

how drive an object in a full circle?

This topic is 3297 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
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

This topic is 3297 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this