|
![](/i/fill.gif) |
Hello group, i need your help. i am trying to move CSG objects along a curve.
That's easy, but the problem here is i dont want any gaps between the objects.
So, it will involve some trigonometric operations.
imagine you have a box and you see it from above.
rotation are about the y axis
first you have to rotate it at origin multiplied by the while control variable
(magsec in my example).
Next i will translate it so as the right down side of the box will just touch
the previous box edge.
the left side will merge with the previous box some more, so there will be no
gap.
the object is 55.88 wide and 44 depth.
the uncorrected translate after the rotate will be 44*magsec. then you have to
back it a bit along the z axis to remove the gap.
I figured that it will be a z translate of tan(angle)*55.88/2
Next you will have to move along the x axis to make the whole path curved
I figured that it will be a x translate of sin(angle)*44
But these vectors will be affected by the rotation along the curve so I thought
that i will need to vrotate them, and add the cumulatively.
So here is the SDL :
#declare tx = <0,0,0>;
#declare tz = <0,0,0>;
#declare txb = <44*sin(2*pi*1.665/360),0,0>; // x correction to create
the curve path
#declare tzb = <0,0,(55.88/2)*tan(2*pi*1.665/360)>; // z correction to
remove gap
#declare magsec = 0;
#while(magsec < 80)
#declare vrx = vrotate(txb,<0,-1.665*(magsec),0>); // take into account
the rotational effect on the vectors
#declare vrz = vrotate(tzb,<0,-1.665*(magsec+1),0>); // take into account
the rotational effect on the vectors
#declare txtmp = tx;
#declare tztmp = tz;
#declare tx = txtmp + vrx; // cumulative addition of vectors
#declare tz = tztmp + vrz; // cumulative addition of vectors
#declare leftmag3 = object{maglev_track_section
no_shadow
double_illuminate
rotate magsec*1.665*y // rotate at origin
translate 44*z*magsec // translate without corrections
translate -tx // create curve
translate -tz // remove gap
}
object { leftmag3 }
#declare magsec = magsec + 1;
#end
Please help me find the problem, or if you know a better algorithm.
Thank you.
Post a reply to this message
|
![](/i/fill.gif) |