168 471 computer graphics, kku. lecture 51 transformations given two frames in an affine space of...

29
168 471 Computer Graphics, KKU. Lec ture 5 1 Transformations Given two frames in an affine space of d imension n, we can find a (n+1) x (n+1) m atrix that converts the coor- dinates of a point in the first frame to the coordi nates of the same point in the second fr ame. The opera- tion are called transform ation. The matrix is called transformation matrix. In 3D space, for example, the gen eral form of the matrix is

Upload: cameron-park

Post on 03-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

1

Transformations

Given two frames in an affine space of dimensionn , we can find a (n+1 ) x (n +1 ) matrix that conver

- ts the coor dinates of a point in the first frame to the coordinates of the same point in the second f

- rame. The opera tion are called transformation . The matrix is called transformation matrix . I

n 3 D space, for example, the general form of th e matrix is

Page 2: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

2

Transformations: The Relationship

• The matrix can be applied to - the coordinate,leaving the frame fixed.- the frame, leaving the coordinate fixed.

• It is useful to allow us to shift a point between the local coordinates of the point, or between the frames

• In 3D space

Page 3: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

3

Cramer’s Rule

Given a frame and any point having coordinates (u,v,w), we can define a vector

Cramer’s Rule states that

1

2

3

Du DDv DDw D

and

Page 4: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

4

Finding a transformation matrix

Consider two frames denoted as and By Cramer’s rule, let

1. If we give , then we can get

1,1 1,2 1,3, , ande u e v e w

2. If we give , then we can get

2,1 2,2 2,3, , ande u e v e w

3. If we give , then we can get

3,1 3,2 3,3, , ande u e v e w

4 . If we give , then we can get

4,1 4,2 4,3, , ande u e v e w

Page 5: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

5

168 471 Computer Graphics (First Semester, 2001)Assignment#2 (Due on June 27, 2001)

1. For three points in 2D cartesian frame, 1 1( , )x y , 2 2( , )x y and 3 3( , )x y , show that the

determinant

1 2 3

1 2 3

1 1 1

x x x

y y y

is proportional to the area of the triangle whose corner are the three points.

2. By using Cramer’s rule, determine the transformation matrix of the example given at the endof the lecture 4.

Page 6: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

6

Simple Transformations

• Translation• Scaling• Rotation• Shearing

Page 7: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

7

Translation

• Moves all points of an objects a fixed distance in a specified direction.

• Translation of frames

• Translation of points within the frame

the origin is moved but the vectors stay the same.

Page 8: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

8

Translation (Cont.)

• A translation matrix is

• The matrix is most frequently applied to all points of an object in the local system to move the object within the system.

Page 9: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

9

Scaling

• Scales the coordinates of an objects

• Scaling a frame - expands or contracts the lengths of the vectors

• Scaling a point

Page 10: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

10

Scaling (Cont.)

• A Scaling matrix

• By scaling, you multiply each point of an object by a factor which effectively scaling the object about the origin.

Page 11: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

11

Scaling (Cont.)

• If the center of the object is not at the origin, the operation will move the object away from the origin of the frame.

Page 12: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

12

Scaling (Cont.)

• For the case of scaling about other points, we need to combine the scaling transformation with two translation transformations in order to correctly get a transformation matrix.

Page 13: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

13

• performed about an axis which is usually specified by a point P and a vector direction .

Rotation

• Rotating about a point in two dimensions

Rotation matrix

Page 14: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

14

Rotation about the X-Axis

;xR

Page 15: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

15

Rotation about the Y-Axis

;yR

Page 16: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

16

Rotation about the Z-Axis

;zR

Page 17: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

17

Rotation about an arbitrary axis

• Assuming the axis of rotation is represented by

and

then a rotation of degrees about this axis can be defined by concatenating the following transformations

1. Translate so that the point P moves to the origin

Page 18: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

18

Rotation about an arbitrary axis (Cont.)

2. Rotate the vector until it is in the yz ppppp pp ppppp p pppppppp

where

Page 19: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

19

Rotation about an arbitrary axis (Cont.)

3. Rotate the vector until it coincides with the x axis

where

Page 20: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

20

Rotation about an arbitrary axis (Cont.)

4. Rotate about the z axis.

Page 21: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

21

Rotation about an arbitrary axis (Cont.)

5. Use rotations and translations to reverse the first three steps

Page 22: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

22

Rotation about an arbitrary axis (Cont.)

The matrix representation of the general rotation is given by

the product of the above transformations.

Page 23: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

23

Shearing

• Shearing transformations in three-dimensions alter two of the three coordinate values proportionally to the value

of the third coordinate.

Page 24: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

24

X-Shearing

• X-shearing a frame: We ``x-shear'' a frame by modifying the first vector of the frame by adding to it a linear

combination of the other two vectors.

Page 25: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

25

- X Shearing (Cont.)

• X-shearing a point

• The X-shear transformation matrix can be defined by

Page 26: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

26

Y-Shearing

• Y-shearing a frame

Page 27: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

27

- Y Shearing (Cont.)

• Y-shearing a point

• The Y-shear transformation matrix can be defined by

Page 28: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

28

Z-Shearing

• Z-shearing a frame

Page 29: 168 471 Computer Graphics, KKU. Lecture 51 Transformations Given two frames in an affine space of dimension n, we can find a ( n+1 ) x ( n +1) matrix that

168 471 Computer Graphics, KKU. Lecture 5

29

- Z Shearing (Cont.)

• Z-shearing a point

• The Z-shear transformation matrix can be defined by