# Thread: Java 3D circular movement?

1. Member
Join Date
Aug 2011
Posts
4
Rep Power
0

## 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

2. 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
Last edited by JosAH; 08-11-2011 at 03:02 PM.

3. Member
Join Date
Aug 2011
Posts
4
Rep Power
0

What do you mean for [amin, amax] ?

4. 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.)

5. 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

6. Member
Join Date
Aug 2011
Posts
4
Rep Power
0
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

7. 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
Make b move from -pi to 0 while a moves from 0 to a value (much) greater than 2*pi ....

kind regards,

Jos

8. Member
Join Date
Aug 2011
Posts
4
Rep Power
0
Thank you, great help!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•