Rotation About an Arbitrary Axis in 3 Dimensions Glenn Murray June 6, 2013

1

Introduction

The problem of rotation about an arbitrary axis in three dimensions arises in many fields including computer graphics and molecular simulation. In this article we give an algorithm and matrices for doing the movement. Many of the results were initially obtained with Mathematica. An algorithm (See Figure 1):

Figure 1: Moving the axis of rotation A to the z-axis.

(1) Translate space so that the rotation axis passes through the origin. 1

(2) Rotate space about the z axis so that the rotation axis lies in the xz plane. (3) Rotate space about the y axis so that the rotation axis lies along the z axis. (4) Perform the desired rotation by θ about the z axis. (5) Apply the inverse of step (3). (6) Apply the inverse of step (2). (7) Apply the inverse of step (1). We will write our three-dimensional points in four homogeneous coordinates; i.e., (x, y, z) will be written as (x, y, z, 1). This enables us to do coordinate transformations using 4x4 matrices. Note that these are really only necessary for translations, if we omitted translations from our movements we could do the motions with 3x3 rotation matrices obtained by deleting the last rows and last columns of the 4x4 matrices. In this article vectors are multiplied by matrices on the vector’s left.

2

A translation matrix

The product TP1 ·v is equivalent to the vector sum h−a, −b, −c, 0i+v, i.e., this transformation moves the point P1 (a, b, c) to the origin.   1 0 0 −a 0 1 0 −b   TP1 =  0 0 1 −c  0 0 0 1   1 0 0 −a 0 1 0 −b   TP1 =  0 0 1 −c  0 0 0 1

3

3D Coordinate axes rotation matrices

Here are the matrices for rotation by α around the x-axis, β around the y-axis, and γ around the z-axis.   1 0 0 0  0 cos α − sin α 0   Rx (α) =   0 sin α cos α 0  0 0 0 1   cos β 0 sin β 0  0 1 0 0   Ry (β) =   − sin β 0 cos β 0  0 0 0 1

2



cos γ − sin γ  sin γ cos γ Rz (γ) =   0 0 0 0

0 0 1 0

 0 0   0  1

The general rotation matrix depends on the order of rotations. The first matrix rotates about x, then y, then z; the second rotates about z, then y, then x. 

 0 0   0  1



 0 0   0  1

cos β cos γ cos γ sin α sin β − cos α sin γ cos α cos γ sin β + sin α sin γ  cos β sin γ cos α cos γ + sin α sin β sin γ − cos γ sin α + cos α sin β sin γ Rz Ry Rx =   − sin β cos β sin α cos α cos β 0 0 0 cos β cos γ − cos β sin γ sin β  cos α sin γ + sin α sin β cos γ cos α cos γ − sin α sin β sin γ − sin α cos β Rx Ry Rz =   sin α sin γ − cos α sin β cos γ sin α cos γ + cos α sin β sin γ cos α cos β 0 0 0

4

Transformations for rotating a vector to the z -axis

In this section we introduce matrices to move a rotation vector hu, v, wi to the z-axis. Note that we use the components to form expressions for the cosines and sines to avoid using inverse trigonometric functions. We require that the rotation vector not be parallel to the z-axis, else u = v = 0 and the denominators vanish.

4.1

The matrix to rotate a vector about the z -axis to the xz -plane √ √ u √u2 + v 2 v √u2 + v 2  −v u2 + v 2 u u2 + v 2 =  0 0 0 0 

Txz

4.2

 0 0   0  1

The matrix to rotate the vector in the xz -plane to the z -axis 

√

u2 + v 2 + w 2  √ √0 Tz =   u2 + v 2 u2 + v 2 + w2 0

5

0 0 1 0

w

√ √ 0 − u2 + v 2 u2 + v 2 + w2 1 √ 0 0 w u2 + v 2 + w2 0 0

 0 0   0  1

Rotations about the origin

In this section we rotate the point (x, y, z) about the vector hu, v, wi by the angle θ. 3

5.1

The matrix for rotations about the origin

−1 −1 This is the product Txz Tz Rz (θ)Tz Txz .

        

u2 +(v 2 +w2 ) cos θ u2 +v 2 +w2 √ uv(1−cos θ)+w u2 +v 2 +w2 sin θ u2 +v 2 +w2 √ uw(1−cos θ)−v u2 +v 2 +w2 sin θ u2 +v 2 +w2

0

√ uv(1−cos θ)−w u2 +v 2 +w2 sin θ u2 +v 2 +w2 2

2

2

v +(u +w ) cos θ u2 +v 2 +w2 √ vw(1−cos θ)+u u2 +v 2 +w2 sin θ u2 +v 2 +w2

0

√ uw(1−cos θ)+v u2 +v 2 +w2 sin θ u2 +v 2 +w2 √ vw(1−cos θ)−u u2 +v 2 +w2 sin θ u2 +v 2 +w2 w2 +(u2 +v 2 ) cos θ u2 +v 2 +w2

0

0

  0    0  1

If we multiply this times hx, y, zi we can obtain a function of of seven variables that yields the result of rotating the point (x, y, z) about the axis hu, v, wi by the angle θ. f (x, y, z, u, v, w, θ) =

     

5.2

√ u(ux+vy+wz)(1−cos θ)+(u2 +v 2 +w2 )x cos θ+ u2 +v 2 +w2 (−wy+vz) sin θ u2 +v 2 +w2 √ v(ux+vy+wz)(1−cos θ)+(u2 +v 2 +w2 )y cos θ+ u2 +v 2 +w2 (wx−uz) sin θ u2 +v 2 +w2 √ w(ux+vy+wz)(1−cos θ)+(u2 +v 2 +w2 )z cos θ+ u2 +v 2 +w2 (−vx+uy) sin θ u2 +v 2 +w2

     

The normalized matrix for rotations about the origin

At this point we would like to simplify the expressions by making the assumption that hu, v, wi is a unit vector; i.e., that u2 + v 2 + w2 = 1. With this simplification, we obtain the −1 −1 following expression for Txz Tz Rz (θ)Tz Txz .   2 u + (1 − u2 ) cos θ uv(1 − cos θ) − w sin θ uw(1 − cos θ) + v sin θ 0    uv(1 − cos θ) + w sin θ 2 2 v + (1 − v ) cos θ vw(1 − cos θ) − u sin θ 0       2 2 uw(1 − cos θ) − v sin θ vw(1 − cos θ) + u sin θ w + (1 − w ) cos θ 0   0 0 0 1 If we multiply this times hx, y, zi we can obtain a function of of seven variables that yields the result of rotating the point (x, y, z) about the axis hu, v, wi (where u2 + v 2 + w2 = 1) by the angle θ. 4



f (x, y, z, u, v, w, θ) =   u(ux + vy + wz)(1 − cos θ) + x cos θ + (−wy + vz) sin θ      v(ux + vy + wz)(1 − cos θ) + y cos θ + (wx − uz) sin θ    w(ux + vy + wz)(1 − cos θ) + z cos θ + (−vx + uy) sin θ

6

Rotation about an arbitrary line

We will define an arbitrary line by a point the line goes through and a direction vector. If the axis of rotation is given by two points P1 = (a, b, c) and P2 = (d, e, f ), then a direction vector can be obtained by hu, v, wi = hd − a, e − b, f − ci. We can now write a transformation for the rotation of a point about this line.

6.1

The matrix for rotation about an arbitrary line

−1 −1 This is given by the product TP−1 Tz Rz (θ)Tz Txz TP1 . In hopes of fitting the matrix onto Txz 1 the page we make the substitution L = u2 + v 2 + w2 .



u2 +(v 2 +w2 ) cos θ L

   √ uv(1−cos θ)+w L sin θ  L   uw(1−cos θ)−v√L sin θ  L  0

√ uv(1−cos θ)−w L sin θ L

√ uw(1−cos θ)+v L sin θ L

  √ a(v 2 +w2 )−u(bv+cw) (1−cos θ)+(bw−cv) L sin θ

v 2 +(u2 +w2 ) cos θ L

√ vw(1−cos θ)−u L sin θ L

√  b(u2 +w2 )−v(au+cw) (1−cos θ)+(cu−aw) L sin θ 

√ vw(1−cos θ)+u L sin θ L

w2 +(u2 +v 2 ) cos θ L

0

0

L



L

   √ (1−cos θ)+(av−bu) L sin θ   L 



c(u2 +v 2 )−w(au+bv)

1

If we multiply this times hx, y, zi we can obtain a function of of ten variables that yields the result of rotating the point (x, y, z) about the line through (a, b, c) with direction vector hu, v, wi by the angle θ. f (x, y, z, a, b, c, u, v, w, θ) =

      

  √ a(v 2 +w2 )−u(bv+cw−ux−vy−wz) (1−cos θ)+Lx cos θ+ L(−cv+bw−wy+vz) sin θ L    √ 2 2 b(u +w )−v(au+cw−ux−vy−wz) (1−cos θ)+Ly cos θ+ L(cu−aw+wx−uz) sin θ    L   √ 2 2 c(u +v )−w(au+bv−ux−vy−wz) (1−cos θ)+Lz cos θ+ L(−bu+av−vx+uy) sin θ L 5

 

6.2

The normalized matrix for rotation about an arbitrary line

Assuming that hu, v, wi is a unit vector so that L = 1, we obtain a more practical result for −1 −1 Tz Rz (θ)Tz Txz TP1 . TP−1 Txz 1 u2 + (v 2 + w2 ) cos θ

uv(1 − cos θ) − w sin θ

uw(1 − cos θ) + v sin θ

  uv(1 − cos θ) + w sin θ   uw(1 − cos θ) − v sin θ   0

v 2 + (u2 + w2 ) cos θ

vw(1 − cos θ) − u sin θ

vw(1 − cos θ) + u sin θ

w2 + (u2 + v 2 ) cos θ

0

0



  a(v 2 + w2 ) − u(bv + cw) (1 − cos θ) + (bw − cv) sin θ    b(u2 + w2 ) − v(au + cw) (1 − cos θ) + (cu − aw) sin θ    c(u2 + v 2 ) − w(au + bv) (1 − cos θ) + (av − bu) sin θ    1

If we multiply this times hx, y, zi we can obtain a function of of ten variables that yields the result of rotating the point (x, y, z) about the line through (a, b, c) with direction vector hu, v, wi (where u2 + v 2 + w2 = 1) by the angle θ. f (x, y, z, a, b, c, u, v, w, θ) =    a(v 2 + w2 ) − u(bv + cw − ux − vy − wz) (1 − cos θ) + x cos θ + (−cv + bw − wy + vz) sin θ      2 2 b(u + w ) − v(au + cw − ux − vy − wz) (1 − cos θ) + y cos θ + (cu − aw + wx − uz) sin θ      2 2 c(u + v ) − w(au + bv − ux − vy − wz) (1 − cos θ) + z cos θ + (−bu + av − vx + uy) sin θ

7

Code and visualization

A graphic visualization of rotating a point about a line can be found at http://twist-and-shout. appspot.com/. Tested Java code for the matrices and formulas, released under the Apache license, is at https://sites.google.com/site/glennmurray/Home/rotation-matrices-and-formulas.

6

Rotation About an Arbitrary Axis in 3 Dimensions

Jun 6, 2013 - including computer graphics and molecular simulation. ..... Java code for the matrices and formulas, released under the Apache license, is at.

166KB Sizes 1 Downloads 146 Views

Recommend Documents

Superstrings in arbitrary dimensions
Apr 4, 1991 - sonic systems and it is natural to extend it to the su- persymmetric case [ 5 ]. This is most easily done using superfields. In this lctter I shall show ...

Motor Imagery in Mental Rotation: An fMRI Study - ScienceDirect.com
ferent sorts of stimulus pairs, viz. pictures of hands and pictures of tools, which ... aging data replicate classic areas of activation in men- tal rotation for hands and ...

Two-way interaction in 3 dimensions with Sparse ...
Smoothed Particle Hydrodynamics is a mesh-free La- grangian fluid .... the boundary of the domain, virtual particles are placed ..... 100 simulation steps. Fig.

Cheap In Stock Zhiyun Smooth 3 Smooth Iii 3 Axis Brushless ...
Cheap In Stock Zhiyun Smooth 3 Smooth Iii 3 Axis Bru ... Plus 6 5S Samsung S7 6 5 4 Huawei Free Shipping.pdf. Cheap In Stock Zhiyun Smooth 3 Smooth Iii 3 ...

The multiple dimensions of male social status in an ... - CiteSeerX
the sale of community lumber or participation in government or NGO-sponsored development projects. Influence ... Tsimane entrepreneurs operate small businesses where they purchase goods in San Borja and then resell them ...... Seattle: University of

rotation in rainfed Vertisol
organic manure to cotton and their residual effect on sorghum grown after cotton ... mean gross income (Rs.14119 ha1) with a cotton yield equivalent of 949 kg ...

in various dimensions
May 7, 1990 - 3kf d4x E~i~VP~Eapya ... (4.2c). Here ë'~and ~ab are the quantum fluctuations and D0 is the covariant ... (4.2c) using the background (4.6):.

Cheap Beholder Ec1 32Bit 3-Axis Handheld Stabilizer 360 Endless ...
Cheap Beholder Ec1 32Bit 3-Axis Handheld Stabilizer ... 5D-7D Mirrorless & Dslr Cameras Vs Free Shipping.pdf. Cheap Beholder Ec1 32Bit 3-Axis Handheld Stabilizer 3 ... -5D-7D Mirrorless & Dslr Cameras Vs Free Shipping.pdf. Open. Extract. Open with. S

MMA7660FC, 3-Axis Orientation/Motion Detection Sensor - MicroPython
Laptop PC: Anti-Theft. • Gaming: Motion Detection ... 10 LEAD. DFN. CASE 2002-03. MMA7660FC. MMA7660FC: XYZ-AXIS. ACCELEROMETER. ±1.5 g.

Silverlake Axis
May 7, 2014 - o-y basis) in software & hardware sales, which although commanded a lower ... projects. There has not been much visibility on big order wins.

An algorithm for transferring 2D arbitrary hp-refined ...
Department of Computer Science, AGH University of Science and .... p refinement of 2D element top edge translates into p refinement of 3D top face in. 3D local ...

An FPGA Implementation of 8-Channel Arbitrary Waveform ... - IJRIT
IJRIT International Journal of Research in Information Technology, Volume 2, Issue 6, .... is basically a scaled down version of SONAR in the ocean, although, of course, there ... evaluated and the best one meeting the requirements is selected.

Cheap Aibird Uoplay⁄Uoplay 2 3-Axis Handheld Universal ...
Cheap Aibird Uoplay⁄Uoplay 2 3-Axis Handheld Univers ... tc For Gopro 3 4 Free Shipping & Wholesale Price.pdf. Cheap Aibird Uoplay⁄Uoplay 2 3-Axis ...

Mechanistic Force Model of an Arbitrary Drill Geometry
May 4, 2009 - Drilling is a machining process used to make a straight hole in wood, metal, ceramic and a variety of other materials. Commonly the process is performed by using a twist drill bit. The flutes are responsible for transferring material fr

Finitely Forcible Graphons with an Almost Arbitrary ...
My sincere gratitude goes to the Leverhulme Trust 2014 Philip Leverhulme. Prize of Daniel Král', which generously provided ... Jordan Venters for their company and support. I would also like to express gratitude .... family of sets, we use ⋃F to d

Silverlake Axis
May 7, 2014 - RM200m from the Malaysian bank could propel SILV but there has not been .... compliance with any applicable U.S. laws and regulations.

Finitely forcible graphons with an almost arbitrary ...
Nov 24, 2017 - Overview. Limits of dense graphs: |E| = Ω(|V|2). Developed by Borgs, Chayes, Lovász, Sós, Szegedy, Vesztergombi,... Applications in extremal combinatorics, computer science, property testing,... Jakub Sosnovec. Finitely forcible gra

Finitely forcible graphons with an almost arbitrary ...
Mar 16, 2018 - Page 5 .... d(Hi ,W ) = d(Hi ,W)∀i = 1,...,m =⇒ W weakly isomorphic to W. Jakub Sosnovec. Finitely forcible graphons with an ... minimizes min. W k. ∑ i=1 αi d(Hi ,W). Theorem (Grzesik, Král', Lovász Jr., 2017): This is FALSE.

An FPGA Implementation of 8-Channel Arbitrary Waveform ... - IJRIT
IJRIT International Journal of Research in Information Technology, Volume 2, Issue 6, ... does not fit the requirements of flexibility, data access, programmability, ... is basically a scaled down version of SONAR in the ocean, although, of course, .

Information about CFA level 3 exams & modules & Changes in ... - AFTC
39.2. Execution. Of Portfolio. Decisions. (cont.) h. VWAP vs. Implementation shortfall i. Econometric models j. Major trader types k. Trading tactics l. Algorithmic ...