|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> 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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
|
|