# Java 3D circular movement?

• 08-11-2011, 03:18 PM
AXELTOPOLINO
Java 3D circular movement?
Hello,
I'm working on a 3D game and I'm trying to move my object roundly. It must follow a circumference when it's moving.
I've got the following variables/function:
-motionX, motionY, motionZ
-posX, posY, posZ
-"onupdate()" function which update the state, the position and the movement of the object
-the coords of the circumference's centre

How can I move this object roundly around the centre?
Is there a function in GL11 or in another library? Can you write an example?

Thanks really much,
AXELTOPOLINO
• 08-11-2011, 03:45 PM
JosAH
Think spherical coordinates:

x= r*cos(a)*sin(b)
y= r*sin(a)*sin(b)
z= r*cos(b)

where r is a constant value (the radius of your sphere) and both a and b move in the intervals [amin, amax] and [bmin, bmax] in a linear way.

kind regards,

Jos
• 08-11-2011, 11:12 PM
AXELTOPOLINO

What do you mean for [amin, amax] ?
• 08-12-2011, 02:23 AM
Hibernate
That is the closed (inclusive beginning and end; i.e. not clopen) interval tor which the variable 'a' is bound.
'a' cannot be less than 'amin' [radians] and not more than 'amax' [radians].

The values are probably 0 and 2π. Jumping to 0 when reaching 2π (2π modular), and jumping to 2π + a, when a < 0
The interval should probably [actually] be clopen: [0; 2π[
(i.e. 2π is exclusive as describe 2 lines above.)
• 08-12-2011, 08:53 AM
JosAH
Quote:

Originally Posted by Hibernate
The values are probably 0 and 2π

If you do that you can only describe a 'great circle around that sphere. If both intervals are in the range [0, 2π] that great circle is tilted w.r.t. one of the axes.

kind regards,

Jos
• 08-12-2011, 01:45 PM
AXELTOPOLINO
Really thanks, it works!

May I ask how I can do a "tornado" movement? I mean a spiral movement: a circular movement, but the radius increase and the object go up until the "top" of the tornado.

Thanks again for the great support :(nod):
• 08-12-2011, 03:52 PM
JosAH
Quote:

Originally Posted by AXELTOPOLINO
Really thanks, it works!

May I ask how I can do a "tornado" movement? I mean a spiral movement: a circular movement, but the radius increase and the object go up until the "top" of the tornado.

Thanks again for the great support :(nod):

Make b move from -pi to 0 while a moves from 0 to a value (much) greater than 2*pi ....

kind regards,

Jos
• 08-12-2011, 05:31 PM
AXELTOPOLINO
Thank you, great help!