POV-Ray : Newsgroups : povray.general : AutoBanking : Re: AutoBanking Server Time
10 Aug 2024 01:23:10 EDT (-0400)
  Re: AutoBanking  
From: John VanSickle
Date: 31 Mar 2000 22:59:36
Message: <38E576E8.58DBD751@erols.com>
Peter Popov wrote:
> 
> On Fri, 31 Mar 2000 14:34:48 -0800, Josh English
> <eng### [at] spiritonecom> wrote:
> 
> >I am continuing to develop my bezier spline macros, but I am currently
> >having a problem with banking the object to have a realistic motion
> >along the curve. Does anyonw have any suggestions?
> 
> Take the second derivative of the equation of motion you are using and
> use (scaled to a proper range of course) to rotate the object around
> the axis formed by the first derivative of aforementioned function. I
> hope I know what I am talking about at this time of night :)

Close enough for government work.  Take the 2nd derivative of the motion,
which will be a vector inward of the curve.  From this subtract a vector
representing the force of gravity; since gravity is down, the result will
be mostly up, tilted by the amount of acceleration.  Normalize the
result.  That's the new "up" vector for the object.

Since a bezier spline uses the equation

P(u)=(1-u)^3 * P_0 + 3*u*(1-u)^2 * P_1 + 3*u^2*(1-u) * P_2 + u^3 * P_3

The first derivative ought to be

dP/du= (-3+6*u-3*u^2) * P_0 + (3-12*u+9*u^2) * P_1
  +(6*u-3*u^2)*P_2 + 3*u^2 * P_3

and the second ought to be

d^2P/du^2 = (6-6*u)* P_0 + (-12+18*u) * P_1 + (6-6*u) * P_2 + 6*u * P_3

Now to get the object placed and banked, calculate the position along
the spline, and the first two derivatives, and place them in the variables
Location, Velocity, and Acceleration.

The velocity becomes your object's forward vector:

#local VecF=vnormalize(Velocity);

From the acceleration, you require only the portion that is perpendicular
to the direction of motion:

#local VecA=Accleration-VecF*vdot(VecF,Accleration);

From this, subtract the vector for gravity and normalize the result:

#local Gravity=<0,-9.8,0>; // gravity is down at 9.8 m/sec^2
#local VecU=vnormalize(VecA-Gravity);

Then you get your right-hand vector for a full transformation:

#local VecR=vnormalize(vcross(VecU,VecF));

And then recalculate the up vector (in case the forward motion is
going up or down a slope):

#local VecU=vnormalize(vcross(VecF,VecR));

and then invoke it wall with a matrix transform.  If your object
is modeled so that z is forward and y is up,

matrix < VecR.x, VecR.y, VecR.z,
         VecU.x, VecU.y, VecU.z,
         VecF.x, VecF.y, VecF.z,
         Location.X,Location.Y,Location.Z >

Hope this helps (and isn't full of bugs),
John
-- 
ICQ: 46085459


Post a reply to this message

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