Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

23
Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003

Transcript of Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Page 1: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Arbitrary Rotations in 3D

Lecture 18Wed, Oct 8, 2003

Page 2: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

Consider a rotation through an angle about a line through the origin.We must assign a positive direction to the line.We do this by using a vector rather than a line.

Page 3: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

The function callglRotatef(angle, vx, vy, vz)

will create a single matrix that represents a rotation about the vector v = (vx, vy, vz).There are some clever ways of obtaining this matrix.We will learn an elementary (non-clever) method.

Page 4: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

To find the matrix of an rotation through an angle about a vector v emanating from the origin Rotate about the y-axis so that v is in

the xy-plane. Let this angle be and call the new vector v’.

Rotate about the z-axis so that v’ is aligned with the positive x-axis. Let this angle be –.

Page 5: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

Rotate about the x-axis through angle .

Rotate about the z-axis through angle .

Rotate about the y-axis through angle –.

Page 6: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

Find the matrix of a rotation of angle about unit vector v = (vx, vy, vz).

v

Page 7: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

Rotate v about the y-axis through angle to get vector v’.Call this matrix Ry().

v

Page 8: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

Rotate v’ about the z-axis through angle – to get vector v’’.Call this matrix Rz(–).

v’

v’’

Page 9: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

Rotate about the x-axis through angle .Call this matrix Rx().

v’’

Page 10: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Rotations about an Arbitrary Axis

Then apply Rz(-)–1 followed by Ry()–1.

The matrix of the rotation is the product

Ry()–1Rz(-)–1Rx()Rz(-)Ry()

This is the same asRy(-)Rz()Rx()Rz(-)Ry()

Page 11: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

Find the matrix of the rotation about v = (1/3, 2/3, 2/3) through 90.v projects to (1/3, 0, 2/3) in the xz-plane. = tan–1(2).cos() = 1/5, sin() = 2/5.

Page 12: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

The matrix of this rotation is

1/5 0 2/5 0

0 1 0 0

–2/5 0 1/5 0

0 0 0 1

Ry() =

Page 13: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

v rotates into the vector v’ = (5/3, 2/3, 0). = tan–1(2/5).cos(-) = 5/3, sin(-) = -2/3.

Page 14: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

The matrix of this rotation is

5/3 2/3 0 0

-2/3 5/3 0 0

0 0 1 0

0 0 0 1

Rz(-) =

Page 15: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

Now apply the original rotation of 90 to the x-axis.The matrix is

1 0 0 0

0 0 -1 0

0 1 0 0

0 0 0 1

Rz() =

Page 16: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

Reverse the rotation through angle .

5/3 -2/3 0 0

2/3 5/3 0 0

0 0 1 0

0 0 0 1

Rz() =

Page 17: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

Reverse the rotation through angle .

1/5 0 -2/5 0

0 1 0 0

2/5 0 1/5 0

0 0 0 1

Ry(-) =

Page 18: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

The product of these five matrices is the matrix of the original rotation.

1/9 -4/9 8/9 0

8/9 4/9 1/9 0

-4/9 7/9 4/9 0

0 0 0 1

R() =

Page 19: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

How can we verify that this is correct?If P is a point on the axis of rotation, then the transformed P should be the same as P.If v is orthogonal to the axis, then the transformed v should be orthogonal to v.If we apply the transformation 4 times, we should get the identity.

Page 20: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

A point on the axis is of the form(t, 2t, 2t, 1).

The matrix maps this point to(t, 2t, 2t, 1).

Page 21: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Example: Rotation

Compute-7/9 4/9 4/9 0

4/9 -1/9 8/9 0

4/9 8/9 -1/9 0

0 0 0 1

R()2 =

1 0 0 0

0 1 0 0

0 0 1 0

0 0 0 1

R()4 =

Page 22: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Special Properties of Rotation Matrices

Every rotation matrix has the following properties. Each row or column dotted with itself

is 1. Each row (column) dotted with a

different row (column) is 0.

A matrix with this property is called orthonormal.Its inverse equals its transpose.

Page 23: Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.

Special Properties of Rotation Matrices

Verify that R() is orthonormal.Consider each row of the matrix to be a point.Where does the matrix map each row?These are the points that map to the points (1, 0, 0), (0, 1, 0), and (0, 0, 1).What about the columns? What do they represent?