You are on page 1of 31

5.

1 3D Coordinates System

Right-handed Coordinates System


Y X

Y X

X Y

Left-handed Coordinates System


X
Y Y
X
X
Y

We will use vight-handed Coordinates


System in our class.

CG Page: 1 東吳資訊科學 江清水


5.2 3D Geometry

We can use the way to represent 3D points


and polyhedras as the way to represent 2D
points and polygons. For example:
Y

(0,2,0)

(0,0,0)
X
(3,0,0)
(0,0,1)

Z
0 0 0

[ ] 3
0
0
0
2
0
0
0
1
represents a tetrahedron

In homogenlous coordinates system

represents the same tetrahedron

CG Page: 2 東吳資訊科學 江清水


5.3 3D Transformations

Let's discuss 3D transformations, going


directly to matrix and functional fo
rms:
(1) Translation:

[x' y' z' 1] = [x y z 1] * [ ]


(2) Scaling:

[x' y' z' 1] = [x y z 1] * [ ]


(3) Rotation:
• Rotating about X(Y or Z) does not change X'
s.
• The value of Y' and Z' does not depend on X.
• Row 4 and column 4 are always the same.
• The problem is to locate sin, -sin and cos.

CG Page: 3 東吳資訊科學 江清水


(a) Rotate about Z:

Y
X
Z
Eye

[ ]
cos sin 0
-sin cos 0
[y' z' 1] = [y z 1] * 0 0 1

cos sin 0 0

[x' y' z' 1] = [x y z 1] * [ -sin cos 0


0
0
0
0
1
0
0
0
1
]
(b) Rotate about Y:
Y X
Z
X
Z

CG Page: 4 東吳資訊科學 江清水


[ ]
cos sin 0
-sincos 0
[z' x' 1] = [z x 1] * 0 0 1

[x' z' 1] = [x z 1] *[ ]
cos -sin 0
sincos 0
0 0 1

cos 0 -sin 0

[x' y' z' 1] = [x y z 1] * [ 0 1 0 0


sin 0 cos 0
0 0 0 1
]
(c) Rotate about X:

Y
X
Z

[ ]
cos sin 0
-sin cos 0
[y' z' 1] = [y z 1] * 0 0 1

1 0 0 0

[x' y' z' 1] = [x y z 1] * [ 0 cos sin 0


0 -sin cos 0
0 0 0 1
]

CG Page: 5 東吳資訊科學 江清水


Homework:
Rotate the block counterwisely 
degree about X, Y, Z axis respectively.
Find new coordinate for each vertex.

Y Rotate Y
about
(0,3,0) X

(1,0,0) X
X
(0,0,2)
Rotate Z
Z about
Y

Y Rotate Y
about
Z

X X

Z Z

CG Page: 6 東吳資訊科學 江清水


6.1 Projection

Different eye position has different


view.

CG Page: 7 東吳資訊科學 江清水


After the projection, the distance b
etween your eyes and the object ve
rtices is unknown.

With the help of


hidden-line removal
algorithm, you
can know which
vertex is closer to
you.

CG Page: 8 東吳資訊科學 江清水


Orthgraphic Parallel Projections vs.
Perspective Projections
Orthgraphic Parallel Projections:
The center of projection is located at infinity
and the projectors are prependicular to
the projection plane .

Perspective projections:
The center of projection is located at a finite
distance from the projection plane.

CG Page: 9 東吳資訊科學 江清水


Orthgraphic parallel Projection :
Y
[x,y,z]

[x,y,0]

Projection Plane : XY-Plane (Z=0)


Projector : parallel to Z axis
The Problem for finding projection point
are simple:
project to [ x y 0 ] [ x y z ] will

CG Page: 10 東吳資訊科學 江清水


Perspective Projection :

How to get a picture?


(1) Freeze the scene.
(2) Freeze you head (eyes).

Perspective:

CG Page: 11 東吳資訊科學 江清水


What information we need to project
a picture into a projection plane via
perspective projection?
(1) eye position
(2) object position
(3) picture plane
Anything else?
(4) Up direction

CG Page: 12 東吳資訊科學 江清水



Y

[] [] []
0 1 1
1 0 1
Up1 = 0 Up2 = 0 Up3 = 0

CG Page: 13 東吳資訊科學 江清水


Consider the eye coordinate system:

Ye
[x y z]

[xp yp 0]
Xe

Ze [0 0 d] = Eye Position
Projection plane: XY-plane (Z=0)
Eye position: [0 0 d]
Projector: the line from [x y z] to a
given eye position.
The problem for finding projection point b
ecomes:
Find the intersection point for
projcetion plane and projector.

CG Page: 14 東吳資訊科學 江清水


(1) Look alone the -Xe direction:
Ye
Ye
[x y z]
(x,y,z)
[xp yp 0]
Xe
Ze [0 0 d] = Eye Position
y
yp
Ze d -z
yp : y = d : d-z
(2) Look yalone
p= (d/(d-z))
the -Y*e direction:
y

x
Ye
(x,y,z)
[x y z]
-z xp
[xp yp 0]
Xe Xe
Ze [0 0 d] = Eye Position
d

Ze
xp : x = d : d-z
xp= (d/(d-z)) * x

CG Page: 15 東吳資訊科學 江清水


(3) Represented in matrix form :
xp = (d/(d-z)) * x
yp= (d/(d-z)) * y

[ ]
d/(d-z) 0 0 0
0 d/(d-z) 0 0

[xp yp 0 1]=[x y z 1] 0
0
0
0
0 0
0 1

In homogeneous coordinates system, the


points [ x y z 1] and [wx wy wz w] (w0)
represents the same points. So, the point

[xp yp 0 1] = [dx/(d-z) dy/(d-z) 0 1]


= [x y 0 1-(z/d)]
1 0 0 0

=[x y z 1][ 0
0
0
1
0
0
0 0

]
0 -1/d
0 1

CG Page: 16 東吳資訊科學 江清水


(4) Questions :
(a) How to draw a 3D line into the

Y picture
[x y z ]
t t plane ?
t

[x't y't 0] 
[xf yf zf]
[x'f y'f 0]
X
Z

 
(b) What happens when Z

 
(c) What about d

CG Page: 17 東吳資訊科學 江清水


Exercise:

(1) Draw The rectangle whose vertices are
P=(10,10,-10), Q=(-10,10,-10)
R=(-10,10,10), S=(10,10,10) and XY
plane is projection plane, (0,0,15) is the
Y
eye position.
Y
Q 1
P
2
4 X
R S
3

..
X

.
(0,0,5)
Z
(0,0,15)

CG Page: 18 東吳資訊科學 江清水


(2) Move
 your eye from (0,0,15) to ((0,0,15),
what you will see?
Y
Y
1
Q P
2
4
R S
3

..
X X

.
(0,0,5)
Z
(0,0,15)

CG Page: 19 東吳資訊科學 江清水


(d) How about z > d (i.e., point is
behind the eye) ?

X
Z

(e) How about z d (i.e., point is


near the eye) ?

Y Y

X X
Z Z

CG Page: 20 東吳資訊科學 江清水


6.2 View Transformation

In general, we may want to observe


object from some other position (in
stead of (0,0,d)) and direction (in
stead of - Ze), say from point (xf , yf
,zf ) to point (xt ,yt ,zt ).

Yw (Xf ,Yf ,Zf )

view
(Xt ,Yt ,Zt ) vector
Xw
world
data
representing
object
ZwNotice that the world data and view v
ector now are given in world coordi
nates, not eye coordinates.

CG Page: 21 東吳資訊科學 江清水


We must transform the object data
from world coordinates into eye
coordinates before we can perform
orthographic parallel or perspective
projection . This transformation
called viewing transformation.

Where is the eye coordinate system?

Yw Ye
Xe
Ze

Xw
world
data
We make the arbitrary Ye (Up
Zw direction) which perpedicular to Ze

CG Page: 22 東吳資訊科學 江清水


We want a "neat" viewing
transformation, V, such that
[xe ye ze 1] = [xw yw zw 1] * V i.e.,
multiply all world points by V and
it will be just as if the eye was at
(0,0,d) or (0,0,),
 depend on
perspeative or orthographic parallel
projection, looking at (0,0,0).
Visualize the process as transforming
the Ze and Ye axes to Zw and Yw
axes. This is accomplished using
four basic transformations:
1. Translate the vector so that
(xt , yt , zt ) = (0, 0, 0).
2. Rotate the result so that the
transformed (xf , yf , zf )' swings
into the Yw-Zw plane.
3. Rotate the result so that (xf , yf
, zf )'' swings down onto the Zw
axis.
4. Rotate this result so that Ye
swings down onto the Yw axis.

CG Page: 23 東吳資訊科學 江清水


Step 1. The first step is just a
simple translation.

Yw

Ye
Xe
Ze
Xw

Zw
T1 =

= [ ]

CG Page: 24 東吳資訊科學 江清水


Step 2. Rotate  degrees about Yw t
o swing eye' into the Yw-Zw plane.
tan(2- =X'/Z'=tan(- 
 =
Check the sign (check rotation direc
tion)

Step 3. Swing eye'' down by  degr


ees to (0,0,d) by rotating eye'' abo
ut Xw.
 =
Yw

eye'' eye'
 Xw

Zw

CG Page: 25 東吳資訊科學 江清水


Now, the eye coordinate system and
world coordinate system are show
n in the following picture.

Yw

Ye
 Xe

Xw

Ze
Zw

Step 4. Rotate Xe about Zw  degrees.


(asswne Xe = (X3, Y3, 0))
 = -tan-1 Y'/X'

CG Page: 26 東吳資訊科學 江清水


Our transformation equation becomes:
[xe ye ze 1] = [xw yw zw 1] T1 R2 R3 R4

To check your transformatios, try:


eye = (0,1,0)
Yw
aim = (0,0,0) (0,1,0) w

Ye = (1,0,0)
Xw
(1,0,0)w
(0,0,1)w
Zw

Ze

Ye

Xe

CG Page: 27 東吳資訊科學 江清水


Homework:
Try again with Ye = (0,0,1) and
other values are the same.

Yw

(0,1,0)w 
(0,0,1)e

(0,0,0)w 
(0,0,0)e
Xw
(1,0,0)w 
(-1,0,0) e

(0,0,1)w 
(0,1,0)e

Zw

CG Page: 28 東吳資訊科學 江清水


6.3 View Volume
We saw that as z -> d, severe distortion occu
res, like a "fisheye" lens. Also, data far fr
om the observer (z << 0) becomes dots!
To eliminate these effects, we'll introduce two
clipping planes, parallel to the X e-Ye plane
:
(1) A front clipping plane at z=zfront
(2) A back clipping plane at z=zback

Ye

Back
Clipping
Plane

Xe
ZThis
e
creates a viewing volume, which is aPlane
Projection pyra
mid, and is now aFront
6-sided frustum.
Clipping Plane

CG Page: 29 東吳資訊科學 江清水


6.3 Z-Clipping

Now the full clipping procedure becomes


:
(1) Clip on front and back planes.
(2) Perspective projection to 2D
window.
(3) Clip on the 2D window.
To determine the visibility of a point P(x
,y,z), just test its z value:
If ((z > zfront) or (z<zback)) then
"Invisible", else "Visible".
(1) Under what conditions that a line
segment will not be clipped?
P1 = (X1, Y1, Z1) P2 = (X2, Y2, Z2)
Zback Z1, Z2 Zfront
(2) How to clip a line segment using
Z-clipping?
(1) Z = Z1 + (Z2-Z1)t
(2)replace Z = Zfront or Zend , find t
(3)find (X Y Z) =
(X1 Y1 Z1) + t(X2-X1, Y2-Y1, Z2-Z1)

CG Page: 30 東吳資訊科學 江清水


Three types of perspective
projections:
(1) one-point

(2) two-point

(3) three-point

CG Page: 31 東吳資訊科學 江清水

You might also like