23
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation

Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation

  • View
    231

  • Download
    3

Embed Size (px)

Citation preview

Elementary 3D Transformations - a "Graphics Engine"

Transformation procedures

Transformations of coordinate systems

Translation

Scaling

Rotation

Coordinate systems

Y

X

ZX

Y

Z

left handed right handed

Transformation procedures

• A scene is made up of objects• Objects can be made of separately defined parts

• Each object / part defined by a list of points (vertices)

• Any part of the object can be moved or distorted by

applying a transformation to the list of points which

define it

Basic transformations

• Translation (shift)

• Scaling

• Rotation

Translation

T = (Tx,Ty,Tz)

x’ = x + Txy’ = y + Tyz’ = z + Tz

X

Y

Z

A

B

C

DA

B

C

D

Scalingabout the origin

X

Z

Y

A

B

C

D

A

B

C

D

x’ = x * Sxy’ = y * Syz’ = z * Sz

S > 1 - enlarge0 < S < 1 - reduceS < 0 - mirror

Scalingabout an arbitrary point

Scaling about a fixed point ( xc, yc, zc )

x' = xc + ( x – xc ) * Sx

y' = xc + ( y – yc ) * Sy

z' = zc + ( z – zc ) * Sz

Can also be achieved by a composite transformation.

Rotation

The direction of rotation in the left-handed system

Positive angle of rotation

when looking from a positive axis toward the origin

a 90o clockwise rotation transforms one positive

axis into the other.

Positive angle of rotation for Z axis

Y

X

Looking from the positive end of Z axis towards the origin

Rotation

Axis of rotation is Direction of positive rotation is

X from Y to Z

Y from Z to X

Z from X to Y

A

C

DB

Rotation about Z axis

X

Y

Z

A

B

C

D x' = x·cos - y·sin y' = x·sin + y·cos z' = z

Rotation about X axis

• y' = y·cos - z·sin • z' = y·sin + z·cos • x' = x

X

Y

Z

A

B

C

D

A

B

C

D

Rotation about Y axis

• z' = z·cos - x·sin• x' = z·sin + x·cos• y' = y

X

Y

Z

B

C

D

AA

B

C

D

Matrix representationHomogeneous coordinates

• common notation for ALL transformations

• common computational mechanism for ALL transformations

• simple mechanism for combining a number of transformations => computational efficiency

Common matrix operation for all transformations???

• Translate (shift) point P• Scale point P• Rotate point P

Point (vector) P = [ xp yp zp ]

Matrix ???

Homogeneous coordinates

• Point P = (x, y, z ) represented by a vector

P =

• TransformationsAll represented by a 4 x 4 matrix T

T =

x

yz1

a d g j

b e h kc f i l0 0 0 1

x

yz1

Point transformation in homogeneous coordinates

x'

y'z'1

=

a d g j

b e h kc f i l0 0 0 1

x

yz1

• Implemented by matrix multiplicationP’ = T · P

Transformation matrices for elementary transformations

• 4 x 4 matrix

• Homogeneous coordinates

• Translation, scaling, rotation and perspective

projection, all defined through matrices

Translation

x’ = x + Tx

y’ = y + Ty

z’ = z + Tz

T =

1 0 0 Tx

0 1 0 Ty0 0 1 Tz0 0 0 1

Scaling

x’ = x * Sx

y’ = y * Sy

z’ = z * Sz

S =

Sx 0 0 0

0 Sy 0 00 0 Sz 00 0 0 1

Rotation about Z axis

x' = x·cos - y·sin y' = x·sin + y·cos z' = z

Rz =

cos -sin 0 0

sin cos 0 00 0 1 00 0 0 1

Rotation about X axis

y' = y·cos - z·sin z' = y·sin + z·cos x' = x

Rx =

1 0 0 0

0 cos -sin 00 sin cos 00 0 0 1

Rotation about Y axis

z' = z·cos - x·sinx' = z·sin + x·cosy' = y

Ry =

cos 0 sin 0

0 1 0 0-sin 0 cos 0

0 0 0 1