TUmatrixRot TCL UTILITIES USER MANUAL TUmatrixRot
SYNOPSIS
Return a partial or full rotation matrix
PACKAGE
TCLUTILS
NAME
TUmatrixRot
USAGE
set rV  [TUmatrixInv  Phi Theta Psi RotM Fmt]
INPUT DEFINITIONS
Phi - The rotation axis rotation angle when returning rotation matrix about about a single rotation axis, otherwise the Euler rotation angle about the intial Z axis.
Theta - The Eulerian rotation angle about the new X axis.
Psi - The Eulerian rotation angle about the final Z axis.
RotM - The returned rotation matrix.
Fmt - Rotation matrix contents. All of the defined formats can have _T appended to them to return the tranpose of the defined rotation matrix as X and X_T.
X - X axis rotation matrix.
Y - Y axis rotation matrix.
Z - Z axis rotation matrix.
EULER - Eulerian rotation matrix.
RETURN DEFINITION
NONE
DESCRIPTION
TUmatrixRot returns various rotation matrices. When returning a rotation matrix about a single axis only the first input angle Phi is used otherwise all angles are used. All angles are input as degrees. The single axis rotation matrices returned by the procedure are:
X X_T
1.0 0.0 0.0
0.0 cos(&phi) sin(&phi)
0.0 -sin(&phi) cos(&phi)
1.0 0.0 0.0
0.0 cos(&phi) sin(&phi)
0.0 -sin(&phi) cos(&phi)
Y Y_T
cos(&phi) 0.0 sin(&phi)
0.0 1.0 0.0
-sin(&phi) 0.0 cos(&phi)
cos(&phi) 0.0 -sin(&phi)
0.0 1.0 0.0
sin(&phi) 0.0 cos(&phi)
Z Z_T
cos(&phi) sin(&phi) 0.0
-sin(&phi) cos(&phi) 0.0
0.0 0.0 1.0
cos(&phi) -sin(&phi) 0.0
sin(&phi) cos(&phi) 0.0
0.0 0.0 1.0
EULER
cos(&psi)cps(&phi) - cos(&theta)sin(&phi)sin(&psi) cos(&psi)sin(&phi) + cos(&theta)cos(&phi)sin(&psi) sin(&psi)sin(&theta)
-sin(&psi)cos(&phi) - cos(&theta)sin(&phi)cos(&psi) -sin(&psi)sin(&phi) + cos(&theta)cos(&phi)cos(&psi) cos(&psi)sin(&theta)
sin(&phi)sin(&theta) -cos(&phi)sin(&theta) cos(&theta)
EULER_T
cos(&psi)cps(&phi) - cos(&theta)sin(&phi)sin(&psi) -sin(&psi)cos(&phi) - cos(&theta)sin(&phi)cos(&psi) sin(&phi)sin(&theta)
cos(&psi)sin(&phi) + cos(&theta)cos(&phi)sin(&psi) -sin(&psi)sin(&phi) + cos(&theta)cos(&phi)cos(&psi) -cos(&phi)sin(&theta)
-sin(&psi)sin(&theta) -cos(&psi)sin(&theta) cos(&theta)
ERRORS
None Generated
C BACKING
No
EXAMPLE(S)
EXAMPLE 1: Establish a forward and reverse rotation matrix about Z and use to rotate a rectangle
# GENERATE the XY coordinates of a rectangle

set R(0) -5.0 ; set R(1)  -2.0 ; set R(2) 0.0
set R(3) -5.0 ; set R(4)   2.0 ; set R(5) 0.0
set R(6)  5.0 ; set R(7)   2.0 ; set R(8) 0.0
set R(9)  5.0 ; set R(10) -2.0 ; set R(11) 0.0

# PRODUCE forward rotation about Z and rotate data

TUmatrixRot 30.0 0.0 0.0 RoT Z
TUmatrixMath RoT * R Ra 3 3 3 1 0 0 0
TUmatrixMath RoT * R Ra 3 3 3 1 0 3 3
TUmatrixMath RoT * R Ra 3 3 3 1 0 6 6
TUmatrixMath RoT * R Ra 3 3 3 1 0 9 9

# PRODUCE reverse rotation about Z and rotate data

TUmatrixRot 30.0 0.0 0.0 RoT Z_T
TUmatrixMath RoT * R Rb 3 3 3 1 0 0 0
TUmatrixMath RoT * R Rb 3 3 3 1 0 3 3
TUmatrixMath RoT * R Rb 3 3 3 1 0 6 6
TUmatrixMath RoT * R Rb 3 3 3 1 0 9 9

# SET up graphics

GraphicsOn TK ETones
GenWindow 1 0.0 0.0 0.0 1.0 1.0 0.0 -8.0 -8.0 0.0 8.0 8.0 0.0

# ORIGINAL rectangle in white

PlotColor HOLD $GphInfo(White) OFF
Line 1 $R(0) $R(1)  $R(2)  $R(3)  $R(4)  $R(5)
Line 1 $R(3) $R(4)  $R(5)  $R(6)  $R(7)  $R(8)
Line 1 $R(6) $R(7)  $R(8)  $R(9)  $R(10) $R(11)
Line 1 $R(9) $R(10) $R(11) $R(0)  $R(1)  $R(2)

# FORWARD rotated rectangle in red

PlotColor HOLD $GphInfo(Red) OFF
Line 1 $Ra(0) $Ra(1)  $Ra(2)  $Ra(3)  $Ra(4)  $Ra(5)
Line 1 $Ra(3) $Ra(4)  $Ra(5)  $Ra(6)  $Ra(7)  $Ra(8)
Line 1 $Ra(6) $Ra(7)  $Ra(8)  $Ra(9)  $Ra(10) $Ra(11)
Line 1 $Ra(9) $Ra(10) $Ra(11) $Ra(0)  $Ra(1)  $Ra(2)

# REVERSE rotated rectangle in green

PlotColor HOLD $GphInfo(Green) OFF
Line 1 $Rb(0) $Rb(1)  $Rb(2)  $Rb(3)  $Rb(4)  $Rb(5)
Line 1 $Rb(3) $Rb(4)  $Rb(5)  $Rb(6)  $Rb(7)  $Rb(8)
Line 1 $Rb(6) $Rb(7)  $Rb(8)  $Rb(9)  $Rb(10) $Rb(11)
Line 1 $Rb(9) $Rb(10) $Rb(11) $Rb(0)  $Rb(1)  $Rb(2)

# A few labels

TexT 1 0.0 7.00 0.0 center "ORIGINAL UNROTATED" $GphInfo(White)
TexT 1 0.0 6.25 0.0 center "FORWARD UNROTATED" $GphInfo(Red)
TexT 1 0.0 5.50 0.0 center "REVERSE UNROTATED" $GphInfo(Green)
update
      
Sept 8, 2003