Docsity

3-D Transforms: Extending 2-D Techniques to Three Dimensions, Study notes of Computer Graphics

Toggle sidebar
bg1
Today: 3-D Transforms
Last time, we developed 2-D transformations
But we’re mainly interested in 3-D graphics
So today, we’ll extend these tools to 3-D
An Alternative View of Transformations
Can be thought of as mapping points to new locations
• this is the basis of the presentation from last time
Can also be thought of as a change of coordinate system
• vectors are specified as a linear combination of basis vectors
• for instance, in 2-D:
• transformed vector is similar combination of transformed basis
This is frequently a useful approach
to understanding transformations
p
p
11 2 2
=+pe e
e
1
e
2
'' '
p
p
11 2 2
=+pe e
e′
1
e′
2
Scaling & Translation in 3-D
Looks pretty much the same as in 2-D
• just add on the zdimension to everything
Unfortunately, rotation is not so simple …
r
s
t
000


000

=
00 0

0001

S
x
y
z
100∆


0
10∆

=
0
01∆

0
00 1

T
Scaling
Translation
Rotation About Coordinate Axes
Looks pretty similar to 2-D case
Specify rotation as 3 angles
• one per coordinate axis
• these are called Euler angles
• fairly widely used
Drawback 1: Result is order dependent
• suppose we rotate about xthen y
•yrotation is about transformed axis after
xrotation is performed
• this gets confusing
Drawback 2: Difficult to interpolate
• for animation want to interpolate angles
• resulting motion can be weird
cos sin
sin cos
x
θθ
θθ
10 0 0


0−0

=
00

00 0 1

R
cos sin
sin cos
z
θ
θ
θθ
−00


00

=
0010

0001

R
cos sin
sin cos
y
θ
θ
θθ
00


0100

=
−0 0

0001

R
pf3
pf4

Partial preview of the text

Download 3-D Transforms: Extending 2-D Techniques to Three Dimensions and more Study notes Computer Graphics in PDF only on Docsity!

Today: 3-D Transforms Last time, we developed 2-D transformationsBut we’re mainly interested in 3-D graphicsSo today, we’ll extend these tools to 3-D

An Alternative View of Transformations Can be thought of as mapping points to new locations^ • this is the basis of the presentation from last time Can also be thought of as a change of coordinate system^ • vectors are specified as a linear combination of basis vectors• for instance, in 2-D:• transformed vector is similar combination of transformed basis This is frequently a useful approachto understanding transformations

p^

p 1 1 2 2 =^

p^

e^

e

e^1 e^2

'^

'^

p^

p 1 1

2 2 =^

p^

e^

e

e ′^1 e ′^2

Scaling & Translation in 3-D Looks pretty much the same as in 2-D^ • just add on the

z^ dimension to everything

Unfortunately, rotation is not so simple …

r s 0 0 0 t ^

^

^

= ^

^

^

S

x y z 1 0

^

^

^

= ^

^

^

T

Scaling Translation

Rotation About Coordinate Axes Looks pretty similar to 2-D caseSpecify rotation as 3 angles^ • one per coordinate axis• these are called Euler angles• fairly widely used Drawback 1: Result is order

dependent

  • suppose we rotate about

x^ then

y

-^ y^ rotation is about transformed axis after^ x^ rotation is performed• this gets confusing Drawback 2: Difficult to interpolate • for animation want to interpolate angles• resulting motion can be

weird

cos^

sin sin^

cos x

θ^

θ θ^

θ 1 0

^

^

−^

^

= ^

^

^

R

cos^

sin sin^

cos z

θ^

θ θ^ −^0 θ

^

^

^

= ^

^

R

cos^

sin sin^

cos y

θ

θ θ

θ 0

^

^

^

= ^

−^

^

^

R

Some Mathematical Definitions The dual matrix of a vector u^ • can write vector cross product

u × v^

as matrix multiply

∗ uv

The outer product of a vector

u^ (with itself)

z^ y z^

x 0 − y^ x

^

=^

^

^

−^

^

u

[^

]

x T

x^ xy

xz

y^ x^

y^ z^

xy^ y

yz

z^

xz^ yz

z 2 2

2 ^

^ ^

^

^ =

= ^

^ ^

^

^ ^ ^

^

uu

Rotation About Arbitrary Axis Let’s suppose we have a unit direction vectorWe can derive a rotation by a given angle about this axisThis is the approach used by OpenGL — glRotatef(

θ ,^ x ,^ y

,^ z )

Has many of the same interpolation problems as Euler angles

x^ where y^

x^ y

z

z

2 2

2

^ ^ =

+^ +

u ^  ^ ^ 

T^

T^

( ,^ )

cos^ (

)^ (sin

θ

θ

θ

=^

+^

−^

R^ u

uu

I^ uu

u

Quaternions Complex numbersQuaternions are essentially generalized complex numbers^ • a scalar part + a vector part — 1 real and 3 imaginary parts• norm • basic quaternion operation is multiplication

,^

c^ a

b = +^

i^ i

=^

=^

+^ +

x y z ]) =

( ,^ )

( , [

q^

s^

s^

s^ x^

y^ z

v^

i^ j

k

=^ +

+^

+^

+^

+^

=^

−^ ⋅^

×^ +

'^ (^

)( '^

'^

'^

'^ )

(^ '^

',^

'^

'^ '^

qq^

s^ x^

y^

s^ x

ss^

s^

s

i^ j

zk

i^ y j

z k

v v^

v^ v

v

v

2

2

2

2

||^ || q^

w^

x^

y^

z

=^

+^

+^

1,^

,^

=^ =

=^

=^

2 2

2

i^ j

k^

ij^ k

jk^

i^ ki

j

Quaternions (continued)^ ConjugateInversion We’re interested in the class of unit quaternions^ • forms a unit sphere in 4-D space• can be used to represent the set of rotations• forms a group with multiplication as the operation

=^

−^ =

−^

−^ −

( ,^

q^

s^

s^ x

y^

z

v^

i^ i

k

q

q^

q

−

2

= q qq^

s

2

2 2

=^

=^ +

= 1 v

Transformation of Normal Vectors A plane in 3-D space is described by the homogeneous vector^ • thus any point

v^ on the plane satisfies the equation

For any 4x4 matrix whose inverse exists, this is equivalent to^ • thus the transformed point

Mv^ lies on the plane

T nM

    • it’s plane vector is (

T-1 nM T^ ) or (

-1T M ) n

This gives us the transformation rule for normal vectors

where

is the plane equation

a b c d

ax^ by

cz^

d

=^

+^ +

+^

n^ T^ = 0 n v^ T^

−^

n M^

Mv^ T−1 ( )→ n^

M^

n

Transformation of Normal Vectors Must in general compute actual local plane^ • however, there are some simpler cases Simplified case #1: Affine Transformations^ • map parallel planes to parallel planes• thus, can pick any value of

d^ — might as well be 0

Simplified case #2: Orthogonal (Rigid-Body) Transformations^ • in this case (e.g., rotation)• thus the normal transformation rule becomes

where

is the plane equation

a b c d

ax^ by

cz^

d

=^

+^ +

+^

n

T −1^ = M M

→ n Mn

Beyond Linear Transformations There are of course more general kinds of transformations^ • in general, any function mapping points to new locations• for instance, might want to twist an object• the downside: must transform all points individually Free-form deformations common in production software^ • define a 3-D grid of control points• use grid points to control Bézier cubic splines within cells• obviously much more complex than single matrices For us, affine transforms are (generally) good enough