Results 1 to 8 of 8
  1. #1
    AXELTOPOLINO is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Default 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
    -the size of the radius

    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. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,784
    Blog Entries
    7
    Rep Power
    21

    Default

    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 04:02 PM.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    AXELTOPOLINO is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Default

    Thanks JosAH for your reply.

    What do you mean for [amin, amax] ?

  4. #4
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    5

    Default

    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.)
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,784
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Hibernate View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    AXELTOPOLINO is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Default

    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. #7
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,784
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by AXELTOPOLINO View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    AXELTOPOLINO is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

Similar Threads

  1. help me with this ! circular doubly linked list
    By someone in forum Advanced Java
    Replies: 1
    Last Post: 04-11-2011, 11:35 AM
  2. CIrcular Arrays
    By Bgreen7887 in forum New To Java
    Replies: 1
    Last Post: 03-25-2011, 08:30 AM
  3. Replies: 5
    Last Post: 02-04-2011, 05:29 AM
  4. Need help with circular arrays
    By bap2 in forum New To Java
    Replies: 6
    Last Post: 11-04-2010, 09:39 PM
  5. Problem prioritizing a circular queue
    By Metastar in forum New To Java
    Replies: 1
    Last Post: 10-04-2010, 12:40 AM

Posting Permissions

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