|
![](/i/fill.gif) |
Rune wrote:
8<..... snip .....
> The first macro is just a macro needed by the second macro.
> The second macro do what I wanted to do.
8<..... snip .....
>#macro FindAngle (V1,V2,About) // by Rune S. Johansen
> #local Angle = degrees(acos(vdot(vnormalize(V1),vnormalize(V2))));
> #if (
> (vlength(About)!=0)
> &
>(vlength(vaxis_rotate(V1,-About,Angle)-V2)<
> vlength(vaxis_rotate(V1,About,Angle)-V2)))
> #local Angle = -Angle;
> #end
> Angle
>#end
8<..... snip .....
>#macro Vectors2Rotate (VectorX,VectorY) // by Rune S. Johansen
> #local RotZ = FindAngle(x,<VectorX.x,VectorX.y,0>,z);
> #local RotY = FindAngle(x,vrotate(X,-RotZ*z),y);
> #local RotX = FindAngle(vrotate(y,<0,RotY,RotZ>),VectorY,VectorX);
> <RotX,RotY,RotZ>
>#end
8<..... snip .....
I think there must be an error in your second macro.
The variable X (in the 3rd line) is not defined.
Is this meant to be a lower case x ?
And I believe your first macro could be simplified to this:
#macro Find_Angle(v1, v2, vAbout)
(vdot(vAbout, vcross(v1, v2)) < 0 ? -1 : 1)*
degrees(acos(vdot(vnormalize(v1), vnormalize(v2))))
#end // macro FindAngle
This macro gives the Angle the same sign as the
Scalar Triple Product of your 3 vectors;
vAbout, v1 and v2
Regards,
Tor Olav
--
mailto:tor### [at] hotmail com
http://www.crosswinds.net/~tok/tokrays.html
Post a reply to this message
|
![](/i/fill.gif) |