Results 1 to 3 of 3

Thread: roll a sphere?

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2001
    New York, NY, US

    roll a sphere?

    One more question:

    If I want to roll a sphere on the x-z plane
    by using translations and rotations.
    How can I roll it from the point A(-4,1,4,1)
    to the point B(3,1,-4,1) along with
    a straight line, and make the rotation and
    translation should match to produce the
    effect of rolling the spere on the x-z plane?

    Thanks a lot!

  2. #2
    Senior Member Regular Contributor
    Join Date
    Aug 2000
    Ocoee, Florida, USA

    Re: roll a sphere?

    I'm not even going to try to figure out which plane is the x-z plane right now, but you should try figuring out which direction you want to roll it first (start by applying:
    glRotated( 1.0, 1.0, 0.0, 0.0 )
    each frame, if thats not right use:
    glRotated( 1.0, 0.0, 1.0, 0.0 )
    and if thats not right, use:
    glRotated( 1.0, 0.0, 0.0, 1.0 )

    You should be able to see which direction is the one you want.

    Then start adding in your translation with glTranslate() until it looks right, translate it in the direction you want to go each frame by a little more than last frame (simple vector math).

    You should be rolling your sphere around in no time.

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Adelaide, South Australia, Australia

    Re: roll a sphere?


    I'm taking a wild stab in the dark, here (well, any excuse to procrastinate, I feel <mutters about work he should be doing, but isn't doing right at the minute>=) but it SOUNDS like the original poster is trying to figure out what rotations/transformations s/he wants to get the ball to rotate along an arbitrary vector.

    Righty. The things you need to know are:

    1) the two end points of the trajectory,
    2) some other point on the ground plane, and
    3) the size of the sphere

    from (1) you can compute how far you want the ball to roll, and along which vector. You also use the direction vector and (2) to figure out the plane its rolling on, and thus compute a vector along this plane that's orthogonal to the vector in (1). (3) will tell you how far the ball travels in one rotation (ie. the length of its circumfrence).

    <thinks deep mathematical thoughts for a moment or two> If the ball is at angle *q* at time 0 at the start vertex, *a*, then for an arbitary point p along the vector from *ab*, then the ball would have rotated

    ------ * 2.0*pi radians about its axis since it started ... (1)

    where |p-a| is the segment length from the start to the ball's position, and c is the circumfrence of the sphere. So, all you need to do is position the ball at p, and rotate it by eqn (1) about the vector found using the ground plane point and the vector (points 1 and 2 above)

    nice, eh? I thought so. <basks in round of applause for several moments> thank you, thankyou.

    er, you find p by interpolating along the line. easy to figure out. but not now; some sultry female just rang me up right now telling me that my order is ready, so i'm off! Mwhahahah.


Similar Threads

  1. Yaw, Pitch & Roll
    By OGL_PGR in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-08-2005, 07:26 AM
  2. pitch yaw and roll faq?
    By apit in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-02-2003, 10:53 AM
  3. about Yaw-Pitch-Roll
    By tigeryhong in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-22-2003, 12:07 PM
  4. How to roll a cube??
    By in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 08-03-2002, 07:37 AM
  5. Roll, Pitch, and Yaw
    By BigRD in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 10-18-2001, 07:19 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
Proudly hosted by Digital Ocean