Re: Convert axis and angle of rotation to rotations about X & Y axis'
- From: ericgorr@xxxxxxxxx
- Date: 15 Dec 2005 12:43:42 -0800
Just d' FAQs wrote:
> On 14 Dec 2005 06:45:11 -0800, ericgorr@xxxxxxxxx wrote:
> >I am only concerned about aim, roll about the aim direction is not
> >important for my situation.
> >
> >Here's a (probably inefficient) possible solution:
> >
> >I'll work with the 3D coordinate system as pictured here:
> >http://mathworld.wolfram.com/SphericalCoordinates.html
> >
> >I can define a bounding sphere around my object, centered around (0, 0,
> >0).
> >
> >
> >a. Convert the axis-angle to a rotation matrix
> > (the OpenGL function glRotatef will be useful here)
> >
> >b. Take the XYZ point (0, 1, 0 ) and apply the rotation matrix to it.
> > Call this new point P.
> >
> >c. Determine the position of P in Spherical Coordinates.
> >
> >I now have an angle of rotation about the X-Axis (Phi) and an angl of
> >rotation about the Z-Axis (Theta) and essentially my answer.
>
> Fine. It appears you want to aim the Y axis using rotations around X
> and Z. Steps (a) and (b) are a reasonable way to start. Now you must
> decide two things: (1) Do you want to rotate first around X, or around
> Z?
Well, I want it to not matter, but clearly it does.
> (2) Do you want use (fixed) world axes or (rotating) body axes?
Fixed world axes.
I generally find it helps to see how things work themselves out when
using actual numbers and to make sure I understand the details, so I
will add some comments doing just that. Let's set theta 30 degrees and
phi to 60 degrees.
> Assume X first, world axes. Then we have the following
>
> P = [rotate by Theta around Z] [rotate by Phi around X] Y
Using the rotation matricies found at:
http://en.wikipedia.org/wiki/3D_projection
This formula then becomes:
P = [ cos(30) -sin(30) 0 0] [1 0 0 0] [0]
[ sin(30) cos(30) 0 0] [0 cos(60) -sin(60) 0] [1]
[ 0 0 1 0] [0 sin(60) cos(60) 0] [0]
[ 0 0 0 1] [0 0 0 1] [1]
P = [ cos(30) -sin(30)*cos(60) -sin(30)*-sin(60) 0][0]
[ sin(30) cos(30)*cos(60) cos(60)*-sin(60) 0][1]
[ 0 sin(60) cos(60) 0][0]
[ 0 0 0 1][1]
P = [ -sin(30)*cos(60) ] [ -0.25 ]
[ cos(30)*cos(60) ] ~= [ 0.433 ]
[ sin(60) ] [ 0.866 ]
[ 1 ] [ 1.0 ]
> Reverse this to read
>
> Y = [unrotate by Phi around X] [unrotate by Theta around Z] P
Y = [1 0 0 0][cos(-30) -sin(-30) 0 0] [-sin(30)*cos(60)]
[0 cos(-60) -sin(-60) 0][sin(-30) cos(-30) 0 0] [ cos(30)*cos(60)]
[0 sin(-60) cos(-60) 0][ 0 0 1 0] [ sin(60)]
[0 0 0 1][ 0 0 0 1] [ 1]
Y ~= [ cos(-30) -sin(-30) 0 0][ -0.25 ]
[cos(-60)*sin(-30) cos(-60)* cos(-30) -sin(-60) 0][ 0.433 ]
[sin(-60)*sin(-30) sin(-60)* cos(-30) cos(-60) 0][ 0.866 ]
[ 0 0 0 1][ 1.0 ]
Y ~= [ cos(-30)*-.25+ -sin(-30)*0.433 ]
[cos(-60)*sin(-30)*-.25+cos(-60)* cos(-30)*0.433+-sin(-60)*0.866]
[sin(-60)*sin(-30)*-.25+sin(-60)* cos(-30)*0.433+ cos(-60)*0.866]
[ 1 ]
Y = [0]
[1]
[0]
[1]
So far, so good.
> Let the components of P be (x,y,z). Let ct and st be cosine and sine
> of Theta; cp and sp, of Phi. Then we require unrotation by Theta to
> zero the x component of P:
>
> [0] [ ct st] [x]
> [r] = [-st ct] [y]
You lost me here. I am uncertain how you derived this.
> This is accomplish by letting r = sqrt(x^2+y^2), (ct,st) = (y,-x)/r,
> if r is non-zero, else by (ct,st) = (1,0).
Quickly,
r = sqrt(x^2+y^2)
I am interpreting this as the length of the vector P when projected
onto the XY plane. Is this the correct interpretation?
Assuming the above, I work it out to be:
[0] = [ x * cos(t) + y * sin(t) ]
[r] [ y * cos(t) - x * sin(t) ]
How did you get from here to:
r = sqrt(x^2+y^2),
(ct,st) = (y,-x)/r, (Is this written correctly?)
if r is non-zero, else by (ct,st) = (1,0).
> Similarly we require unrotation by Phi to zero the z component of P:
>
> [1] [ cp sp] [r]
> [0] = [-sp cp] [z]
>
> Notice the y component is already unrotated to be r. Also notice that
> r^2+z^2 should equal 1. So we take (cp,sp) = (r,z).
Same as above.
> The actual angles Phi and Theta are computed using a two-argument
> arctangent function.
I am uncertain how to get to this point.
.
- Follow-Ups:
- Re: Convert axis and angle of rotation to rotations about X & Y axis'
- From: Just d' FAQs
- Re: Convert axis and angle of rotation to rotations about X & Y axis'
- From: ericgorr
- Re: Convert axis and angle of rotation to rotations about X & Y axis'
- References:
- Convert axis and angle of rotation to rotations about X & Y axis'
- From: ericgorr
- Re: Convert axis and angle of rotation to rotations about X & Y axis'
- From: Just d' FAQs
- Convert axis and angle of rotation to rotations about X & Y axis'
- Prev by Date: Re: practical analytical modelf for daylight
- Next by Date: Re: Memory Pool / Simple Segregated Storage
- Previous by thread: Re: Convert axis and angle of rotation to rotations about X & Y axis'
- Next by thread: Re: Convert axis and angle of rotation to rotations about X & Y axis'
- Index(es):
Relevant Pages
|