Vector rotation: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>David E. Volk
m (subpages)
mNo edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{subpages}}
{{subpages}}
'''Vector rotations''' are widely used not only in the sciences, such as [[physics]], [[chemistry]] and [[mathematics]], but are critical for graphics computations in [[computer game]] programs and navigation in space.  A typical example used in computer games would be calculating the graphics for a military tank rolling up a slanted hill, the relative rotation of the tank's turret, and the elevation of the tanks' barrel.  Although a rotation matrix for each point of the tank ''could'' be calculated individually, a more economical method is to calculate a single rotation matrix for the entire tank and apply that solution to every current position of the tank as it rolls up the hill.  Additional rotations are then used for the turret rotation by a second multiplication.
'''Vector rotations''' are widely used not only in the sciences, such as [[physics]], [[chemistry]] and [[mathematics]], but are critical for graphics computations in [[video game]] programs and navigation in space.  A typical example used in computer games would be calculating the graphics for a military tank rolling up a slanted hill, the relative rotation of the tank's turret, and the elevation of the tanks' barrel.  Although a rotation matrix for each point of the tank ''could'' be calculated individually, a more economical method is to calculate a single rotation matrix for the entire tank and apply that solution to every current position of the tank as it rolls up the hill.  Additional rotations are then used for the turret rotation by a second multiplication.


== Methods ==
== Methods ==
A variety of methods can be used to determine the rotation matrix (in 3D or 4D space) needed to convert vector V<sub>1</sub> into vector V<sub>2</sub>. Because they provide non-unique results, inverse trigonometry functions should only be used with great caution.  [[Quaternions]], a 4-dimensional approach in 3D space, can also be used, and this method has devoted followers and critics. Although several 3D matrix rotation methods can be used, the method of Hughes (J. Graphics Tools, 2000) is particularly fast, because it avoids time-consuming inverse trigonometry and square root calculations, and avoids computational pitfalls of instability inherent to some of the previous methods.
A variety of methods can be used to determine the rotation matrix (in 3D or 4D space) needed to convert vector V<sub>1</sub> into vector V<sub>2</sub>, see [[rotation matrix]] and [[Euler angles]] for two alternative methods.   Because they may lead to non-unique results, inverse trigonometry functions, such as [[arctan]], should only be used with great caution.  [[Quaternions]], a 4-dimensional approach in 3D space, can also be used, and this method has devoted followers and critics. Although several 3D matrix rotation methods can be used, the method of Hughes (J. Graphics Tools, 2000) is particularly fast, because it avoids time-consuming inverse trigonometry and square root calculations, and avoids computational pitfalls of instability inherent to some of the previous methods.  


=== Hughes' method ===
=== Method of Möller and Hughes ===
The sum of two reflections is a rotation, and the Hughes method relies on this fact, using the reflections defined by the [[Householder matrix]] to construct a rotation
The product of two [[reflection]]s is a rotation, and the Möller-Hughes method relies on this well-known fact, using the reflections defined by the [[Householder matrix]] to construct a rotation
matrix by summing two reflections about either the X, Y or Z-axis, using the axis most orthogonal to the starting vector. Is is important to note that this method only works for [[unit vector|unit vectors]], so translation and scaling may be required before performing the vector rotation.
matrix by multiplying two reflections about either the X, Y or Z-axis, using the axis most orthogonal to the starting vector. It is important to note that this method only works for [[unit vector|unit vectors]], so translation and scaling may be required before performing the vector rotation.


Take arbitrary starting unit vector V<sub>1</sub> and desired final unit vector V<sub>2</sub> defined as:
When the unit vector V<sub>1</sub> and desired final unit direction vector V<sub>2</sub> defined as:


:<math> V_1 = (V_{1x} , V_{1y} , V_{1z})</math>
:<math> \, V_1 = (V_{1x} , V_{1y} , V_{1z})</math>
:<math>  V_2 = (V_{2x} , V_{2y} , V_{2z})</math>
:<math>\, V_2 = (V_{2x} , V_{2y} , V_{2z})</math>


Choose the reflection vector P as the unit vector most orthogonal to V<sub>1</sub> in the following manner:
are almost parallel then we choose the reflection vector P as the unit vector most orthogonal to V<sub>1</sub> in the following manner:
 
:<math> P = (1,0,0) if |V_{1x}| < |V_{1y}| and |V_{1x}| < |V_{1z}| </math>
:<math> P = (0,1,0) if |V_{1y}| < |V_{1x}| and |V_{1y}| < |V_{1z}| </math>
:<math> P = (0,0,1) if |V_{1z}| < |V_{1y}| and |V_{1z}| < |V_{1y}| </math>


:<math> P = (1,0,0) \quad\hbox{if}\quad  |V_{1x}| < |V_{1y}| \quad\hbox{and}\quad  |V_{1x}| < |V_{1z}| </math>
:<math> P = (0,1,0) \quad\hbox{if}\quad  |V_{1y}| < |V_{1x}| \quad\hbox{and}\quad  |V_{1y}| < |V_{1z}| </math>
:<math> P = (0,0,1) \quad\hbox{if}\quad  |V_{1z}| < |V_{1y}| \quad\hbox{and}\quad  |V_{1z}| < |V_{1x}| </math>
Define two new vectors '''u''' and '''v''':
Define two new vectors '''u''' and '''v''':


Line 28: Line 27:
Then the elements <math>(r_{ij})</math> of the rotation matrix '''R'''  which rotates V<sub>1</sub> into V<sub>2</sub> (that is '''R'''(V<sub>1</sub>) = V<sub>2</sub>) can be calculated simply by multiplication and [[dot product|dot products]], without using either inverse trigonometry or square roots, as:
Then the elements <math>(r_{ij})</math> of the rotation matrix '''R'''  which rotates V<sub>1</sub> into V<sub>2</sub> (that is '''R'''(V<sub>1</sub>) = V<sub>2</sub>) can be calculated simply by multiplication and [[dot product|dot products]], without using either inverse trigonometry or square roots, as:


:<math> r_{ij} = \delta_{ij} - \frac{2 u_i u_j}{\mathbf u \cdot \mathbf u} - \frac{2 v_i v_j}{\mathbf v \cdot \mathbf v} + \frac{4 \mathbf u \cdot \mathbf v}{(\mathbf u \cdot \mathbf u)(\mathbf v \cdot \mathbf v)}</math>
:<math> r_{ij} = \delta_{ij} - \frac{2 u_i u_j}{\mathbf u \cdot \mathbf u} - \frac{2 v_i v_j}{\mathbf v \cdot \mathbf v} + \frac{4 \mathbf u \cdot \mathbf v}{(\mathbf u \cdot \mathbf u)(\mathbf v \cdot \mathbf v)} v_i\, u_j</math>


:::where <math> \delta_{ij}</math> = 1 if i=j,  otherwise <math>\delta_{ij}</math> = 0
:::where <math> \delta_{ij}</math> = 1 if i=j,  otherwise <math>\delta_{ij}</math> = 0
=== Product operator formalism ===
In [[NMR spectroscopy]], [[magnetic resonance imaging]] and related sciences, a simplified form of vector rotation, the [[Product operator (NMR)|product operator formalism]], can be used because all vectors are unit vectors starting from the origin (0,0,0).  This formalism is a simplied form of matrix rotation.


== References ==
== References ==
Tomas Moller and John F. Hughes, J. Graphics Tools, '''4'''(4):1-4, 2000.
Tomas Möller and John F. Hughes, J. Graphics Tools, '''4'''(4):1-4, 1999.
 
[[Category:Suggestion Bot Tag]]

Latest revision as of 12:01, 4 November 2024

This article is developing and not approved.
Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
External Links  [?]
Citable Version  [?]
 
This editable Main Article is under development and subject to a disclaimer.

Vector rotations are widely used not only in the sciences, such as physics, chemistry and mathematics, but are critical for graphics computations in video game programs and navigation in space. A typical example used in computer games would be calculating the graphics for a military tank rolling up a slanted hill, the relative rotation of the tank's turret, and the elevation of the tanks' barrel. Although a rotation matrix for each point of the tank could be calculated individually, a more economical method is to calculate a single rotation matrix for the entire tank and apply that solution to every current position of the tank as it rolls up the hill. Additional rotations are then used for the turret rotation by a second multiplication.

Methods

A variety of methods can be used to determine the rotation matrix (in 3D or 4D space) needed to convert vector V1 into vector V2, see rotation matrix and Euler angles for two alternative methods. Because they may lead to non-unique results, inverse trigonometry functions, such as arctan, should only be used with great caution. Quaternions, a 4-dimensional approach in 3D space, can also be used, and this method has devoted followers and critics. Although several 3D matrix rotation methods can be used, the method of Hughes (J. Graphics Tools, 2000) is particularly fast, because it avoids time-consuming inverse trigonometry and square root calculations, and avoids computational pitfalls of instability inherent to some of the previous methods.

Method of Möller and Hughes

The product of two reflections is a rotation, and the Möller-Hughes method relies on this well-known fact, using the reflections defined by the Householder matrix to construct a rotation matrix by multiplying two reflections about either the X, Y or Z-axis, using the axis most orthogonal to the starting vector. It is important to note that this method only works for unit vectors, so translation and scaling may be required before performing the vector rotation.

When the unit vector V1 and desired final unit direction vector V2 defined as:

are almost parallel then we choose the reflection vector P as the unit vector most orthogonal to V1 in the following manner:

Define two new vectors u and v:

= P -
= P -

Then the elements of the rotation matrix R which rotates V1 into V2 (that is R(V1) = V2) can be calculated simply by multiplication and dot products, without using either inverse trigonometry or square roots, as:

where = 1 if i=j, otherwise = 0

Product operator formalism

In NMR spectroscopy, magnetic resonance imaging and related sciences, a simplified form of vector rotation, the product operator formalism, can be used because all vectors are unit vectors starting from the origin (0,0,0). This formalism is a simplied form of matrix rotation.

References

Tomas Möller and John F. Hughes, J. Graphics Tools, 4(4):1-4, 1999.