Re: Convert axis and angle of rotation to rotations about X & Y axis'
- From: Just d' FAQs <nobody-here@xxxxxxx>
- Date: Thu, 15 Dec 2005 00:17:32 -0600
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 angle 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? (2) Do you want use (fixed) world axes or (rotating) body axes?
Assume X first, world axes. Then we have the following
P = [rotate by Theta around Z] [rotate by Phi around X] Y
Reverse this to read
Y = [unrotate by Phi around X] [unrotate by Theta around Z] P
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]
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).
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).
The actual angles Phi and Theta are computed using a two-argument
arctangent function.
.
- Follow-Ups:
- References:
- Prev by Date: Re: Memory Pool / Simple Segregated Storage
- Next by Date: practical analytical modelf for daylight
- Previous by thread: 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
|