Docsity

Computer Graphics: Homogeneous Coordinates and Transformations, Study notes of Computer Graphics

Partial preview of the text

Download Computer Graphics: Homogeneous Coordinates and Transformations and more Study notes Computer Graphics in PDF only on Docsity!

Computer Graphics

CS 470

Computer Science and Electrical Engineering Dept.

West Virginia University

September 12, 2008

Outline

(^1) Review

2 Coordinate systems and frames

(^3) Homogeneous coordinates

(^4) Change of coordinate system

(^5) Transformations

Review

Frame

To specify a frame: in 3D

a reference point, P 0 , and basis vectors {v 1 , v 2 , v 3 }

Notation : F = (P 0 , v 1 , v 2 , v 3 )

The Cartesian frame

The 3 basis vectors, e 1 , e 2 , e 3 , are chosen to be unit length and mutually

perpendicular.

e 1 · e 1 = e 2 · e 2 = e 3 · e 3 = 1

e 1 · e 2 = e 1 · e 3 = e 2 · e 3 = 0

Review

Frames in OpenGL

Vertices can have different coordinates in all of the different frames:

Model (sometimes called Object or Local frame)

World frame

Camera (or Eye) frame

Window (or Screen) frame

The transformations from one frame to another are controlled by 4 × 4

matrices.

Coordinate systems and frames

Frame

Three non-coplanar basis vectors v 1 , v 2 , v 3 and a reference point P 0 define a

frame.

Any point, P, can be represented in this frame as some vector displacement

added to the reference point (origin).

P = P 0 + β 1 v 1 + β 2 v 2 + β 3 v 3

P = P 0 +

[

β 1 β 2 β 3

]

v 1

v 2

v 3

Homogeneous coordinates

Homogeneous coordinates

First, let’s define 0 · P = 0 and 1 · P = P.

Then we can write a new representation for the point

P = P 0 + β 1 v 1 + β 2 v 2 + β 3 v 3 in terms of the 4 elements of the frame

P =

[

β 1 β 2 β 3 1

]

v 1

v 2

v 3

P 0

β 1

β 2

β 3

1

T 

v 1

v 2

v 3

P 0

We will call (β 1 , β 2 , β 3 , 1 ) the homogeneous coordinates of the point P.

Usually these coordinates will be represented as a column vector.

Change of coordinate system

Change of coordinate system

Given 2 frames, F 1 = (P 0 , v 1 , v 2 , v 3 )

and F 2 = (Q 0 , u 1 , u 2 , u 3 ), write F 2 in terms of F 1.

Why? Given coordinates of a point in F 1 , we can compute coordinates in F 2.

How? First write the basis vectors of F 2 in terms of the basis vectors of F 1.

u 1 = γ 11 v 1 + γ 12 v 2 + γ 13 v 3

u 2 = γ 21 v 1 + γ 22 v 2 + γ 23 v 3

u 3 = γ 31 v 1 + γ 32 v 2 + γ 33 v 3

Then write Q 0 in terms of frame F 1

Q 0 = P 0 + γ 41 v 1 + γ 42 v 2 + γ 43 v 3

Change of coordinate system

Change of coordinate system

We can write all 4 equations in matrix form

u 1

u 2

u 3

Q 0

γ 11 γ 12 γ 13 0

γ 21 γ 22 γ 23 0

γ 31 γ 32 γ 33 0

γ 41 γ 42 γ 43 1

v 1

v 2

v 3

P 0

We will be using M to denote the 4 × 4 matrix which transforms frame

(P 0 , v 1 , v 2 , v 3 ) into (Q 0 , u 1 , u 2 , u 3 )

M =

γ 11 γ 12 γ 13 0

γ 21 γ 22 γ 23 0

γ 31 γ 32 γ 33 0

γ 41 γ 42 γ 43 1

This is known as an affine transformation matrix.

Change of coordinate system

Change of coordinate system

Since b

T M = a

T and since (b

T M)

T = M

T b we can write

a = M

T b

If matrix M, transforms frame F 1 = (P 0 , v 1 , v 2 , v 3 ) into F 2 = (Q 0 , u 1 , u 2 , u 3 ),

then M

T transforms homogeneous representations in F 2 into representations

in F 1.

We can transform representations in the other direction (F 1 → F 2 ) by

inverting the matrix:

b = (M

T )

− 1 a

Transformations

Transformations

Transformation : a function that takes a point (or vector) and maps it to

another point (or vector)

I (^) T(v) = w

Linear Transformation : Preserves linear combinations

I (^) T(α 1 v 1 + α 2 v 2 ) = α 1 T(v 1 ) + α 2 T(v 2 )

Affine Transformation : Preserves affine combinations

I (^) T(αv 1 + ( 1 − α)v 2 ) = αT(v 1 ) + ( 1 − α)T(v 2 )

Properties:

Every linear transformation is equivalent to a change in frames : we can

perform linear transformations by multiplying homogeneous

representations by a matrix.

Affine transformations preserve lines : this allows us to transform lines

(and planes) by transforming the points on the lines (or planes).

Transformations

Translation

We could use the point-vector addition operation to perform translation of

points:

P

′ = P + d =

Px + dx

Py + dy

Pz + dz

Transformations

Translation

We can also write this as an affine transformation of the homogeneous

representation:

1 0 0 dx

0 1 0 dy

0 0 1 dz

0 0 0 1

Px

Py

Pz

1

Px + dx

Py + dy

Pz + dz

1

Transformations

Scaling

βx 0 0 0

0 βy 0 0

0 0 βz 0

0 0 0 1

Px

Py

Pz

1

βxPx

βyPy

βzPz

1

Properties

The origin is unchanged by a scaling operation.

Independent scaling can be applied along the 3 coordinate axes.

Can also be applied to vectors.