|
|
"CAD-Andi" <nomail@nomail> wrote:
> Hi!
> I would like to simulate a tractor-trailer situation. The vehicle should be
> guided by a spline and the trailer will be connected on a pivot point.
>
> The main problem is the so called "off tracking" of the trailer when the
> combination goes through a turn. The rear end of the trailer describes a
> different path than the pulling vehicle.
>
> I need to do this only on a plane in 2D (for now). Does anyone have a idea or
> even a little code snippet to put me on track? Did anyone come a cross a inverse
> kinematics script for POVRay? ...
>
> Thanks!
I played around with your problem and came up with this. It might need some fine
tunning.
#version 3.7;
global_settings { max_trace_level 20
assumed_gamma 1.0 }
#declare C= clock*18+1;
#declare SPLINE=spline{quadratic_spline
0,<-242.85714,348.57143262>
,1,<-242.85714,371.42857262>,2,<-191.42857,440.00000262> ,
3,<-42.857143,525.71428262>,4,<171.42857,502.85714262>,5,<288.57143,440.00000262>,
6,<374.28571,325.71428262>,7,<425.71429,205.71428262>,8,<285.71429,168.57143262>,
9,<234.28571,288.57143262>,10,<162.85714,405.71428262>,11,<20,428.57143262>,
12,<-54.285714,377.14285262>,13,<-102.85714,245.71428262>,14,<8.5714286,225.71428262>,
15,<14.285714,145.71428262>,16,<-71.428571,122.85714262>,17,<-217.14286,182.85714262>,
18,<-282.85714,254.28571262>,19,<-242.85714,348.57143262> }
#declare X_FOLLOW = SPLINE(C).x;
#declare Y_FOLLOW = SPLINE(C).y;
#declare X_CAB_LEAD = SPLINE(C+1.5).x;
#declare Y_CAB_LEAD = SPLINE(C+1.5).y;
#declare X_TOW_LEAD = SPLINE(C+.5).x;
#declare Y_TOW_LEAD = SPLINE(C+.5).y;
#declare X_DIFFER = X_FOLLOW-X_TOW_LEAD;
#declare Y_DIFFER = Y_FOLLOW-Y_TOW_LEAD;
#if(Y_DIFFER=0)#declare Y_DIFFER=.001;
#end
#declare REF_ANGLE=0;
#if (Y_DIFFER<0)
#if (X_DIFFER<0) #declare REF_ANGLE=-180+atan(X_DIFFER/Y_DIFFER);
#else #declare REF_ANGLE=180+(atan (X_DIFFER/Y_DIFFER));
#end
#end
#declare POINT =-(180/pi)*atan(X_DIFFER/Y_DIFFER)-REF_ANGLE;
#declare X_DIFFER_CAB = X_CAB_LEAD-X_FOLLOW;
#declare Y_DIFFER_CAB = Y_CAB_LEAD- Y_FOLLOW;
#if(Y_DIFFER_CAB=0)#declare Y_DIFFER_CAB=.001;#end
#declare REF_ANGLE=0;
#if (Y_DIFFER_CAB<0)
#if (X_DIFFER_CAB<0) #declare
REF_ANGLE=-180+atan(X_DIFFER_CAB/Y_DIFFER_CAB);
#else #declare P=z; #declare REF_ANGLE=180+(atan
(X_DIFFER_CAB/Y_DIFFER_CAB));
#end
#end
#declare POINT_CAB =180-(180/pi)*atan(X_DIFFER_CAB/Y_DIFFER_CAB)-REF_ANGLE;
union{cylinder{5*y,25*y,6.5} cone{0,0,5*y,6.5} cylinder{-.25*z,.25*z,2.5 }
rotate <0,0,POINT>
translate<X_TOW_LEAD,Y_TOW_LEAD,0 >/3
pigment{rgb 0} }
union{cylinder{-5*y,-10*y,6.5} cone{0,0,-5*y,6.5}
rotate <0,0,POINT_CAB>
translate<X_TOW_LEAD,Y_TOW_LEAD,0 >/3
pigment{rgb 0} }
//////ROAD
#declare I=0;
#while (I<19)
cylinder{0,z,11 translate SPLINE(I)/3 pigment{rgb<1,1,0>} finish{ambient 1}}
cylinder{-z/99,z,1 translate SPLINE(I)/3 pigment{rgb<0,0,0>} }
#declare I=I+.1;
#end
camera{ orthographic //angle 5
location<16,122,-100>
#declare Wide=70;
up <0,3.0,0> *Wide
right <4,0,0> *Wide
look_at <16,122,0>}
background{rgb 1}
Post a reply to this message
|
|