POV-Ray : Newsgroups : povray.newusers : Object Rotation Server Time
5 Sep 2024 04:13:34 EDT (-0400)
  Object Rotation (Message 1 to 5 of 5)  
From: Les Patterson
Subject: Object Rotation
Date: 31 Jan 2002 17:55:09
Message: <3C59E81B.1040701@txcyber.com>
There's something I don't understand about rotation.
In the case of an aircraft positioned at 0,0,0(facing camera) then X, 
and Z work fine, but rotate the aircraft to a right angle to the camera, 
0,-90,0 and then X & Z don't rotate as expected. I understand that this 
is a 360degree universe, but if that's the case then why wouldn't the 
rotational angles be the same regardless of which direction the aircraft 
is pointing?

What is a good solution for "dipping" the wing when rotated 0,-90,0? The 
only thing I've been able to do is change the angle of the nose of the 
plane with either X or Z rotation. I know there is probably a simple 
answer for this but it seems to escape me.

As always thanks for any help or info,
Les


Post a reply to this message

From: Warp
Subject: Re: Object Rotation
Date: 31 Jan 2002 20:33:10
Message: <3c59f056@news.povray.org>
Les Patterson <les### [at] txcybercom> wrote:
: There's something I don't understand about rotation.
: In the case of an aircraft positioned at 0,0,0(facing camera) then X, 
: and Z work fine, but rotate the aircraft to a right angle to the camera, 
: 0,-90,0 and then X & Z don't rotate as expected. I understand that this 
: is a 360degree universe, but if that's the case then why wouldn't the 
: rotational angles be the same regardless of which direction the aircraft 
: is pointing?

  If you tell povray to rotate an object around the x-axis, it will rotate
the object around the x axis. There's no reason for it to rotate it around
any other axis. It rotates the object around the x-axis regardless of the
current orientation of the object.
  Also you have to understand that the effect of consecutive rotations are
summed in the order they are given. This means that if you do this:

  rotate <50,0,0>
  rotate <30,0,0>

the final orientation of the object will be equivalent to

  rotate <80,0,0>

  Now, with these two things in mind, think about these consecutive rotations:

  rotate <0,45,0>
  rotate <45,0,0>
  rotate <0,-45,0>
  rotate <-45,0,0>

  It might not be clear at first, but the net effect of those rotations
is *not* as if no rotations were made at all.

  Suppose we have a regular box { -1,1 } which we are rotating that way.
  First we rotate it 45 degrees around the y-axis. Now the face which was
facing the camera is oriented so that it's 45 degrees to the left (the side
of the box which was facing right is now 45 degrees to the right).
  Then we rotate 45 degrees around the x-axis. Here it's important to
understand that the rotation is done around the x-axis, not any other axis.
The cube is rotated so that now we see three of its faces (the new face is
the lower face which became visible). The corner of the box is pointing
approximately at the camera.
  The next rotation is more difficult to imagine in our head (thus it's
better to do it in povray to see it). We rotate -45 degrees around the y-axis.
The box is rotate so that the corner which was pointing at the camera now
points 45 degrees to the right. We still see the lower face and the original
front face of the box, but it's tilted
  Finally we rotate -45 degrees around the x-axis. The final orientation
of the box looks awkward because it still is tilted. It's oriented
approximately so that the original front face of the box is again facing
the camera, but the whole box is tilted.

  I know that this is pretty confusing, but it's a direct consequence of
the fact that rotations are always made around the axes. You should test
with the box example to see what happens. Here's a simple scene:

camera { location -z*7 look_at 0 angle 35 }
light_source { <100,200,-300>, 1 }

box
{ -1,1 pigment { rgb <1,.5,0> }
  rotate <0,45,0>
  rotate <45,0,0>
  rotate <0,-45,0>
  rotate <-45,0,0>
}

  Note that the order of the rotations matter. If we shuffle the rotations
above, we will get a different result.

  With your aircraft you have to make the rotations in the right order
to get the correct result. You probably want to rotate first around the
main longitudinal axis of the plane, then around the "pitch" axis and then
the axis which orients the plane to wherever it is heading.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Mike Williams
Subject: Re: Object Rotation
Date: 1 Feb 2002 02:34:12
Message: <tfusoGAqQkW8Ew9y@econym.demon.co.uk>
Wasn't it Les Patterson who wrote:
>There's something I don't understand about rotation.
>In the case of an aircraft positioned at 0,0,0(facing camera) then X, 
>and Z work fine, but rotate the aircraft to a right angle to the camera, 
>0,-90,0 and then X & Z don't rotate as expected. I understand that this 
>is a 360degree universe, but if that's the case then why wouldn't the 
>rotational angles be the same regardless of which direction the aircraft 
>is pointing?
>
>What is a good solution for "dipping" the wing when rotated 0,-90,0? The 
>only thing I've been able to do is change the angle of the nose of the 
>plane with either X or Z rotation. I know there is probably a simple 
>answer for this but it seems to escape me.

Let me make a bit of an educated guess that you are trying to do both
the Y rotation and the wing dip with a single rotation. Try doing it as
two separate rotations instead. 

Either
        rotate <0, 0, 20>       // wing dip
        rotate <0, -90, 0>      // turn
or
        rotate <0, -90, 0>      // turn
        rotate <20, 0, 0>       // wing dip

What happens is that POV performs the three components of rotation in
the order X,Y,Z. If you try to write it as "rotate <20, -90, 0>" then
the X rotation (currently nose angle) happens before the turn. If you
try to write it as "rotate <0, -90, 20>" then the Y rotation happens
first, and the Z rotation (which originally would have controlled the
wing dip) now affects the nose angle.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Les Patterson
Subject: Re: Object Rotation
Date: 1 Feb 2002 14:53:12
Message: <3C5B0EF6.5010603@txcyber.com>
Warp,
  Ah, I think I understand now. What you're saying is that Pov needs to 
calculate one angle at a time and get a sum total.
  Thanks for the help, I'll try the example and see how it all works, 
but it does make more sense now.
Les

Warp wrote:

> Les Patterson <les### [at] txcybercom> wrote:
> : There's something I don't understand about rotation.
> : In the case of an aircraft positioned at 0,0,0(facing camera) then X, 
> : and Z work fine, but rotate the aircraft to a right angle to the camera, 
> : 0,-90,0 and then X & Z don't rotate as expected. I understand that this 
> : is a 360degree universe, but if that's the case then why wouldn't the 
> : rotational angles be the same regardless of which direction the aircraft 
> : is pointing?
> 
>   If you tell povray to rotate an object around the x-axis, it will rotate
> the object around the x axis. There's no reason for it to rotate it around
> any other axis. It rotates the object around the x-axis regardless of the
> current orientation of the object.
>   Also you have to understand that the effect of consecutive rotations are
> summed in the order they are given. This means that if you do this:
> 
>   rotate <50,0,0>
>   rotate <30,0,0>
> 
> the final orientation of the object will be equivalent to
> 
>   rotate <80,0,0>
> 
>   Now, with these two things in mind, think about these consecutive rotations:
> 
>   rotate <0,45,0>
>   rotate <45,0,0>
>   rotate <0,-45,0>
>   rotate <-45,0,0>
> 
>   It might not be clear at first, but the net effect of those rotations
> is *not* as if no rotations were made at all.
> 
>   Suppose we have a regular box { -1,1 } which we are rotating that way.
>   First we rotate it 45 degrees around the y-axis. Now the face which was
> facing the camera is oriented so that it's 45 degrees to the left (the side
> of the box which was facing right is now 45 degrees to the right).
>   Then we rotate 45 degrees around the x-axis. Here it's important to
> understand that the rotation is done around the x-axis, not any other axis.
> The cube is rotated so that now we see three of its faces (the new face is
> the lower face which became visible). The corner of the box is pointing
> approximately at the camera.
>   The next rotation is more difficult to imagine in our head (thus it's
> better to do it in povray to see it). We rotate -45 degrees around the y-axis.
> The box is rotate so that the corner which was pointing at the camera now
> points 45 degrees to the right. We still see the lower face and the original
> front face of the box, but it's tilted
>   Finally we rotate -45 degrees around the x-axis. The final orientation
> of the box looks awkward because it still is tilted. It's oriented
> approximately so that the original front face of the box is again facing
> the camera, but the whole box is tilted.
> 
>   I know that this is pretty confusing, but it's a direct consequence of
> the fact that rotations are always made around the axes. You should test
> with the box example to see what happens. Here's a simple scene:
> 
> camera { location -z*7 look_at 0 angle 35 }
> light_source { <100,200,-300>, 1 }
> 
> box
> { -1,1 pigment { rgb <1,.5,0> }
>   rotate <0,45,0>
>   rotate <45,0,0>
>   rotate <0,-45,0>
>   rotate <-45,0,0>
> }
> 
>   Note that the order of the rotations matter. If we shuffle the rotations
> above, we will get a different result.
> 
>   With your aircraft you have to make the rotations in the right order
> to get the correct result. You probably want to rotate first around the
> main longitudinal axis of the plane, then around the "pitch" axis and then
> the axis which orients the plane to wherever it is heading.


Post a reply to this message

From: Les Patterson
Subject: Re: Object Rotation
Date: 1 Feb 2002 14:57:13
Message: <3C5B0FE7.7050501@txcyber.com>
Mike,
  Yes I was trying to set all angles at once, and after reading yours' 
and Warps posts, I understand much better how to do this.
  Thanks a million to both of you!
Les

Mike Williams wrote:

> Wasn't it Les Patterson who wrote:
> 
>> There's something I don't understand about rotation.
>> In the case of an aircraft positioned at 0,0,0(facing camera) then X, 
>> and Z work fine, but rotate the aircraft to a right angle to the camera, 
>> 0,-90,0 and then X & Z don't rotate as expected. I understand that this 
>> is a 360degree universe, but if that's the case then why wouldn't the 
>> rotational angles be the same regardless of which direction the aircraft 
>> is pointing?
>> 
>> What is a good solution for "dipping" the wing when rotated 0,-90,0? The 
>> only thing I've been able to do is change the angle of the nose of the 
>> plane with either X or Z rotation. I know there is probably a simple 
>> answer for this but it seems to escape me.
> 
> 
> Let me make a bit of an educated guess that you are trying to do both
> the Y rotation and the wing dip with a single rotation. Try doing it as
> two separate rotations instead. 
> 
> Either
>         rotate <0, 0, 20>       // wing dip
>         rotate <0, -90, 0>      // turn
> or
>         rotate <0, -90, 0>      // turn
>         rotate <20, 0, 0>       // wing dip
> 
> What happens is that POV performs the three components of rotation in
> the order X,Y,Z. If you try to write it as "rotate <20, -90, 0>" then
> the X rotation (currently nose angle) happens before the turn. If you
> try to write it as "rotate <0, -90, 20>" then the Y rotation happens
> first, and the Z rotation (which originally would have controlled the
> wing dip) now affects the nose angle.


Post a reply to this message

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