+ All Categories
Home > Documents > 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics...

3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics...

Date post: 26-Mar-2015
Category:
Upload: victoria-mitchell
View: 216 times
Download: 1 times
Share this document with a friend
Popular Tags:
24
3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012
Transcript
Page 1: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

3D Transformations

1

Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department

Computer Graphics Course

Kocaeli UniversityFall 2012

Page 2: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Extending From 2d Approach• Methods for geometric transformations in three

dimensions are extended from two-dimensional methods by including considerations for the z coordinate.

• A three-dimensional position, expressed in homogeneous coordinates, is represented as a four-element column vector. Thus , each geometric transformation operator is now 4 by 4 matrix.

2

Page 3: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Translation

3

' ' ', ,x y zx x t y y t z z t

1 0 0

0 1 0

0 0 1

1 0 0 0 1 1

x

y

z

x t x

y t y

z t z

Page 4: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation: z-axis rotation

• 3D Coordinate-Axis Rotations• z-axis rotation (counter-clockwise)

4

Page 5: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation: x-axis rotation

• counter-clockwise

5

Page 6: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation: y-axis rotation

• counter-clockwise

6

Page 7: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Scaling

• Change the coordinates of the object by scaling factors.

z

y

x

z

y

x

PSP

P

P

Page 8: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Scaling with respect to a Fixed Point

• Translate to origin, scale, translate back

z

y

x

z

y x

z

y

x

z

y

x

Translate Scale Translate back

PTSTP ),,(),,( ffffff zyxzyx

Page 9: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Scaling with respect to a Fixed Point

1000

)1(00

)1(00

)1(00

),,(),,(

1000

00

00

00

1000

100

010

001

1000

100

010

001

1000

000

000

000

1000

100

010

001

),,(),,(

zfz

yfy

xfx

ffffff

fzz

fyy

fxx

f

f

f

f

f

f

z

y

x

f

f

f

ffffff

szs

sys

sxs

zyxzyx

zss

yss

xss

z

y

x

z

y

x

s

s

s

z

y

x

zyxzyx

TST

TST

Page 10: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Reflection

• Reflection over planes, lines or points

1 0 0 00 1 0 00 0 1 00 0 0 1

z

y

x

z

y

x

z

y

x

1 0 0 00 1 0 00 0 1 00 0 0 1

1 0 0 00 1 0 00 0 1 00 0 0 1

z

y

x

1 0 0 00 1 0 00 0 1 00 0 0 1

Page 11: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Shear• Deform the shape depending on another dimension

SH z

1 0 a 00 1 b 00 0 1 00 0 0 1

x and y value depends on z value of the shape

SH x

1 0 0 0a 1 0 0b 0 1 00 0 0 1

y and z value depends on x value of the shape

Page 12: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Advanced Topics

12

Page 13: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

1. Rotation Around a Parallel Axis

13

• Translate the object so that the rotation axis coincides with the parallel coordinate axis

• Perform the specified rotation about that axis• Translate the object so that rotation axis is moved

back to its original• A coordinate position P is transformed with the

sequence

' 1 ( )xP T R T P -1

Page 14: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation Around a Parallel Axis• Rotating the object around a line parallel to one of the axes:

Translate to axis, rotate, translate back.

z

y

x

z

y

x

z

y

x

z

y

x

Translate Rotate Translate back

PTRTP ),,0()(),,0( ppxpp zyzy

Page 15: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

2. Rotation Around an Arbitrary Axis

• In this case, we also need rotation to align the rotation axis with a selected coordinate axis and then to bring the rotation axis back to its original orientation

• A rotation axis can be defined with two coordinate position, or one position and direction angles.

• Now we assume that the rotation axis is defined by two points, and that the direction of rotation is to be counter clockwise when looking along the axis from p2 to p1.

15

Page 16: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation Around an Arbitrary Axis

• Translate the object so that the rotation axis passes though the origin

• Rotate the object so that the rotation axis is aligned with one of the coordinate axes

• Make the specified rotation• Reverse the axis rotation• Translate back

z

y

x

Page 17: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation Around an Arbitrary Axis

Page 18: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation Around an Arbitrary Axis

),,( 12121212 zzyyxx PPV

),,( cbaV

Vuu is the unit vector along V:

First step: Translate P1 to origin:

1000

100

010

001

1

1

1

z

y

x

T

Next step: Align u with the z axiswe need two rotations: rotate around x axis to get u onto the xz plane, rotate around y axis to get u aligned with z axis.

Page 19: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation Around an Arbitrary Axis

z

x

u

Align u with the z axis

1) rotate around x axis to get u into the xz plane,

2) rotate around y axis to get u aligned with the z axis

y

α

z

xu

y

β

),,()()()()()(),,()( 111111 zyxzyx xyzyx TRRRRRTR

Page 20: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

BACKUP Slides

No need to study Advanced Topics

20

Page 21: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation Around an Arbitrary Axis

z

x

u

Align u with the z axis

1) rotate around x axis to get u into the xz plane,

2) rotate around y axis to get u aligned with the z axis

y

α

z

xu

y

βz

x

uu' α

uz

y

),,()()()()()(),,()( 111111 zyxzyx xyzyx TRRRRRTR

Page 22: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Dot product and Cross Product

• v dot u = vx * ux + vy * uy + vz * uz. That equals also to |v|*|u|*cos(a) if a is the angle between v and u vectors. Dot product is zero if vectors are perpendicular.

v x u is a vector that is perpendicular to both vectors you multiply. Its length is |v|*|u|*sin(a), that is an area of parallelogram built on them. If v and u are parallel then the product is the null vector.

Page 23: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation Around an Arbitrary Axis

z

x

uu' α

Align u with the z axis

1) rotate around x axis to get u into the xz plane,

2) rotate around y axis to get u aligned with the z axis

uz

We need cosine and sine of α for rotation

),,0( cbu

22 cos cbdd

c

z

z

uu

uu

bxzxz uuuuuu sin

sindb

d

b

d

c sin cos

1000

00

00

0001

)(

d

c

d

bd

b

d

c

x RProjection of u onyz plane

Page 24: 3D Transformations 1 Assist. Prof. Dr. Ahmet Sayar Computer Engineering Department Computer Graphics Course Kocaeli University Fall 2012.

Rotation Around an Arbitrary Axis

z

x

u

u''= (a,0,d)

Align u with the z axis

1) rotate around x axis to get u into the xz plane,

2) rotate around y axis to get u aligned with the z axis

duu

uu

z

z

cos

)(sin ayzyz uuuuuu

1000

00

0010

00

)(

sin cos

da

ad

ad

y

R

),,()()()()()(),,()( 111111 zyxzyx xyzyx TRRRRRTR

β


Recommended