POV-Ray : Newsgroups : povray.general : Rolling balls, appropriate rotation equation. : Re: Rolling balls, appropriate rotation equation. Server Time
9 Aug 2024 13:22:55 EDT (-0400)
  Re: Rolling balls, appropriate rotation equation.  
From: Chris Colefax
Date: 15 Jul 2000 21:59:43
Message: <3971170f@news.povray.org>
Greg M. Johnson wrote:
> I have an isosurface that is rolling hills based on the noise3d function.
>
> At time increment n,  I know the tangent is at pt x1,y2,z1.
> At time increment n+1, I know the tangent is at pt. x2,y2,z2.
>
> I know the distance between the two, and the time increment is so small
that
> I don't think I'll be harmed by assuming it's a straight line. Even with a
> straight line on an inclined plane, I have no idea how the ball should
> roll.  The 1d & 2d solutions are trivial.

The simple answer is that you need to rotate the ball around the axis
perpendicular to the direction of travel and the normal of the surface
you're rolling on, by the angle (in degrees) given by the
360*distance_travelled/ball_circumference.

The tricky part is finding the right axis to rotate about, which depends on
exactly how you want to simulate the ball's behaviour.  Perhaps the easiest
option is to assume the ball has a preferred orientation (i.e. one axis that
always points in the direction of travel).  Then you can simply rotate
around the rolling axis first, followed by a rotation around the "up" axis
to the direction of travel, finished by a rotation (so the up axis points to
the surface normal) and translation to the final position, e.g. assuming the
balls starts centred at the origin, pointing to +z:

   #declare BallUp = vnormalize(SurfaceNormal);
   #declare BallDir = vnormalize(p2 - p1);
   #declare BallRight = vnormalize (vcross(BallUp, BallDir));
   #declare BallLoc = SurfacePoint + (BallUp*BallRadius);

   object {Ball
      rotate x*360*(vlength(p2 - p1)+PreviousDistance)/(2*pi*BallRadius)
      matrix <BallRight.x, BallRight.y, BallRight.z,
         BallUp.x, BallUp.y, BallUp.z,
         BallDir.x, BallDir.y, BallDir.z,
         BallLoc.x, BallLoc.y, BallLoc.z>}

If, on the other hand, you want the ball to be able to roll around any axis
you could recalculate the rolling axis at each step and add the rotation
around it to the previous rotations - but it seems to me what you'd get is a
ball that always points in one global direction, rather than always pointing
forwards, and I don't know that this would look very effective...


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.