## Thursday, April 23, 2015

### HP Prime and TI-84+: Rotation and Translation of the 3-D Vector

HP Prime and TI-84+:  Rotation and Translation of the 3-D Vector

Greetings from Monterey, California!

 Greetings from Cal State Monterey Bay

 Deep Sea Tank:  Monterey Bay Aquarium

Let P be a three dimensional column vector P = [[ x ],[ y ],[ z ]].

We can move P by a linear transformation by addition to get a new vector P’:

P’ = P + T where T = [[ t1 ],[ t2 ],[ t3 ]].

We can rotate point P by using one of three rotation matrices using left-multiplication:

P’ = RP  where R can take the form:

Rx = [[ 1, 0, 0 ],[ 0, cos θ, -sin θ ],[ 0, sin θ, cos θ ]]

Ry = [[ cos θ, 0, -sin θ ],[ 0, 1, 0 ],[ sin θ, 0, cos θ ]]

Rz = [[ cos θ, -sin θ, 0 ],[ sin θ, cos θ, 0 ],[ 0, 0, 1 ]]

We can take all three rotation matrices into account to get:

P’ = Rx Ry Rz P

Adding a linear translation and we arrive at:

P’ = Rx Ry Rz P + T

HP Prime:  ROTTRAN3(m,a,b,c,t)

Input:
m = a 3 x 1 column matrix which represents P
a = rotation angle for the x-axis
b = rotation angle for the y-axis
c = rotation angle for the z-axis
t = a 3 x 1 column matrix for linear transformation

Output:  3 x 1 column matrix which represents P’

Program:

EXPORT ROTTRAN3(m,a,b,c,t)
BEGIN
LOCAL x,y,z,n;

x:=[[1,0,0],[0,COS(a),−SIN(a)],
[0,SIN(a),COS(a)]];
y:=[[COS(b),0,−SIN(b)],[0,1,0],
[SIN(b),0,COS(b)]];
z:=[[COS(c),−SIN(c),0],
[SIN(c),COS(c),0],[0,0,1]];
n:=x*y*z*m+t;
RETURN n;

END;

TI-84 Plus:  ROTTRAN3

Original Point:  <X, Y, Z>
Angles for Rx (A), Ry (B), and Rz (C)
Translation Point:  <S, T, U>

Program:
: Disp “X,Y,Z:”
: Prompt X,Y,Z
: Disp “ANGELS OF X,Y,Z:”
: Prompt A,B,C
: Disp “LINEAR SHIFT:”
: Prompt S,T,U
: [[1,0,0][0,cos(A),-sin(A)
][0,sin(A),cos(A)]]*[[cos(
B),0,-sin(B)][0,1,0][sin(B
),0,cos(B)]]*[[cos(C),-sin
(C),0][sin(C),cos(C),0][0,
0,1]]*[[X][Y][Z]]->[J]
: [J]+[[S][T][U]]->[J]
: Disp [J]

Example:

P = [[1][2][3]]
Rotate angles (radians):  x: 0, y: 0.25, z: 0.15
T = [[0][0][1]]

P’ =
[[ -0.073764223786 ]
[ 2.12698028835 ]
[ 4.07741997334 ]]

Source:
Lengyel, Eric.  “Mathematics for 3D Game Programming & Computer Graphics” 2nd Edition.  Charles River Media, Inc.  Hingham, MA  2004

This program is property of Edward Shore.  2015.