|
![](/i/fill.gif) |
This macro (right from the MakeTree macro where it's used to align branch
segments) could do the trick. There may be other of this kind at
http://twysted.net and of course it is mandatory to mention John VanSickle's
"Thoroughly Useful Macros" at http://www.erols.com/vansickl/macs.htm
Gilles Tran
//=========================================
// macro mAlign
//-----------------------------------------
// returns a matrix operation that aligns an object or texture along P2-P1
// the object is translated to P1
// translate to P2-P1 if you want the object to be on P2
#macro mAlign(P1,P2)
#local yV1=vnormalize(P2-P1);
#local xV1=vnormalize(vcross(yV1,z));
#local zV1=vcross(xV1,yV1);
matrix <xV1.x,xV1.y,xV1.z,yV1.x,yV1.y,yV1.z,zV1.x,zV1.y,zV1.z,P1.x,P1.y,P1.z>
#end
Tom Melly wrote:
> Well, i spent the weekend with this and got nowhere useful.
>
> If, you have an object and you want to move it in the direction that it's
> pointing, how do you calculate the new position from the old position?
>
> For example, assume that ObjArrow is an arrow that, with a rotation of 0,
> points in the Y direction. To move the arrow, you just increase the Y
> translation.
>
> or
> #declare n = 0;
> #while n < 10
> object {ObjArrow translate <0, n, 0>}
> #declare n = n +1;
> #end
>
> However, I want to be able to do this for more complex rotations, and ensure
> that my object move in the direction of its "surface normal", so to speak.
>
> I assume that there are lots of cos and sin etc, and it's doing my head in
> (although I can just about manage the equations for 2 dimensions).
>
> Can anyone help and/or refer me to a good shrink and/or marriage guidence
> counsellor?
Post a reply to this message
|
![](/i/fill.gif) |