Converting a Vector to a Transformation MatrixDate: 03/19/98 at 03:24:36 From: Harvey Subject: Vector-angle to Matrix If I have an arbitrary vector and an angle of rotation around that vector, how can I convert that to a transformation matrix for a left- handed coordinate system? Is there an easy/fast way? Date: 03/19/98 at 14:34:30 From: Doctor Rob Subject: Re: Vector-angle to Matrix I would rotate the system of coordinates to make the z-axis the vector of interest. Then I would convert to cylindrical coordinates, add the angle in question to theta, convert back to rectangular coordinates, and rotate back to the original coordinate system. Let the vector be a = (a1,a2,a3) and the angle be alpha. Then let u be the unit vector in the direction of a, so that: u = (u1,u2,u3) = a/sqrt(a1^2 + a2^2 + a3^2). Then let v be a unit vector perpendicular to u, such as: v = (-a2,a1,0)/sqrt(a1^2+a2^2), and w be a unit vector perpendicular to both, such as: w = u X v (cross-product of u and v). Then, to translate into the (u,v,w) coordinate system, [u] [u1 u2 u3][x] [x] [v] = [v1 v2 v3][y] = U [y] [w] [w1 w2 w3][z] [z]. Now: theta = arctan(w/v), r = sqrt[u^2 + v^2], v = r*cos(theta), w = r*sin(theta). Now replace theta by theta - alpha to do the rotation. u' = u, r' = r, theta' = theta - alpha. Expand the sine and cosine using the addition formulas. u' = u, v' = r'*cos(theta'), = r*cos(theta - alpha), = r*cos(theta)*cos(alpha) + r*sin(theta)*sin(alpha), = cos(alpha)*v + sin(alpha)*w. w' = r'*sin(theta'), = r*sin(theta - alpha), = -r*cos(theta)*sin(alpha) + r*sin(theta)*cos(alpha), = -sin(alpha)*v + cos(alpha)*w. [u'] [1 0 0 ][u] [v'] = [0 cos(alpha) sin(alpha)][v], [w'] [0 -sin(alpha) cos(alpha)][w] [u] = R [v] [w]. Now: [x'] [u'] [y'] = U^(-1) [v'], [z'] [w'] [u] = U^(-1) R [v], [w] [x] = U^(-1) R U [y]. [z] This means that the rotation matrix is given by U^(-1) R U, where U and R are defined above. Is this a simple way? That's a matter of opinion. -Doctor Rob, The Math Forum Check out our web site! http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994- The Math Forum at NCTM. All rights reserved.
http://mathforum.org/dr.math/