3D Transformation-Edited - Compatibility Mode

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

11/19/2021

Hanoi University of Science and Technology

Industrial Robot

PhD. Le Duc Do
Email: do.leduc@hust.edu.vn

Three Dimensional
(3D) Modeling
Transformations

Three Dimensional Modeling


Transformations

 Methods for object modeling


transformation in three dimensions
are extended from two dimensional
methods by including consideration
for the z coordinate.

1
11/19/2021

Three Dimensional Modeling


Transformations

 Generalize from 2D by including z coordinate

 Straightforward for translation and scale, rotation


more difficult

 Homogeneous coordinates: 4 components

 Transformation matrices: 4×4 elements

3D Point
 We will consider points as column vectors.
Thus, a typical point with coordinates (x, y, z)
is represented as:

 x
 y
 
 z 

3D Point Homogenous Coordinate

 A 3D point P is represented in
homogeneous coordinates by a 4-dim.
Vect: x
 
 y
P 
z
 
1 
6

2
11/19/2021

3D Point Homogenous Coordinate

 We don't lose anything


 x
 The main advantage: it is easier to  y
compose translation and rotation  
z
 Everything is matrix multiplication  
1

3D Coordinate Systems
 Right Hand  Left Hand coordinate
coordinate system: system:

3D Transformation
 In homogeneous coordinates, 3D
transformations are represented by 4×4
matrixes:
a b c t
x

d e f t
 y

g h i t
z
 
0 0 0 1

3
11/19/2021

3D Translation

10

3D Translation
 P is translated to P' by:
 x  1 0 0 t x   x
 y  0 1 0 t y   y 
  
 z   0 0 1 tz   z
     
 1  0 0 0 1  1 

P  T  P

11

3D Translation
 An object is translated in 3D dimensional by
transforming each of the defining points of the
objects .

12

4
11/19/2021

3D Translation
 An Object represented as a set of polygon surfaces, is translated
by translate each vertex of each surface and redraw the polygon
facets in the new position.

x ' , y ' , z '


T  t x , t y , t z 
x , y , z 

 Inverse Translation:
1
T (t , t , t )  T (t ,t ,t )
x y z x y z

13

3D Translation
Example1: U is the vector represents a point in space to translational
movement:
u  x y z 
T

and p is the vector indicating the direction and length to be shifted: 


p  px p y pz 
T

v is the point vector coordinates in space has been translated to:


v  Tp  p x p y p z .u

Apply: u  2 3 2 T p  4  3 7 T Find v =?:

| 14 |

14

3D Translation
Example1: U is the vector represents a point in space to translational
movement:
u  x y z T
and p is the vector indicating the direction and length to be shifted: 
p  px p y pz 
T

v is the point vector coordinates in space has been translated to:


v  Tp  p x p y p z .u

Apply: u  2 3 2 T p  4  3 7 T Find v =?:

Ans:
1 0 0 4   2  6
0 1 0  3  3 0
v  Tp  p x p y p z .u    
0 0 1 7   2  9
     
0 0 0 1   1   1

| 15 |

15

5
11/19/2021

3D Rotation

16

3D Rotation

 In general, rotations are specified by a


rotation axis and an angle. In
two-dimensions there is only one
choice of a rotation axis that leaves
points in the plane.

17

3D Rotation
 The easiest rotation axes are those that parallel to
the coordinate axis.

 Positive rotation angles produce counterclockwise


rotations about a coordinate axix, if we are looking
along the positive half of the axis toward the
coordinate origin.

18

6
11/19/2021

Coordinate Axis
Rotations

19

Coordinate Axis Rotations


 Z-axis rotation: For z axis same as 2D rotation:
 x '  cos   sin  0 0  x 
 y '  sin 
  cos  0 0  y 

 z '  0 0 1 0  z 
     
1   0 0 0 1  1 

P   R z (θ )  P

20

Coordinate Axis Rotations


 Obtain rotations around other axes through
cyclic permutation of coordinate parameters:
xyzx

21

7
11/19/2021

Coordinate Axis Rotations


 X-axis rotation:
 x '  1 0 0 0  x 
 y ' 0 cos   sin  0  y 
   
 z '  0 sin  cos  0  z 
     
 1  0 0 0 1 1

P   R ()  Px

22

Coordinate Axis Rotations


 Y-axis rotation:
 x '   cos  0 sin  0  x 
 y '  0 1 0 0  y 
   
 z '   sin  0 cos  0  z 
     
1   0 0 0 1 1
P  R ()  P y

23

Major Axis Rotation Matrices


1 0 0 0
0 cos  0
 about X axis  sin
Rx  
0 sin cos  0
 
0 0 0 1

 about Y axis  cos  0 sin 0


 0 Rotations are
1 0 0
Ry   orthogonal matrices,
 sin 0 cos  0 preserving distances
 
 0 0 0 1 and angles.
 about Z axis
cos   sin 0 0
 sin cos  0 0
Rz  
 0 0 1 0
 
 0 0 0 1

24

8
11/19/2021

General Three Dimensional


Rotations

25

General Three Dimensional Rotations


Rotation axis parallel with coordinate axis (Example x axis):

P   T 1  R x (θ)  T  P
26

Rotation Axis
 In general rotation vector does not pass through
origin

27

9
11/19/2021

Rotation about an Arbitrary Axis


 Rotation about an Arbitrary Axis

y Basic Idea
T 1. Translate (x1, y1, z1) to the origin
(x2,y2,z2)
2. Rotate (x’2, y’2, z’2) on to the z axis
R
3. Rotate the object around the z-axis
(x1,y1,z1) 4. Rotate the axis to the original
orientation
x R-1
5. Translate the rotation axis to the
z original position
T-1

[TRarb ]  [TTR ]1[TRx   ]1[TR y   ]1[TRz   ][TR y   ][TR x   ][TTR ]

28

Rotation about an Arbitrary Axis


 Step 1. Translation

(x2,y2,z2)
1 0 0  x1 
0 1 0  y1 
(x1,y1,z1)
TTR   
x
0 0 1  z1 
 
z 0 0 0 1 

29

Rotation about an Arbitrary Axis


 Step 2. Establish T  R x ( )

y b b
sin   
b2  c 2 d
(0,b,c) c c
(a,b,c)
cos   
b2  c 2 d
Projected
Point   1 0 0 0  1 0 0 0
 cos   sin  0 0 c / d 0
x T   00
R x ( )
sin  cos 

0  0 b / d
b/ d
c/d 0
z    
0 0 0 1  0 0 0 1
Rotated
Point

30

10
11/19/2021

Rotation about an Arbitrary Axis


 Step 3. Rotate about y axis by 

y a d
sin   , cos  
l l
l 2  a 2  b2  c 2  a 2  d 2
(a,b,c)
d  b2  c 2
Projected l
Point cos  0  sin  0  d / l 0  a / l 0
d  0  0 0
 x T    sin0 
Ry 
1 0
0 cos

0  a / l
1 0
0 d / l 0

(a,0,d)    
 0 0 0 1  0 0 0 1
Rotated
z Point

31

Rotation about an Arbitrary Axis


 Step 4. Rotate about z axis by the desired angle 

cos   sin  0 0
 sin  cos  0 0
T   
Rz  
 0 0 1 0
l  

x
 0 0 0 1

32

Rotation about an Arbitrary Axis


 Step 5. Apply the reverse transformation to place the axis
back in its initial position
y
1 0 0 x1  1 0 0 0
0 1 0 y1  0 cos sin  0
[TTR ] [TRx   ] [TR y   ]  
1 1 1

0 0 1 z1  0  sin  cos 0
l   
0 0 0 1  0 0 0 1
 cos 0 sin  0
 0 1 0 0
l 
x
 sin  0 cos  0
 
 0 0 0 1

z
[TRarb ]  [TTR ]1[TRx   ]1[TR y   ]1[TRz   ][TR y   ][TR x   ][TTR ]

33

11
11/19/2021

34

R (r,φ) :

R r ,    R  x ,  .R  y ,  .R  z ,  .R  y ,  .R  x ,  

1 0 0 0  C 0 S 0
0 0  0
C S 1 0 0 
R ( x ,  )   R ( y,  )  
0  S C 0  S 0 C 0
   
0 0 0 1  0 0 0 1

 C  S 0 0 C  0  S 0 1 0 0 0
S C 0 0   0 1 0 0  0 C  S 0
R( z, )    R ( y ,  )   R ( x,  )   
0 0 1 0 S 0 C 0 0 S C 0
     
0 0 0 1  0 0 0 1 0 0 0 1

S  sin   ry / ry2  rz2   1/ 2


; C  cos   rz / ry2  rz2 
1/ 2


S   rx / r; C   ry2  rz2 
1/ 2
/r V  ver sin    vers  1  cos  |

35

Rotation about an Arbitrary Axis

Find the new coordinates of a unit cube 90º-rotated about an axis defined
by its endpoints A(2,1,0) and B(3,3,1).

36

12
11/19/2021

Rotation about an Arbitrary Axis


 Step1. Translate point A (2,1,0) to the origin

B’(1,2,1)
1 0 0  2
0 1 0  1 
A’(0,0,0) x [TTR ]  
0 0 1 0
z  
0 0 0 1

37

Rotation about an Arbitrary Axis


 Step 2. Rotate axis A’B’ about the x axis by and angle , until
it lies on the xz plane.

2 2 2 5
sin    
2 2  12 5 5
1 5
cos   
y 5 5
Projected point
(0,2,1) B’(1,2,1)
l  12  2 2  12  6

 l
1 0 0 0
x  5 2 5 
0  0
z T     5 5 
B”(1,0,5) Rx 
2 5 5
0 0
 5 5 
0 0 0 1

38

Rotation about an Arbitrary Axis


 Step 3. Rotate axis A’B’’ about the y axis by and angle , until
it coincides with the z axis.

1 6
sin   
y 6 6
5 30
cos   
6 6

l  30 6 
 x  0  0
(0,0,6)  6 6 
B”(1,0,  5) T   
Ry  

0
6
1 0
30
0
0 0
z  6 6 
 0 0 0 1

39

13
11/19/2021

Rotation about an Arbitrary Axis


 Step 4. Rotate the cube 90° about the z axis

0  1 0 0
1 0 0 0
TRz 90   
0 0 1 0
 
0 0 0 1

Finally, the concatenated rotation matrix about the arbitrary axis AB becomes,

[TRarb ]  [TTR ]1[TR x   ]1[TR y   ]1[TR 90  ][TR y   ][TR x   ][TTR ]


z

40

Rotation about an Arbitrary Axis


1 0 0 0  30 6 
1 0 0 2  5 2 5  0 0  0  1 0 0
0 
1 0 1  0 0  6 6  0 0
[TRarb ]    5 5  0 1 0 0  1 0 
0 0 1 0  2 5 5 6 30 0 0 1 0
  0  5 0   0 0  
0 0 1  5  6 6  0 0
0  0 1
0 0 0 1   0 0 0 1
 30 6  1 0 0 0
 0  0  5 2 5  1 0 0  2
6 6  0  0 0

0 1 0 0  5 5 1 0  1 
 
6 30 2 5 5 0 0 1 0
 0 0 0 0  
 6 6  5 5  0 0 0 1
    
0 0 0 1 0 0 0 1
 0.166  0.075 0.983 1.742 
 0.742 0.667 0.075  1.151

 0.650 0.741 0.167 0.560 
 
 0 0 0 1 

41

Rotation about an Arbitrary Axis


 Multiplying [TR]AB by the point matrix of the original cube

P  T P
*
Rarb

 0.166  0.075 0.983 1.742  0 0 1 1 0 0 1 1


 0.742 0.667 0.075  1.151 1 1 1 1 0 0 0 0
 
P 
*
 0.650 0.741 0.167 0.560  1 0 0 1 1 0 0 1
  
 0 0 0 1  1 1 1 1 1 1 1 1
 2.650 1.667 1.834 2.816 2.725 1.742 1.909 2.891 
 0.558  0.484 0.258 0.184  1.225  1.151  0.409  0.483
 
 1.467 1.301 0.650 0.817 0.726 0.560  0.091 0.076 
 
 1 1 1 1 1 1 1 1 

42

14
11/19/2021

Rotation about an Arbitrary Axis


 Reflection Relative to the xy Plane

 x '  1 0 0
0  x 
y y     
 y '   0 1 0 0  y 
z  z'  0 0  1 0  z 
    
z x x  1  0 0 0 1 1 

 Z-axis
 x ' Shear
1 0 a 0  x 
 y '  0
  1 b 0   y 
 z ' 0 0 1 0  z 
    
 1  0 0 0 1 1 

43

Q1 - Translate by <1, 1, 1>

 A translation by an offset (tx, ty, tz) is achieved


using the following matrix:

1 0 0 tx   So to translate by a
0 1 0 t y  vector
M T (t x , t y , t z )   (1, 1, 1), the matrix is simply:
0 0 1 tz 
 
0 0 0 1
1 0 0 1
0 1 0 1
M T (1,1,1)  
0 0 1 1
 
0 0 0 1

44

Q2- Rotate by 45 degrees


about x axis
 So to rotate by 45 degrees about the x-axis, we
use the following matrix:

1 0 0 0
1 0 0 0  1 1 
0 cos 45  sin 45 0  0
0   2 2
R x ( 45)    1 1 
0 sin 45 cos 45 0 0 0
 
0 0 0 1  2 2 
0 0 0 1

45

15
11/19/2021

Q3 - Rotate by 45 about
axis <1, 1, 1>
 So a rotation by 45 degrees about <1, 1, 1> can
be achieved by a few succesive rotations about
the major axes. Which can be represented as a
single composite transformation
2 2
d n x  n z  2  1 .414
nx = 1
ny 1
ny = 1 SO   tan 1  tan 1  35 . 264
d 2
nz = 1 nx 1
  tan 1  tan 1  45
nz 1

46

Q3 - Arbitrary Axis Rotation

 The composite transformation can then be obtained as follows:

M R (1,1,1)  R y1 ( )  R x1 (  )  Rz ( )  Rx (  )  Ry ( )

 cos(45) 0 sin(45) 0 1 0 0 0 cos(45)  sin(45) 0 0


 0  sin(45) cos(45) 0 0
1 0 0 0 cos(35.2)  sin(35.2) 0
= 
 sin(45) 0 cos(45) 0

0 sin(35.2) cos(35.2)

0

 0 0

1 0
     
 0 0 0 1 0 0 0 1  0 0 0 1

1 0 0 0  cos( 45 ) 0 sin( 45) 0


0 0 

cos( 35 .2 )  sin( 35 .2 )
 0 1 0 0 x
0 sin( 35 .2 ) cos( 35 .2 ) 0

 sin( 45) 0

cos( 45) 0 
??
    y
0 0 0 1  0 0 0 1
z

47

Directions vs. Points

 We have looked at transforming points


 Directions are also important in graphics
 Viewing directions
 Normal vectors
 Ray directions (1,1) (-2,-1)
 Directions are represented by vectors, like points,
and can be transformed, but not like points
 Say we define a direction as the difference of two
points: d=a–b. This represents the direction of the line
between two points
 Now we translate the points by the same amount:
a’=a+t, b’=b+t
 Have we transformed d?

48

16
11/19/2021

Homogeneous Directions
 Translation does not affect directions!
 Homogeneous coordinates give us a clear way of handling
this, e.g., direction (x,y) becomes homogeneous direction
(x,y,0), and remains the same after translation:

 1 0 bx   x   x 
0 1 b   y    y 
 y    
0 0 1   0   0 
 (x, y, 0) is a vector, (x,y,1) is a point.
 The same applies to rotation and scaling, e.g., scaling
changes the length of vector, but not direction
 Normal vectors are slightly different though (can’t always
use the matrix for points to transform the normal vector)

49

General Three Dimensional Rotations


An arbitrary axis (with the rotation axis projected onto the Z axis):

R (θ )  T 1  R x 1 ( α )  R y1 (β )  R z (θ)  R y (β )  R x ( α)  T

50

General Three Dimensional Rotations


R (θ )  T 1  R x 1 ( α)  R y1 (β)  R z (θ)  R y (β)  R x (α )  T
 A rotation matrix for any axis that does not coincide
with a coordinate axis can be set up as a composite
transformation involving combination of translations
and the coordinate-axes rotations:
1. Translate the object so that the rotation axis passes through the
coordinate origin
2. Rotate the object so that the axis rotation coincides with one of
the coordinate axes
3. Perform the specified rotation about that coordinate axis
4. Apply inverse rotation axis back to its original orientation
5. Apply the inverse translation to bring the rotation axis back to its
original position

51

17
11/19/2021

General Three Dimensional Rotations


Ex 2: Rotational order of α, θ, φ:
R  , ,    R  z ,  .R  y,  .R  x,  
 C C S S  C S C C S S  S C
0
 S C C 0
 C S
R  ,  ,      
 S C
C S C  C S C C  S S C 0
 
 0 0 0 1
Note: abbreviations used : C  cos  , S  sin  , ...

Ex 3: The rotation order changes: rotate φ around OY, rotate θ around


OZ, then rotate α around OX:
R  , ,    R  x,  .R z ,  .R  y,  
 C C  S C S 0
C S C  S S C C C S S  S C 0
R  ,  ,         
 S S C  C S S C S S S  C C 0
 
 0 0 0 1
| 52 |

52

Other way to look at


rotation
Roll, Pitch, Yaw

53

Roll, Pitch, Yaw

 Imagine three lines running through an


airplane and intersecting at right
angles at the airplane's center of
gravity.

54

18
11/19/2021

Roll
 Roll: rotation around the front-to-back axis.

55

PITCH
 PITCH: Rotation around the side-to-side axis

56

YAW
 YAW: Rotation around the vertical axis.

57

19
11/19/2021

Roll-Pitch-Yaw Rotation (RPY):


The rotations represent the end-effector of
the robot, we determine the order of
rotation:
Rotate an angle ψ around the x-axis →
rotate an angle θ around the y-axis →
rotate an angle  around the z-axis

RPY ( ,  , )  Rot  z ,  Rot  y ,  Rot  x , 


RPY rotational
C C C S S  S C C S C  S S 0 angles
S C S S S  C C S S C  C S 0  of the Robot hand
  
  S C S C C 0
 
 0 0 0 1

| 58 |

58

An Example of the
Airplane

59

An Example of the Airplane


 Consider the following example. An airplane is oriented
such that its nose is pointing in the positive z direction,
its right wing is pointing in the positive x direction, its
cockpit is pointing in the positive y direction. We want
to transform the airplane so that it heads in the direction
given by the vector DOF (direction of flight), is centre
at P, and is not banked.

60

20
11/19/2021

Composite
3D Transformations

61

Composite 3D Transformations

 Same way as in two dimensions:


 Multiply matrices

 Rightmost term in matrix product is the first


transformation to be applied

62

Composite 3D Transformations
Ex4:

r  x y z 1
B T
is:

| 63 |

63

21
11/19/2021

5. Euler Rotation:

In practice, orientation is often the


result of rotation around the x, y,
and z axes. Euler rotation describes
the ability of orientation as follows:
 Rotate an angle  around the z-
axis,
 Next one angle θ around the
new y-axis, that's y’, Euler Rotation
 Finally rotate an angle ψ around
the new z-axis, that's z’’.
We represent Euler's rotation by multiplying 3 rotation matrices :
Euler ( ,  , )  R  z ,  .R  y ,  .R  z ,   R  z , . R  y ,  .R  z ,  
C C C  S S  C C S  S C C S 0
S C C  C S  S C S  C C S S 0
     
  S C S S C 0
 
 0 0 0 1
| 64 |

64

Transformations
Between
Coordinate Systems

65

Transformations Between Coordinate systems

 Translate such that the origins overlap


 Rotate such that the axes overlap
y
y'
u 'x1 u 'x 2 u'x 3 0
u' u 'y 2 u 'y 3 0
R  T   y1  T  x0 , y0 , z0  u y '
 u'z 1 u'z 2 u'z 3 0
 
 0 0 0 1
(x , y , z ) ux'
0 0 0 x'
( 0 ,0 ,0 ) x
uz '

z z'

66

22
11/19/2021

67

R (r,φ) :

R r ,    R  x ,  .R  y ,  .R  z ,  .R  y ,  .R  x ,  

1 0 0 0  C 0 S 0
0 0  0
C S 1 0 0 
R ( x ,  )   R ( y,  )  
0  S C 0  S 0 C 0
   
0 0 0 1  0 0 0 1

 C  S 0 0 C  0  S 0 1 0 0 0
 0 0 
S C 0 0  1 0 0 C  S 0
R( z, )    R ( y ,  )   R ( x,  )   
0 0 1 0 S 0 C 0 0 S C 0
     
0 0 0 1  0 0 0 1 0 0 0 1


S  sin   ry / ry2  rz2 
1/ 2
; C  cos   rz / ry2  rz2   1/ 2


S   rx / r; C   ry2  rz2 
1/ 2
/r |
V  ver sin    vers  1  cos 

68

Homeworks
Exercise 1:

Exercise 2:

Exercise 3:

Exercise 4:

Submit HWs under the form of PPT FILE, WORD FILE


| 69 |

69

23
11/19/2021

Transformations Between Coordinate Systems

Relations between the coordinate system transformation :

Suppose we have 3
coordinate systems A, B, C.
System B is related to system A
through transformation ATB
System C is related to system B
through transformation B TC
We have point P belongs to
the C system: PC
We need to find the
relationship of P in the A
system, denoted: PA

70

Transformations Between Coordinate Systems

Relations between the coordinate system transformation :

PB  BTC . PC

PA  ATB .PB

PA  ATB .B TC .PC Base coordinate frame and other


intermediate coordinate systems of
Robot

The relationship between the coordinate system mounted on end


effector and the base (origin) coordinate system can be described
through the relationship of intermediate coordinate systems mounted
on the robot’s joints, using a T matrix.

71

Transformations Between Coordinate Systems


Describe an object
The objects that are the working objects of robots are very
diverse, but it can be based on geometrical features to
describe them. We can divide the shape of the object into
the following three main groups :
 Rotative objects: center coordinates and surface radius
 Prismatic objects : coordinates of limit points
 Combination objects: has mixed characteristics

For the grasping and motion of the robot, the object


description needs to be associated with homogeneous
transformations.

72

24
11/19/2021

Transformations Between Coordinate Systems


Describe an object
Given a prism-shaped object placed in the standard Oxyz
Example 7:
coordinate system, as shown
We perform the following transformations:
H  Trans ( 4,0 ,0 ). Rot ( y ,90 o ). Rot ( z ,90 o )
With the position of the object, we have a
characteristic 6-point coordinate matrix describing
it:
1 2 3 4 5 6
1  1  1 1 1  1
0 0 0 0 4 4 
 Object description
0 0 2 2 0 0
 
1 1 1 1 1 1

73

Transformations Between Coordinate Systems


Describe an object
After performing transformations:
 Rotate the object around the z-axis by 90 °
 Rotate the object around the y-axis at an
angle of 90 °
 Continuously translating the object along the x-
axis by 4 units, we determine the coordinate
matrix of the object's limit points at the
modified position (rotations select the
reference system as the coordinate system
origin):

-1

74

Transformations Between Coordinate Systems

Describe an object

0 1 0 0  1 1 1 1 1  1
1 0 0 0  0 0 0 0 4 4
 
u1  R z ,90 o .u  
0 0 1
. 
0  0 0 2 2 0 0

  
0 0 0 1  1 1 1 1 1 1
     
u 2  R y ,90 o .u1  R y ,90 o .R z ,90 o .u
u3  T 4 ,0 ,0 .u  T 4,0 ,0 .R  y ,90 .R z ,90 .u  H .u
2
o o

75

25
11/19/2021

Transformations Between Coordinate Systems


Inverse transformation problems:
Determination of rotation angle and rotation axis:

Above, we have studied the forward problems, that is, specify


the rotation axis r and the rotation angle φ first and find the
results of the transformation according to those specified
rotations.

In contrast to the above problem, which is the inverse problem,


assuming we know that after some transformation, the result is
that the object is in a completely determined final state, the
problem is to reverse the transformation parameters. What,
namely, find the rotation axis k and the rotation angle θ when
transforming.

76

Transformations Between Coordinate Systems


Determination of rotation angle and rotation axis:
Normally, the last state of the object can be described by a TE matrix,
called the final state matrix. Assume the T E matrix is determined as follows:

u x vx wx px  Each column of the 3 × 3 in rotation


u vy wy p y  matrix is a one-axis unit vector of
TE   y the UVW dynamic coordinate
u z vz wz pz  system (attached to the object in
  question), represented in the fixed
0 0 0 1
coordinate system XYZ.
We have:
u x vx wx p x   rx2V  C rx ryV  rz S rx rzV  ry S 0
u  
vy wy p y  rx ryV  rz S ry2V  C ry rzV  rx S 0
TE   y  (1)
u z vz wz p z  rx rzV  ry S ry rzV  rx S rz2V  C 0
   
0 0 0 1   0 0 0 1

77

Transformations Between Coordinate Systems


Determination of rotation angle and rotation axis:
Comparing the equivalent elements of two matrices, the necessary
relations can be determined.
We have:
p x  p y  p z  0 corresponds to the origin of UVW coincides
with the origin of XYZ.

Adding diagonals of two matrices on both sides, we have:

u x  v y  wz  1  rx2V  C  ry2V  C  rz2V  C  1


 
 rx2  ry2  rz2 V  3C  1  1  C  3C  1  21  C 
1
 C  cos   u x  vy  wz  1 (2)
2

78

26
11/19/2021

Transformations Between Coordinate Systems


Determination of rotation angle and rotation axis:
 Calculate the difference of the equivalent elements of two matrices:

vz  wy  2rx S ; wx  u z  2ry S ; u y  v x  2rz S (3)

Square both sides of the above equations and then add them together,
we have:

v z  wy   wx  u z   u y  vx   2 S2
2 2 2

1
 S  sin    v z  wy 2  wx  u z 2  u y  vx 2 (4)
2

When 0    1800
v z  wy   wx  u z   u y  vx 
2 2 2

tg  (5)
u x  v y  wz  1

79

Transformations Between Coordinate Systems


Determination of rotation angle and rotation axis:
 From (3), determine the rotation axis of r:
v z  wy wx  u z u y  vx
rx  ; ry  ; rz  (6)
2 sin  2 sin  2 sin 
According to this eq, r cannot be determine when =0 or =180,
thus consider the equivalent elements of the matrix equation (1):

u x  C ux  cos
rx   


V 1  cos
u x  rx2V  C
v y  C v y  cos (7)
v y  ry2V  C  ry   
V 1  cos
2
wz  r V  C
z 
wy  C wz  cos
rz   
V 1  cos

80

Transformations Between Coordinate Systems


Determination of rotation angle and rotation axis:

When 0    1800
Sin is always positive, according to eq.(3) we have rx, ry, rz always with
the same sign as the left side, so we can use the function Sgn(x) to
represent the relation .

u x  cos 
rx  Sgn(vz  w y )
1  cos 
v y  cos  (8)
ry  Sgn( wx  u z )
1  cos 
wz  cos 
rz  Sgn(u y  v x )
1  cos 

81

27
11/19/2021

Transformations Between Coordinate Systems


Determination of rotation angle and rotation axis:
 It is possible to determine the components of the axis of
rotation r, using the method of adding the remaining pairs
of the diagonally symmetrical elements of eq(1), we have:

u y  vx  2rx ryV  2 rx ry 1  cos  


vz  wy  2 ry rzV  2ry rz 1  cos   (9)
wx  u z  2rz rxV  2rz rx 1  cos  

More conveniently, if you choose from eq.(8) the


component with the largest value, for example rx, then
calculate the remaining components according to eq.(9)
u y  vx wx  u z
ry  ; rz  (10)
2rx 1  cos  2rx 1  cos 

82

Transformations Between Coordinate Systems


Determination of rotation angle and rotation axis:
Ex 8:
0 0 1 0
Given R(r,)=R(y,90).R(z,90). 1
Determine the rotation axis r
0 0 0
R r ,     
and rotational angle  satisfied: 0 1 0 0
 
0 0 0 1

Solution: From equation(2), we have:


1
cos   ux  v y  wz  1  1 0  0  0  1   1
2 2 2
1 1 3
sin   v z  w y   wx  u z   u y  v x  
2 2 2
1  02  1  0 2  1  02 
2 2 2

According to eq.(8): 0  1/ 2 1
rx  ry  rz   
1 1 / 2 3

83

Transformations Between Coordinate Systems


Determination of rotation angle and rotation axis:
z
T
Thus we have:  1 1 1 
r  , ,  1/ 3
 3 3 3

r
120 y

1/ 3

x 1/ 3

Rotation axis r and


rotational angle φ

84

28
11/19/2021

Transformations Between Coordinate Systems


9.2/ Determine the three Euler angles:
In part 5, the rotation of an object was expressed through
the angles , , ψ. Now consider the inverse problem, if we
know the final state of the object as a result of that rotation,
the problem is from which to determine these rotation
angles.
Similarly, we can describe the final state of an object using
the TE matrix:
Euler ( ,  , )  R ( ,  , )  R  z ,  .R  y ,  . R  z ,   TE (11)

Balancing the corresponding elements, we have:


u x  C C C  S S ; u y  C C C  C  S ; u z   S C
v x   C C C  S  S ; v y   S C S  C  S ; v z  S S (12)

w x  C S  ; w y  S  S  ; w z  C

85

Transformations Between Coordinate Systems


9.2/ Determine the three Euler angles:
From (12), determine the rotational angles of , , ψ as
follow:
  arccos w z  cos  1 w z
 wx 
  cos 1   (13)
 sin  
 uz 
  cos 1   
 sin  

Since the multi value of the arccos function and the sine function in the
denominator, it will be infinitive when =0 or =180°. People often use
arctg2 function (y, x) called variable arctg2 function or arctg2 function,
with the definition of the item being unique based on the sign of the y / x
ratio. The function returns the angle value in the range - ≤  ≤ by
checking the sign of y and x.

86

Transformations Between Coordinate Systems


y
9.2/ Determine the three Euler angles: X Y 
X Y 
Ex: arctg 2  1 /  1   135 

x
arctg 2 1 / 1  45 
1/ 3
Perform the following X Y  X Y 
transformation.
From (11), we have:
Function arctg2(y, x)
R ( z ,  )  1 TE  R  y ,  .R  z ,  (14)

 C S 0 0  u x vx wx p x   C C  C S S 0
 S C 0 0   u y vy wy p y   S C 0 0 
  . 
 0 0 1 0  u z vz wz p z    S  C S S C 0  (15)
    
 0 0 0 1  0 0 0 1  0 0 0 1

87

29
11/19/2021

Transformations Between Coordinate Systems


9.2/ Determine the three Euler angles:
Multiply by 2 matrices on the left side, and note that: px  p y  pz  0
 C u x  S u y C vx  S v y C wx  S wy 0  C C  C S S 0
 S u  C u  S vx  C v y  S wx  C wy 0  S C 0 0
  x  y
 (16)
 uz vz wz 0  S C S S C 0
   
 0 0 0 1  0 0 0 1
Balancing 2 elements in row 2 and column 3, we have:
S sin  wy  w y
 S w x  C w y  0  tg      (17)
C cos  w x  w x
So angle  can be determined using the arctg2 function:
two pairs of solutions
  arctg 2 w y , w x   arctg 2  w y ,  w x  that are 180 degrees
apart

If w x=w y=0, that is the degenerate case, and we take  =0.

88

Transformations Between Coordinate Systems


9.2/ Determine the three Euler angles:

Continuing to compare the elements of the two matrices, we have :

C w x  S w y  S  ; w z  C    arctg 2 C w x  S  w y , w z 
And:
 S u x  C u y  S ;  S  v x  C  v y  C
   arctg 2  S u x  C u y ,  S  v x  C  v y 
Thus, 3 Euler rotation angles are determined as follows :
  arctg 2 w y , w x   arctg 2  w y ,  w x 
  arctg 2 C  w x  S w y , w z  (18)

  arctg 2  S  u x  C u y ,  S v x  C v y 

89

Transformations Between Coordinate Systems


9.3/ Determine the 3 rotation angles of Roll-Pitch-Yaw (RPY):

90

30
11/19/2021

Transformations Between Coordinate Systems


9.3/ Determine the 3 rotation angles of Roll-Pitch-Yaw (RPY):
The Roll-Pitch-Yaw transformation was presented in section
6, the result of that transformation is the object in the final
state described by the matrix TE :
RPY ( ,  , )  R  z ,  .R  y ,  .R  x ,   T E (19)

We also use the solution as in 9.2 to determine the rotation


angles:
R  z ,  1 TE  R  y ,  . R  x ,  (20)

 C u x  S u y C v x  S v x C wx  S  wy 0   C C S S C 0
 S u  C u  S v x  C v y  S wx  C w y 0   0 C  S 0
  x  y

 uz vz wz 0    S C S C C 0 (21)
   
 0 0 0 1  0 0 0 1

91

Transformations Between Coordinate Systems


9.3/ Determine the 3 rotation angles of Roll-Pitch-Yaw (RPY):
Balancing the two elements in row 2, column 1:
 S  u x  C  u y  0    arctg 2 u x , u y ; and     180 
Then balance the elements in the two matrices:
 S  u z ; C  C u x  S  u y    arctg 2  u z , C  u x  S  u y 
On the other hand:  S   S  w x  C w y ; C   S v x  C v y
   arctg 2 S  w x  C w y ,  S v x  C v y 

Thus, the three rotation angles of RPY are determined as:

  arctg 2 u x , u y ;     180 
  arctg 2  u z , C u x  S u y  (22)

  arctg 2S  w x  C w y ,  S v x  C v y 

92

Index 1: atan2 (y, x) function


How to determine the value of function atan2 (y,x):

  y
 arctan  x  if x  0
  
  y
 arctan     if x  0 and y  0
 x
 y
 arctan     if x  0 and y  0
a tan 2 ( y , x )   x

 if x  0 and y  0
2
 
 if x  0 and y  0
 2
undefined if x  0 and y  0

https://vi.wikipedia.org/wiki/H%E1%BB%87_t%E1%BB%8Da_%C4%91%E1%BB%99_c%E1%BB%B1c

93

31
11/19/2021

Transformations Between Coordinate Systems


Quizs:
Prob. 1: Determine the Euler rotations and RPY rotations when the final
state matrix is known: 1 0 0 0 
0 0 1 5 
TE  
0 1 0 3
 
0 0 0 1
0 1 0  1
An object placed in a coordinate reference 0 1 2 
Prob. 2: R
TP  
0

system, defined by the transformation:  1 0 0 0
 
0 0 0 1
A robot whose standard coordinate system is
related to the reference coordinate system 1 0 0 1
by the transformation: 0 1 0 5
The coordinate system on the robot’s end effector
U
TR   
0 0 1 9
coincides with the coordinate system of the object.
 
Find the transformation (representing the 0 0 0 1
relationship between the end effector and the
robot's origin coordinate system) U
TP

94

95

32

You might also like