POV-Ray : Newsgroups : povray.newusers : Steering a vehicle : Steering a vehicle Server Time
30 Jul 2024 04:21:44 EDT (-0400)
  Steering a vehicle  
From: Bathurstfreak
Date: 17 Oct 2004 09:15:00
Message: <web.41726f1a7d9a2878ed9ef17e0@news.povray.org>
Just thought I'd share this with some of you folk, I spent ages trying to
get this to work and finally cracked it. After you defince your vehicle,
with wheels that roll, that was tricky too, you are left with the task of
steering the fronts, this is it.

frames - no. of frames in sequence
trackpoints - no of points used to define the track
trackspline - self explanatory

note, steering has to be declared as 0 if the two vectors are parallel

_______________________________________________________

#declare dleng = vlength( trackspline(clock*trackpoints) -
trackspline((clock+1/frames)*trackpoints) );
#declare dir1 = trackspline((clock-1/frames)*trackpoints) -
trackspline(clock*trackpoints);
#declare dir2 = trackspline(clock*trackpoints) -
trackspline((clock+1/frames)*trackpoints);
#declare rotat = VRotation(dir1,dir2,y);

#if(rotat=0)
    #declare steering=0;
  #else
    #declare hdist = dleng/(sin(rotat));
    #declare tradi = sqrt(pow(hdist,2)-pow(dleng,2));
    #declare steering = degrees(atan(base/(tradi*sgn(rotat))));
#end

script uses trig to find the angle between two vectors, you then use this
angle with the cars wheelbase (base) to find the radius of turn (tradi)

final output is steering

--------------------------------

Odometer script

#declare distrav = vlength( trackspline((clock+1/frames)*trackpoints) -
trackspline(clock*trackpoints) );
#declare speed=distrav*framerate;

#declare J = 0;
#while (J<=(clock*frames))
   #if (J=0)
      #declare odometer=0;
   #end
   #declare Point1 = trackspline(J/frames*trackpoints);
   #declare Point2 = trackspline((J+1)/frames*trackpoints);
   #declare ddist = vlength( Point2 - Point1 );
   #declare odometer = odometer + ddist;
   #declare J = J + 1;
#end

#declare tyrerotations=odometer/(2*pi*tyreradius);

multiply tyre rotations to get final angle of wheel as input into the frame

Hope this is useful


Post a reply to this message

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