Computer Graphic - Transformations in 3d

24
COMPUTER GRAPHICS CH04 – TRANSFORMATIONS IN 3D

Transcript of Computer Graphic - Transformations in 3d

Page 1: Computer Graphic - Transformations in 3d

COMPUTER GRAPHICSCH04 – TRANSFORMATIONS IN 3D

Page 2: Computer Graphic - Transformations in 3d

3D GRAPH

Right handed space consistent with math. Left handed space suitable to screens. To transform from right to left negate the z values.

Page 3: Computer Graphic - Transformations in 3d

TRANSLATION

Page 4: Computer Graphic - Transformations in 3d

SCALING

Page 5: Computer Graphic - Transformations in 3d

SHEARING

Page 6: Computer Graphic - Transformations in 3d

REFLECTION

Page 7: Computer Graphic - Transformations in 3d

ROTATION

Page 8: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE There are five steps for reflection about an arbitrary point in space:

1. Translate to the origin by –(x0,y0,z0).2. Rotate (x’,y’,z’) about x-axis.3. Rotate (x’,y’,z’) about y-axis.4. Rotate about z-axis.5. Inverse step 2 By changing the sin sign.6. Inverse step 3 By changing the sin sign.7. Inverse step 1 By changing the tx, ty and tz sign.

Page 9: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE EX: Find the new coordinate of a unit cube 90 degree rotated about an axis defined by its end points A(2,1,0) and B(3,3,1).

Page 10: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 1: Translate to origin

a= 3-2= 1 b= 3-1= 2 c= 1-0= 1

1 0 0 -20 1 0 -

10 0 1

00 0 0

1

Page 11: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 2: Rotation about x-axis D= = = Sin= b/d= 2/ Cos= c/d= 1/

1 0 0 0

0 1/ -2/ 10 2/ 1/ 1

0 0 0 1

Page 12: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 3: Rotation about y-axis L= = Sin= a/L= 1/ Cos= d/L= /

/0 -1/0 0 1 0

0/0 /0

0 0 0 1

Page 13: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 4: Rotation about z-axis by 90 degree0 -1 0

01 0 0

00 0 1

00 0 0

1

Page 14: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 5: Inverse Rotation about x-axis

1 0 0 0

0 1/ 2/ 10 -2/ 1/ 1

0 0 0 1

Page 15: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 6: Inverse Rotation about y-axis

/0 1/0 0 1 0

0/0 / 0

0 0 0 1

Page 16: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 7: Inverse of Translation

Then we multiply all the matrices with each other.

1 0 0 20 1 0

10 0 1

00 0 0

1

Page 17: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE EX: Find the rotation for the point (1,2,1) by 90 degree

(1,2,3)

(4,6,7)

Page 18: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 1: Translate to origin

A= 4-1= 3 B= 6-2= 4 C= 7-3= 4

1 0 0 -10 1 0 -

20 0 1 -

30 0 0

1

Page 19: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 2: Rotation about x-axis D= = = Sin= b/d= 4/ Cos= c/d= 4/

1 0 0 0

0 4/ -4/ 10 4/ 4/ 1

0 0 0 1

Page 20: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 3: Rotation about y-axis L= = Sin= a/L= 3/ Cos= d/L=/

/0 -3/0 0 1 0

0 /0 /0

0 0 0 1

Page 21: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 4: Rotation about z-axis by 90 degree0 -1 0

01 0 0

00 0 1

00 0 0

1

Page 22: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 5: Inverse step 2

1 0 0 0

0 4/ 4/ 10 -4/ 4/ 1

0 0 0 1

Page 23: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 6: Inverse step 3

/0 /0 0 1 0

0 -/0 /0

0 0 0 1

Page 24: Computer Graphic - Transformations in 3d

ROTATION ABOUT AN ARBITRARY AXIS IN SPACE Step 1: Inverse step 1

Then we multiply all the matrices with each other and with the point (1,2,1).

1 0 0 10 1 0

20 0 1

30 0 0

1