|
|
To do this I usually just use some basic trig and reorient one axis at a time.
The box is made along the x-axis, so first rotation is to apply a twist about
that x-axis if you want it, otherwise it remains upright through rotations.
Next rotation is to rotate away from the x-z plane by rotating around the
z-axis.
Final rotation is to rotate to final position around the vertical y-axis.
Just the #for Loop portion:
#for (Test, 0, min(dimension_size (StartArray, 1), dimension_size
(EndArray,1))-1 )
#debug concat( " Test = ", str(Test, 3, 1), "\n")
#declare Point1 = StartArray [Test];
#declare Point2 = EndArray [Test];
#declare Vec = Point2 - Point1; //Direction vector to orient to
#declare StrutLength = vlength(Vec); //LENGTH OF BOX
//Twist rotates the box around the long axis first
#declare Twist = 45;
//RotZ and RotY reoorient the box to align to the vector
#declare RotZ = degrees(atan2(Vec.y,vlength(<Vec.x,0,Vec.z>))); //ROTATION
ABOUT Z-AXIS
#declare RotY = degrees(atan2(Vec.z,Vec.x)); //ROTATION
ABOUT Y-AXIS
#declare IBeam = box {<0, -Strut/2, -Strut/2>, <StrutLength, Strut/2,
Strut/2>}
sphere {Point1 0.5 pigment {Orange*0.5} }
sphere {Point2 0.5 pigment {Violet*0.5} }
#declare NewIBeam =
object {
IBeam
rotate Twist*x
rotate RotZ*z
rotate RotY*y
translate Point1
}
object {NewIBeam pigment {Blue} }
#end // end for Test
Post a reply to this message
|
|