3D Viewing
3D Viewing
Viewing
Dr. S.M. Malaek
Assistant: M. Younesi
3D Viewing
The steps for computer generation of a
view of a three dimensional scene are
somewhat analogous to the processes
involved in taking a photograph.
Camera Analogy
1. Viewing position
2. Camera orientation
3. Size of clipping window
Orientation
Window (aperture)
of the camera
Position
Viewing Pipeline
The general processing steps for modeling and
converting a world coordinate description of a scene to
device coordinates:
Viewing Pipeline
1. Construct the shape of individual objects in a scene
within modeling coordinate, and place the objects into
appropriate positions within the scene (world
coordinate).
Viewing Pipeline
2. World coordinate positions are converted to viewing
coordinates.
Viewing Pipeline
3. Convert the viewing coordinate description of the
scene to coordinate positions on the projection plane.
Viewing Pipeline
4. Positions on the projection plane, will then mapped to
the Normalized coordinate and output device.
Viewing Coordinates
Viewing coordinates
system described 3D
objects with respect to a
viewer.
A Viewing (Projector)
plane is set up
perpendicular to zv and
aligned with (xv,yv).
Camera Analogy
Specifying the Viewing Coordinate
System (View Reference Point)
We first pick a world coordinate position called view
reference point (origin of our viewing coordinate system).
P0 is a point where a camera is located.
The view reference point is often chosen to be close to or on
the surface of some object, or at the center of a group of
objects. y w
zw
P 0
x
w
Position
Specifying the Viewing Coordinate
System (Zv Axis)
Next, we select the positive direction for the viewing zv axis,
by specifying the view plane normal vector, N.
The direction of N, is from the look at point (L) to the view
reference point.
Look
Vector
Specifying the Viewing Coordinate
System (yv Axis)
Finally, we choose the up direction for the view by
specifying a vector V, called the view up vector.
This vector is used to establish the positive direction for the
yv axis.
V is projected into a plane that is perpendicular to the normal
vector.
Up Vector
Look and Up Vectors
the direction the camera is pointing
three degrees of freedom; can be any vector in 3-space
determines how the camera is rotated around the Look
vector
for example, whether you’re holding the camera
horizontally or vertically (or in between)
projection of Up vector must be in the plane perpendicular
to the look vector (this allows Up vector to be specified at
an arbitrary angle to its Look vector)
Projection
of up Up vector
vector Look vector
Position
Specifying the Viewing Coordinate
System (xv Axis)
Using vectors N and V, the graphics package computer can
compute a third vector U, perpendicular to both N and V,
to define the direction for the xv axis.
P0
P0
The View Plane
Graphics package allow users to choose the
position of the view plane along the zv axis by
specifying the view plane distance from the
viewing origin.
M WC ,VC
= R ⋅ R ⋅ R ⋅T
z y z
Transformation from World to
Viewing Coordinates
Another Method for generating the rotation-
transformation matrix is to calculate unit uvn vectors
and form the composite rotation matrix directly:
n=
N
= (n1 , n2 , n3 ) ⎡u1 u2 u3 0⎤
N ⎢v v2 v3 ⎥
0⎥
u=
V×N
= (u1 , u 2 , u 3 ) R=⎢ 1
V×N ⎢n1 n2 n3 0⎥
v = n × u = (v1 , v 2 , v3 )
⎢ ⎥
⎣0 0 0 1⎦
M WC ,VC = R ⋅ T
Projection
Viewing Pipeline
Convert the viewing coordinate description of the scene to
coordinate positions on the projection plane.
Viewing 3D objects on a 2D display requires a mapping
from 3D to 2D.
Projection
Projection can be defined as a mapping of point
P(x,y,z) onto its image P ′( x ′, y ′, z ′) in the projection
plane.
;yyyyyyyy;
y;;;;;;;
;
y;;;;;;;
yyyyyyyy;
;
y;;;;;;;
yyyyyyyy;
x p = x, yp = y
⎡1 0 0 0⎤
⎢0 1 0 0⎥
M =⎢ ⎥
⎢0 0 0 0⎥
Orthographic Parallel
⎢ ⎥
⎣0 0 0 1⎦
Oblique
Parallel Projection
Oblique Parallel Projection
Projection are not perpendicular to the viewing
plane.
Angles and lengths are preserved for faces parallel
the plane of projection.
Preserves 3D nature of an object.
Oblique
Parallel Projection
Transformation
Oblique Parallel Projection
Transformation
Convert the viewing coordinate description of the
scene to coordinate positions on the Oblique parallel
projection plane.
Oblique Parallel Projection
Point (x,y,z) is projected to position (xp,yp) on the view plane.
Projector (oblique) from (x,y,z) to (xp,yp) makes an angle α
with the line (L) on the projection plane that joins (xp,yp) and
(x,y).
Line L is at an angle φ with the horizontal direction in the
projection plane.
Oblique Parallel Projection
x p = x + L cos φ
y p = y + L sin φ
z
z L=
tan α = tan α
L
= zL1
x p = x + z ( L1 cos φ)
y p = y + z ( L1 sin φ)
L
⎡1 0 L1 cosφ 0⎤
⎢0 ⎥
1 L1 sin φ 0⎥
M Parallel = ⎢
⎢0 0 0 0⎥
⎢ ⎥
⎣0 0 0 1⎦
Oblique Parallel Projection
Orthographic Projection:
L1 = 0
α = 90 o
x p = x, yp = y
L
⎡1 0 0 0⎤
⎢0 1 0 0 ⎥
M =⎢ ⎥
⎢0 0 0 0⎥
Orthographic Parallel
⎢ ⎥
⎣0 0 0 1⎦
Oblique Parallel Projection
Angles, distances, and parallel
lines in the plane are projected
accurately.
Cavalier Projection
Cavalier Projection:
φ = 30 o
and 45 o
tan α = 1
α = 45 o
Cavalier Cabinet
Perspective Projection
Perspective Projection
Perspective Projection
In a perspective projection, the center of projection is
at a finite distance from the viewing plane.
Produces realistic views but does not preserve
relative proportion of objects
The size of a projection object is inversely
proportional to its distance from the viewing plane.
Perspective Projection
Parallel lines that are not parallel to the viewing
plane, converge to a vanishing point.
A vanishing point is the projection of a point at
infinity.
Vanishing Points
Each set of projected parallel lines will have a
separate vanishing points.
There are infinity many general vanishing points.
Perspective Projection
The vanishing point for any set of lines that are parallel to
one of the principal axes of an object is referred to as a
principal vanishing point.
We control the number of principal vanishing points (one,
two, or three) with the orientation of the projection plane.
Perspective Projection
The number of principal vanishing
points in a projection is determined by
the number of principal axes
intersecting the view plane.
Perspective Projection
z x
x
x
z
z
z′ = z − (z − z prp
)u
Perspective Projection Transformation
x ′ = x − xu
On the view plane: z ′ = z vp y ′ = y − yu
z −z z′ = z − (z − z )u
u=
prp
vp
z −z prp
d p = z prp − z vp
⎛z −z ⎞ ⎛ d ⎞
x = x⎜⎜ prp vp
⎟ = x⎜
⎟ ⎜z−z
p
⎟
⎟
⎝ z−z
p
prp ⎠ ⎝ prp ⎠
⎛z −z ⎞ ⎛ d ⎞
y = y⎜⎜ prp vp
⎟ = y⎜
⎟ ⎜z−z
p
⎟
⎟
⎝ z−z
p
prp ⎠ ⎝ prp ⎠
Perspective Projection Transformation
On the view plane: z ′ = z vp ⎛z −z ⎞
⎜ ⎟
⎛ d ⎞
x = x⎜prp
⎟ = x⎜⎜
vp p
⎟
⎟
⎝ z−z ⎠ ⎝z−z
p
prp prp ⎠
⎡xh ⎤ ⎡1 0 0 0 ⎤ ⎡x⎤ ⎛z −z ⎞ ⎛ d ⎞
⎢y ⎥ ⎢0 ⎥⎢ ⎥ y = y⎜⎜ ⎟ = y⎜ ⎟
prp vp p
1 0 0 ⎟ ⎜ ⎟
⎝ z−z ⎠ ⎝z−z
p
⎠
⎢ h⎥ = ⎢ ⎥ ⋅ ⎢y⎥ prp prp
z − z prp
h=
dp
x p = xh h , y p = yh h
Perspective Projection Transformation
Special Cases: z vp = 0 ⎛z −z
x = x⎜⎜
prp vp
⎞ ⎛ d
⎟ = x⎜ p
⎞
⎟
⎟ ⎜z−z ⎟
⎝ z−z
p
prp ⎠ ⎝ prp ⎠
⎛ z prp ⎞ ⎛ 1 ⎞ ⎛z −z ⎞ ⎛ d ⎞
x p = x⎜ ⎟ = x⎜ ⎟ y = y⎜⎜ ⎟ = y⎜ ⎟
prp vp p
⎠ ⎝ ⎠
⎝ ⎠ ⎝ ⎠
prp prp
prp prp
⎛ z prp ⎞ ⎛ 1 ⎞
y p = y⎜ ⎟ = y⎜ ⎟
⎜z−z ⎟ ⎜ z z −1⎟
⎝ prp ⎠ ⎝ prp ⎠
Perspective Projection Transformation
Special Cases: The projection ⎛z −z ⎞ ⎛ d ⎞
x = x⎜⎜
prp vp
⎟ = x⎜
⎟ ⎜z−z
p
⎟
⎟
⎝ z−z
p
⎛ − zvp ⎞ ⎛ − 1 ⎞
x p = x⎜⎜ ⎟⎟ = x⎜ ⎟
⎜ ⎟
⎝ z ⎠ ⎝ z zvp ⎠
⎛ − zvp ⎞ ⎛ − 1 ⎞
y p = y⎜⎜ ⎟⎟ = y⎜ ⎟
⎜ ⎟
⎝ z ⎠ ⎝ z zvp ⎠
Zprp=0
Summery
Summary