POV-Ray : Newsgroups : povray.general : From a normal to an angle? : Re: From a normal to an angle? Server Time
31 Jul 2024 22:20:30 EDT (-0400)
  Re: From a normal to an angle?  
From: Chris B
Date: 19 Aug 2006 18:10:10
Message: <44e78c42@news.povray.org>
"Tim McMurdo" <jod### [at] wohrrcom> wrote in message 
news:web.44e77cee2c8bed1ce921dc270@news.povray.org...
>I forgot the code...oops!
>
>                #declare Target =
>                        object {NiagaraHull_1C_
>                              scale 330
>                              rotate<0,-90,0>
>                              translate<1000,-1000,00>
>
>
>                        }
>                #declare Norm = <0, 0, 0>;
>                #declare Start = <-3496,5000,0>;
>                #declare Inter =trace ( Target, Start, <0, -1, 0>, Norm );
>
>
>
>                object{MainFifeRail Reorient_Trans(<0,1,0>,  Norm) 
> translate
> Inter}
>

Hi Tim,

I'd recommend doing it in two parts, so you get the rotation in x followed 
by the rotation in z.

For the z rotation you need the angle between the x,y components of the 
Normal and the y axis:
#local Z_Rotation =  VAngleD(Norm*<1,1,0>,y);

Now you can rotate the Normal back to the z-y plane then work out the x 
rotation:
#local X_Rotation = VAngleD(vrotate(Norm, -Z_Rotation*z),y);

I 've included a little test script that you may find handy below (VAngleD 
is in math.inc).
The last two lines rotate a vector of the same length back into position and 
write the position into the message stream, so it should always be the same 
as the vector you start with.

#include "Math.inc"

//#local Norm = <1,2,3>;
//#local Norm = <-1,2,-3>;
#local Norm = <-8,2,4>;


#local Z_Rotation = VAngleD(Norm*<1,1,0>,y);
#local X_Rotation = VAngleD(vrotate(Norm, -Z_Rotation*z),y);


#local Test = vrotate(y*vlength(Norm),<X_Rotation,0,Z_Rotation>);
#debug concat(vstr(3,Norm,",",3,3),"\n")

Regards,
Chris B.


Post a reply to this message

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