POV-Ray : Newsgroups : povray.advanced-users : Truck and trailer Server Time
29 Jul 2024 14:25:29 EDT (-0400)
  Truck and trailer (Message 21 to 30 of 35)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 5 Messages >>>
From: Thomas van der Veen
Subject: Re: Truck and trailer
Date: 3 Sep 2002 06:38:19
Message: <Xns927E7659C8D07veentukibmcom@204.213.191.226>
"J. Diehl" <j.d### [at] firemailde> wrote in
news:web.3d715afea31ba4aac8339f710@news.povray.org: 


> That was a nice topic for my homepage: I've just finished a site
> describing my model with all math and trigonometry in more detail.
> Inclusive a realtime flash-simulation and a POV animation with
> realistic steering front wheels (commented POV source available).

Your site looks great! and the flash thingy is excellent, great fun to play 
with.

I tried the last two evenings to implement it and I ran into all kinds of 
weird problems, mostly because the stuff I'm trying to animate are a bit 
limited compared to you model. This is one of the models I'm trying to get 
going is:

http://library.brickshelf.com/scans/2000/2149/

As you can see the front wheels of the truck don't steer, And I have been 
playing with some real Lego for the last few days at my desk and decided 
that I just turn the truck around the point in the middle between the two 
axle's (I simplified my model a bit more than the 2149, just two axle's on 
the truck and a single on the trailer). I do realize that that is not 
entirely realistic but it seems that real Lego "squeezes" through corners 
as well.

The second problem seems to be that the point where the trailer is attached 
to the truck is not directly on an axle as it in your model. I tried to get  
a single pole model going but something goes wrong..... :(

> No alcohol when driving!

Oooooopppppssss to late ;)


Thomas


Post a reply to this message

From: J  Diehl
Subject: Re: Truck and trailer
Date: 3 Sep 2002 18:30:05
Message: <web.3d753744a31ba4aafed4f2250@news.povray.org>
I already thought about a link-offset (and some other things, see below) and
I’ll give you a fast solution you can try. (I had no time to simulate
yet, but this will follow)

You remember this part in the driveTo-macro:

//get the new position of the pole
#declare d=sqrt(dx*dx+dy*dy);
#declare tomove=d-Length[Pole];
#declare PosX[Pole]=PosX[Pole]+dx/d*tomove;
#declare PosY[Pole]=PosY[Pole]+dy/d*tomove;

In the last two lines we first normalize the d-vector (divide it by ist
length to get legth=1) and then multiply it by our distance to move. A link
with LinkDist units behind the axis (positive value) can be computed
similar. So add the following two lines:

#declare LinkPosX[Pole]=PosX[Pole]-dx/d*LinkDist[Pole]
#declare LinkPosY[Pole]=PosY[Pole]-dy/d*LinkDist[Pole]

This should give us the absolute coordinates of the Link after moved.

When the driveTo macro is called for your trailer, just tell it to follow
LinkPosX/Y instead of PosX/Y - that should fit the problem.

(You will have to add the new Array definitions outside this macro before
running)

Coordinate system of the new model:
Length gives us the distance from rotating point (origin of the truck model)
to the front link. LinkDist is the distance to the back link. The whole
length of this special 'pole' will be Length+LinkDist.
For your pulling truck, define Length and LinkDist with the same value
(every the half of the truck’s length), and it will rotate around ist
center. Putting no axle or wheels at the defined axle (origin), but
somewhere else in the front and back means that the wheels will squeeze
when driving around. Hurts my ears a bit ;-)

The model is still very idealistic. A very interesting thing i.e. will be
how far every wheel rotates to draw realistic rolling rims when steering. I
already have a solution in my head - coming soon.


Post a reply to this message

From: J  Diehl
Subject: Re: Truck and trailer
Date: 4 Sep 2002 06:50:08
Message: <web.3d75e4d8a31ba4aaf70c33440@news.povray.org>
First a question: why do you want to use single back axles? In my eyes it
would look better with the second axle.

I would try to animate it with two pole definitions like this:
Having a look at the plans of 2149 (assuming two axles) I  would put the
origin of the truck (where it turns around) at exactly the half of the
16-unit-construction. Putting the 'front link' (the point to follow the
path) exactly at the front axle, we get a 'PoleLength' of 6 units (dist.
origin --> front axle). The distance from origin to back link is 5 units
('LinkDist'=5). Translate your truck model so that the front axle is drawn
at z=6, the first back axle at z=-3 and the second at z=-6 (on an x-z-plane
with the truck looking at the +z direction)
For the trailer, lets put the origin to turn around at the middle of the two
axles (at the two red round 1 unit-bricks at the bottom of the trailer). In
my eyes, the front link of the trailer is 18 units away (please count
again). This is our 'PoleLength' for the trailer. LinkDist can be 0 here
(there is no further trailer). Translate your trailer so that the axles are
at z=1,5 and z=-1,5.


Post a reply to this message

From: Thomas van der Veen
Subject: Re: Truck and trailer
Date: 4 Sep 2002 06:56:21
Message: <Xns927F7967F9458veentukibmcom@204.213.191.226>
"J. Diehl" <j.d### [at] firemailde> wrote in
news:web.3d75e4d8a31ba4aaf70c33440@news.povray.org: 

> First a question: why do you want to use single back axles? In my eyes
> it would look better with the second axle.


I have been playing with a simplified model for the last few days in order 
to speed up rendering. And tha uses only on axle. Once I get the concecpt 
going I would put the turning point of the truck between the two axle's.

I just saw your two note and I will give it a try, but I don't know when I 
have time to do it :( busy, busy busy. But I will keep you posted on my 
progress.

Thanks!!!

Thomas


Post a reply to this message

From: J  Diehl
Subject: Re: Truck and trailer
Date: 4 Sep 2002 07:05:07
Message: <web.3d75e7cda31ba4aaf70c33440@news.povray.org>
//my suggestion (with clock 0-1)

//-------------------------------------------------------
// truck-and-trailer problem
// POV-implementation
// (c) 2002 J. Diehl
// http://enter.diehlsworld.de
//-------------------------------------------------------


//-------------------------------------------------------
// some math macros
//-------------------------------------------------------

//the main macro to drive a pole to a given destination (NewX,NewY)
//it computes the new position and angle of the pole
#macro driveTo (Pole, NewX,NewY)

 //get the vector [axle --> new position]
 #declare dx=NewX-PosX[Pole];
 #declare dy=NewY-PosY[Pole];

 //get the new position of the pole
 #declare d=sqrt(dx*dx+dy*dy);
 #declare tomove=d-Length[Pole];
 #declare PosX[Pole]=PosX[Pole]+dx/d*tomove;
 #declare PosY[Pole]=PosY[Pole]+dy/d*tomove;

 //get the new position of the back link
 #declare LinkPosX[Pole]=PosX[Pole]-dx/d*LinkDist[Pole]
 #declare LinkPosY[Pole]=PosY[Pole]-dy/d*LinkDist[Pole]

 //get the angle of the pole
 #declare Angle[Pole]=0;
 #if (d!=0)
 #declare Angle[Pole]=atan2(dx,dy)/pi*180;
 #end
#end


//a macro for a simple path (very simple, of course! - a line)
//Put your own spline here
#declare ax=-10;
#declare ay=6;
#declare ex=30;
#declare ey=40;
#macro getPath(time)
        #declare PathX=ax*(1-time)+ex*time;
        #declare PathY=ay*(1-time)+ey*time;
#end

//-------------------------------------------------------
//definition of poles
//-------------------------------------------------------

#declare Poles=2;

#declare PosX=array[Poles]
#declare PosY=array[Poles]
#declare Length=array[Poles]
#declare Angle=array[Poles]

//variables for back link
#declare LinkPosX=array[Poles]
#declare LinkPosY=array[Poles]
#declare LinkDist=array[Poles]


//the initial position of each pole is the position where it was 'parked'
before linking first.
//it affects the direction the pole will be linked to the previous in the
first step.
#declare PosX[0]=20;
#declare PosY[0]=0;
#declare Length[0]=6;
#declare LinkDist[0]=5;

#declare PosX[1]=0;
#declare PosY[1]=2;
#declare Length[1]=18;
#declare LinkDist[1]=0;




//-------------------------------------------------------
//Follow the path
//-------------------------------------------------------

#declare myclock=clock;

//since we can't store the actual position from one frame to the next,
//we have to follow the path up to the current frame everytime.
//the smaller the steps, the more realistic the movement
#declare time=0;
#declare step=0.001;
#while (time <= myclock)
        getPath(time)

        //pole #0 follows the path,
        //pole #1 follows pole #0 and so on...
        driveTo (0,PathX,PathY)
        driveTo (1,LinkPosX[0],LinkPosY[0])

        #declare time=time+step;
#end




//-------------------------------------------------------
//draw the scene
//-------------------------------------------------------

camera {location<12,18,12> look_at < LinkPosX[0],0,LinkPosY[0]>}
light_source {<0,3000,0> color rgb 1}
light_source {<1000,1000,1000> color rgb 1}

plane
{
  y, 0
  pigment {color rgb <0.7,0.6,0.5>}
  normal {granite 0.3 scale 5}
  hollow on
}



//this one shows the path on the ground the truck will follow
cylinder{< ax,0,ay> < ex,0,ey> 0.2
        pigment{color rgb <0,0,1>}
        }



//the truck (pole #0)
union{
    box{<-1,1.8,-8><1,2,8>}
    cylinder{<-2,1,6><2,1,6> 1 pigment {color rgb 0.3}}
    cylinder{<-2,1,-3><2,1,-3> 1 pigment {color rgb 0.3}}
 cylinder{<-2,1,-6><2,1,-6> 1 pigment {color rgb 0.3}}
 pigment {color rgb 0.7}
 //first rotate, then translate the whole to the destination
 rotate y*Angle[0]
 translate < PosX[0],0,PosY[0]>
 }


//the trailer (pole #1)
union{
    cylinder{<-2,1,1.5><2,1,1.5 > 1 pigment {color rgb 0.3}}
    cylinder{<-2,1,-1.5 ><2,1,-1.5 > 1 pigment {color rgb 0.3}}
    box{<-1,2.2,-4.5><1,2.4,19.5>}
    pigment {color rgb 0.5}
 //first rotate, then translate the whole to the destination
 rotate y*Angle[1]
 translate < PosX[1],0,PosY[1]>
 }


Post a reply to this message

From: Thomas van der Veen
Subject: Re: Truck and trailer
Date: 4 Sep 2002 07:34:12
Message: <Xns927F7FD30932Aveentukibmcom@204.213.191.226>
"J. Diehl" <j.d### [at] firemailde> wrote in 
news:web.3d75e7cda31ba4aaf70c33440@news.povray.org:

> 
> 
> //my suggestion (with clock 0-1)


I'll give that a try in a moment!!!

Thank you very much indeed!


Thomas


Post a reply to this message

From: Thomas van der Veen
Subject: Re: Truck and trailer
Date: 4 Sep 2002 08:23:46
Message: <Xns927F883A01DCCveentukibmcom@204.213.191.226>
"J. Diehl" <j.d### [at] firemailde> wrote in 
news:web.3d75e7cda31ba4aaf70c33440@news.povray.org:

> 
> 
> //my suggestion (with clock 0-1)
> 


I just rendered it here at work and it looks great! Now all I need to do is  
to find sometime and implement it....


Thomas


Post a reply to this message

From: hughes, b 
Subject: Re: Truck and trailer
Date: 4 Sep 2002 23:17:23
Message: <3d76ccc3@news.povray.org>
hmmmm This would go nicely into povray.text.scene-files group.


Post a reply to this message

From: J  Diehl
Subject: Re: Truck and trailer
Date: 5 Sep 2002 16:55:08
Message: <web.3d77c376a31ba4aae0c0cc580@news.povray.org>
Thomas van der Veen wrote:
>I just rendered it here at work and it looks great! Now all I need to do is
>to find sometime and implement it....

I'm pleased I could help. And thanks for the idea with Lego models - I'm
just starting with them and experimenting a little. But rebuilding your
truck would take me years... aaargh! Pieces never rest where I want to...!
'Nice' sculptures, though, look a bit like modern art or fractals or...
:-)))

Playing with LeoCAD and exporting to POV, I figured out that the coordinate
system is very different to mine (I'm not the first, I guess). But with
putting the parts into a union and do some rotate <-90,180,0> and scale
1.25 on it, it fits with my coordinates (x=left-right, y=up-down,
z=back-forward, 1 POV unit = 1 brick unit).

You'll have to find some translations for your parts, too. I think it's much
easier than trying to translate my script into any LeoCAD or LDraw
coordinate system.

have a nice time
jo


Post a reply to this message

From: J  Diehl
Subject: Re: Truck and trailer
Date: 5 Sep 2002 17:10:09
Message: <web.3d77c805a31ba4aae0c0cc580@news.povray.org>
hughes, b. wrote:
>hmmmm This would go nicely into povray.text.scene-files group.
>

At the time, this model is beeing tested and modified in any thinkable way,
and we're discussing rather ideas than scripts here.
Looking at the complete scene I posted above - right, that could have been
done in scene-files, too (and animations!?). So I'll post it there when
everything is done and wheels are rotating... be patient.


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 5 Messages >>>

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