POV-Ray : Newsgroups : povray.advanced-users : Convert matrix to rotate ? : Re: Convert matrix to rotate ? Server Time
30 Jul 2024 02:16:07 EDT (-0400)
  Re: Convert matrix to rotate ?  
From: Tor Olav Kristensen
Date: 20 May 2000 15:55:38
Message: <3926ECD9.34DCD419@hotmail.com>
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] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.