Vous êtes sur la page 1sur 13

3D Geometric

Transformation
(Chapt. 5 in FVD, Chapt. 11 in Hearn & Baker)

3D Coordinate Systems
• Right-handed coordinate system:
z

y
x
• Left-handed coordinate system:
y

z
x
Reminder: Vector Product

UxV

q
U

VxU

U ´ V = nˆ U V sin

xˆ yˆ zˆ éu y v z - u z v y ù
ê ú
U ´V = u x uy u z = ê u z vx - u xv z ú
vx vy v z êë u x v y -u y v x úû

3D Point
• A 3D point P is represented in
homogeneous coordinates by a
4-dim. vector:
é xù
ê yú
P=ê ú
êzú
ê ú
ë1û

• Note, that

é x ù é xù
ê ú ê ú
y y
p=ê úºê ú
ê z ú ê zú
ê ú ê ú
ë1 û ë û
3D Transformations

• In homogeneous coordinates, 3D
transformations are represented by
4x4 matrices:
éa b c tx ù
êd e f ú
ty ú
ê
êg h i tz ú
ê ú
ë0 0 0 1û
• A point transformation is
performed:
é x'ù é a b c tx ùéxù
ê ú êd e f t y úú êê y úú
ê y 'ú = ê
ê z 'ú ê g h i tz úê z ú
ê ú ê úê ú
ë 1 û ë0 0 0 1 û ë1 û

3D Translation
• P in translated to P' by:
é1 0 0 t x ù é x ù é x 'ù é x + t x ù
ê0 1 0 t y úú êê y úú êê y 'úú êê y + t y úú
ê = =
ê0 0 1 t z ú ê z ú ê z'ú ê z + t z ú
ê úê ú ê ú ê ú
ë0 0 0 1 û ë1 û ë 1 û ë 1 û

Or T P = P'
z

y
x
-1
• Inverse translation: T P' = P
Scaling
éa 0 0 0ù é x ù é x ' ù é ax ù
ê0 b 0 0úú êê y úú êê y 'úú êêby úú
ê = =
ê0 0 c 0ú ê z ú ê z ' ú ê cz ú
ê úê ú ê ú ê ú
ë0 0 0 1û ë 1 û ë 1 û ë 1 û

Or S P = P'

z z

y y
x x

-1
S P' = P

3D Shearing
• Shearing:
é1 a b 0ù é x ù é x + ay + bz ù
êc úê ú ê ú
ê 1 d 0ú ê y ú êcx + y + dz ú
=
êe f 1 0ú ê z ú ê ex + fy + z ú
ê úê ú ê ú
ë0 0 0 1û ë 1 û ë 1 û
• The change in each coordinate
is a linear combination of all
three.
• Transforms a cube into a
general parallelepiped.
3D Rotation
• To generate a rotation in 3D we
have to specify:
– axis of rotation (2 d.o.f)
– amount of rotation (1 d.o.f)
• Note, the axis passes through the
origin.

z
x

• A counter-clockwise rotation
about the z-axis:

é x'ù écos - sin 0 0ù é x ù


ê y 'ú ê sin cos 0 0úú êê y úú
ê ú=ê
ê z'ú ê 0 0 1 0ú ê z ú
ê ú ê úê ú
ë1 û ë 0 0 0 1û ë 1 û

p' = Rz ( ) p

y
x
• A counter-clockwise rotation
about the x-axis:

é x ' ù é1 0 0 0ù é x ù
ê y'ú ê0 cos - sin 0úú êê y úú
ê ú=ê
ê z ' ú ê0 sin cos 0ú ê z ú
ê ú ê úê ú
ë 1 û ë0 0 0 1û ë 1 û

p' = Rx ( ) p

y
x

• A counter-clockwise rotation
about the y-axis:

é x'ù é cos 0 sin 0ù é x ù


ê y'ú ê 0 1 0 0úú êê y úú
ê ú=ê
ê z ' ú ê - sin 0 cos 0ú ê z ú
ê ú ê úê ú
ë1û ë 0 0 0 1û ë 1 û

p' = R y ( ) p

y
x
Inverse Rotation
-1
p = R ( ) p' = R(- ) p'

Composite Rotations
• Rx, Ry, and Rz, can perform any
rotation about an axis passing
through the origin.

Rotation About an
Arbitrary Axis
• Axis of rotation can be located at
any point: 6 d.o.f.
• The idea: make the axis
coincident with one of the
coordinate axes (z axis), rotate,
and then transform back.
• Assume that the axis passes
through the point p0.
z
p0

y
x
• Transformations:
– Translate P0 to the origin.
– Make the axis coincident with the
z-axis (for example):
• Rotate about the x-axis into the
xz plane.
• Rotate about the y-axis onto
the z-axis.
• Rotate as needed about the z-
axis.
• Apply inverse rotations about y
and x.
• Apply inverse translation.

y y
A
p0 D p0
x
x z
z

y
y
E
p0
B p0
x
x z
z

y y

C p0 F p0

x x
z z
3D Reflection
• A reflection through the xy plane:

é1 0 0 0ù é x ù é x ù
ê0 1 0 ú ê ú ê
0ú ê y ú ê y úú
ê =
ê0 0 -1 0ú ê z ú ê- z ú
ê úê ú ê ú
ë0 0 0 0û ë 1 û ë 1 û

• Reflections through the xz and the


yz planes are defined similarly.
• How can we reflect through some
arbitrary plane?

Transforming Planes
• Plane representation:
– By three non-collinear points
– By implicit equation:
é xù
ê yú
Ax + By + Cz + D = A B C D ê ú = 0
êzú
ê ú
ë1 û

éA B C ù
êD 1ú
ë D D û

P1
P2

x y z 1
P0
• One way to transform a plane is
by transforming any three non-
collinear points on the plane.
• Another way is to transform the
plane equation: Given a
transformation T that
transforms [x,y,z,1] to [x',y',z',1]
find [A',B',C',D'], such that:

é x'ù
ê y 'ú
A' B ' C ' D ' ê ú = 0
ê z 'ú
ê ú
ë1û

• Note that
éxù
ê yú
A B C D T -1T ê ú = 0
êzú
ê ú
ë1 û

• Thus, the transformation that


we should apply to the plane
equation is:

é A' ù é Aù
ê B'ú êBú
ê ú = T -1 T
ê ú
êC 'ú êC ú
ê ú ê ú
ë D'û ëDû
Changing Coordinate
Systems
• Problem: Given the XYZ
orthogonal coordinate system,
find a transformation, M, that
maps XYZ to an arbitrary
orthogonal system UVW.
• This transformation changes a
representation from the UVW
system to the XYZ system.
w=(wx,wy,wz)
z

(x0,y0,z0)
u=(ux,uy,uz)
y
x
v=(vx,vy,vz)

• Solution: M=RT where T is a


translation matrix by (x0,y0,z0), and
R is rotation matrix whose columns
are U,V, and W:

éu x vx wx 0ù
êu vy wy ú

R= ê y
êu z vz wz 0ú
ê ú
ë0 0 0 1û

because

éu x vx wx 0ù é1 ù éu x ù
êu vy wy ú ê ú ê
0ú ê0 ú êu y ú ú
RX = ê y
= =U
êu z vz wz 0 ú ê0 ú ê u z ú
ê úê ú ê ú
ë0 0 0 1û ë1 û ë 1 û
• Similarly, Y goes into V, and Z
goes into W.
• The inverse transform, T-1R-1,
provides the mapping from
UVW back to XYZ. For the
rotation matrix R-1=RT:

éux uy uz 0 ù éu x ù
ê úê ú
ê vx vy vz 0ú êu y ú
R U=
T
ê wx wy wz 0ú ê u z ú
ê úê ú
ë0 0 0 1û ë 1 û
éu x2 + u 2y + u z2 ù é1ù
ê ú ê ú
ê 0 ú ê 0ú
= = =X
ê 0 ú ê0 ú
ê ú ê ú
êë 1 úû ë1û

• Comment: Very useful if an


arbitrary plane is to be mapped
to the XY plane or vice versa.
• Possible to apply if an arbitrary
vector is to be mapped to an
axis (How?).
Transformation Pipe-Line
Modeling
Coordinates

Modeling
Transformation

World Coordinates

Viewing
Transformation

Viewing Coordinates

Projection
Transformation

Projection Coordinates

Workstation
Transformation

Device Coordinates

Modeling Coordinate
Hierarchy zw
world

yw
xw
Tractor
System

Front-Wheel
System

World
transformation
Tractor

transformation

Front-wheel

Vous aimerez peut-être aussi