POV-Ray : Newsgroups : povray.general : From a normal to an angle? Server Time
1 Aug 2024 00:17:02 EDT (-0400)
  From a normal to an angle? (Message 1 to 8 of 8)  
From: Tim McMurdo
Subject: From a normal to an angle?
Date: 19 Aug 2006 16:45:00
Message: <web.44e77810987acea1e921dc270@news.povray.org>
How do I convert a nomal generated by the trace function to an angle in
degrees? I am trying to determine the final transformation....here is the
code I am using:

I am trying to determine the location and rotation of the object after it is
place on the ship's deck.

Tim


Post a reply to this message

From: Tim McMurdo
Subject: Re: From a normal to an angle?
Date: 19 Aug 2006 17:05:01
Message: <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}


Post a reply to this message

From: Chris B
Subject: Re: From a normal to an angle?
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

From: Chris B
Subject: Re: From a normal to an angle?
Date: 19 Aug 2006 18:16:56
Message: <44e78dd8@news.povray.org>
"Chris B" <c_b### [at] btconnectcomnospam> wrote in message 
news: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.
>

Aargh,
Please ignore the above, I realised that I'm testing Norm instead of Test, 
so I'd fooled myself into believing I'd got it right.

Regards,
Chris B.


Post a reply to this message

From: Chris B
Subject: Re: From a normal to an angle?
Date: 19 Aug 2006 18:50:10
Message: <44e795a2$1@news.povray.org>
> I'd fooled myself into believing I'd got it right.
>
> Regards,
> Chris B.
>

Sorry about that, I should have been using VRotationD to pick up the angle 
and I'd failed to get the correct sequence of parameters to get the 
rotational directions correct. The following should be good to go.

#include "Math.inc"

#local Norm = <1,2,3>;
//#local Norm = <-1,2,-3>;
//#local Norm = <-8,-2,4>;
//#local Norm = vrotate(y,<-46,0,-45>);

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


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

Regards,
Chris B.


Post a reply to this message

From: Warp
Subject: Re: From a normal to an angle?
Date: 19 Aug 2006 20:30:37
Message: <44e7ad2d@news.povray.org>
Tim McMurdo <jod### [at] wohrrcom> wrote:
> I am trying to determine the location and rotation of the object after it is
> place on the ship's deck.

  It might be easier to use the functions in transforms.inc. They do all
the hard work for you.

-- 
                                                          - Warp


Post a reply to this message

From: Kenneth
Subject: Re: From a normal to an angle?
Date: 9 Sep 2006 03:40:01
Message: <web.45026de32c8bed1cee7c01140@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Tim McMurdo <jod### [at] wohrrcom> wrote:
> > I am trying to determine the location and rotation of the object after it is
> > place on the ship's deck.
>
>   It might be easier to use the functions in transforms.inc. They do all
> the hard work for you.
>
> --
>                                                           - Warp

As Warp says, there are REALLY useful rotators and such in transforms,inc.
......although the descriptions of what they do can be a bit difficult to
understand at first. The one I like to use, for what you're trying to
achieve, is Point_At_Trans. It can take an object made at the origin in the
normal way (y-axis pointing up), and whirl the object's y-axis around to
meet a traced normal. I.e., Point_At_Trans (norm). Great for sticking
spiky things onto heightfields! Place it in your code where you would
put a typical rotate command.

Ken W.


Post a reply to this message

From: Kenneth
Subject: Re: From a normal to an angle?
Date: 10 Sep 2006 04:40:00
Message: <web.4503cf212c8bed1cc2d4f2880@news.povray.org>
"Tim McMurdo" <jod### [at] wohrrcom> wrote:

> I am trying to determine the location and rotation of the object after it is
> place on the ship's deck.
>
> Tim

Re-reading your question a day later (with my brain working a bit better), I
see that I misread it. You're trying to find the position and angle of an
already-placed object.

Sorry 'bout that....   :-[

Ken


Post a reply to this message

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