|
|
Ger wrote:
> I have a #macro that creates a wall :
>
>
> #macro OutSideWall(Position1,End1,Position2,End2)
> // ---------- for testing purpose only
> cylinder{Position1,Position1+<0,400,0>,30 pigment { red 1 }}
> cylinder{Position2,Position2+<0,450,0>,25 pigment { blue 1 }}
> // ----------
> #local XLength = Position2.x - Position1.x;
> #local ZLength = Position2.z - Position1.z;
> #local WallLength = VDist(Position1,Position2);
> #local Angle = degrees(asin(ZLength/WallLength));
>
> #local LogCounter = 0;
> #declare ThisWall =
> union {
> #while ((LogCounter * HtHLogDistance) < OutsideWallHeight)
> object { Log(WallLength,End1,End2) translate y * HtHLogDistance *
> (LogCounter+0.5) }
> #local LogCounter = LogCounter + 1;
> #end
> }
>
> object { ThisWall rotate y * Angle translate Position1 }
> #end
>
> so I can do this
>
> OutSideWall(< 200,0,1200>, true,< 200,0,800>, true)
> OutSideWall(< 200,0,800>, true,< 400,0, 800>, true)
>
> for a whole building
>
> The walls are created just fine and placed at the correct place (Position1)
> but the rotation (rotate Angle) is wrong.
You really don't need to do this arcsin and rotation stuff.
The better way to do it is:
#local vZ=vnormalize(Position2-Position1);
#local vX=vnormalize(vcross(y,vZ));
and replace the rotate and translate with this:
matrix < vX.x, vX.y, vX.z,
0, 1, 0,
vZ.x, vZ.y, vZ.z,
Position1.x, Position1.y, Position1.z>
It may help you with this to also read
http://www.geocities.com/evilsnack/matrix.htm ,
which is tutorial I wrote about the matrix transform.
Regards,
John
Post a reply to this message
|
|