Lecture 27

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 87

Computer

Graphics
Lecture
REVIEW II
Taqdees A.
Siddiqi
cs602@vu.edu.p
k
CLIPPING
Restricting the effect of
graphics primitives to a
sub-region of the canvas
Protecting other portions
of the canvas
Point Clipping
xmin <= x <= xmax

ymin <= y <= ymax


Line Clipping
Clipping of lines against
rectangles:
Trivial Accept
Trivial Reject
Intersecting Lines
The Brute Force
Approach
Intersect that line with
each of the four clip
rectangle edges. if so, the
line cuts the clip rectangle
and is partially inside.
Cohen Sutherland
Line Clipping Algorithm
More efficient;
Performs initial tests on a
line to determine whether
intersection calculations
can be avoided.
Trivial Accept / Reject Test
Liang-Barsky
Algorithm
Faster line clippers
based on analysis of
the parametric
equation of a line
segment:
Conclusion
More efficient;
intersection calculations
are reduced.
Polygon Clipping

A polygon is usually defined by a


sequence of vertices and edges. If
the polygons are un-filled, line-
clipping techniques are sufficient
however, if the polygons are filled,
the process in more complicated.
Polygon clipping - open polygons.
Example
Sutherland-Hodgeman
clipping algorithm

clips any polygon against a


convex clip polygon.
Weiler-Atherton clipping
algorithm

Weiler-Atherton clipping
algorithm clips any polygon
against any clip polygon. The
polygons may even have
holes.
Four Cases of Polygon
Clipping Against One Edge

Case 1 : Wholly inside


visible region save endpoint
Case 2 : Exit visible region -
save the intersection point
Case 3 : Wholly outside
visible region - save nothing
Case 4 : Enter visible region
- save intersection and
endpoint
Weiler-Atherton Polygon Clipping

Sometimes follow the


window boundaries instead
of polygon boundary.
3-Dimensions
In a 3D medium, each of our
eyes views the scene from
slightly different angles. This
is the way we perceive the
real world.
Coordinate Systems
Coordinate systems are the
measured frames of
reference within which
geometry is defined,
manipulated and viewed.
Coordinate Systems
In this system, a point serves
as the origin (reference
point), and three lines (axes)
that pass through this point
and are orthogonal to each
other (at right angles – 90
degrees).
Types of the coordinate
systems
 Following are three types of
the coordinate systems
• 1-D Coordinate System
• 2-D Coordinate System
• 3-D Coordinate System
1-D Coordinate System
2-D Coordinate System
3-D Coordinate System
Left handed versus Right Handed Rules
“Right Hand Rule”
for rotations: grasp
axis with right hand
with thumb oriented
in positive direction,
fingers will then curl
in direction of
positive rotation for
that axis.
Y-up versus Z-up
The Polar
Coordinate System
Is Cartesian system the only
choice? No. We could also
described the object position in
this way: “starting at the origin,
looking east, rotate 38o
northward, 65o upward, and
travel 7.47 feet along this line”.
Modeling
 Modeling is the process of
describing an object or
scene so that we can
construct an image of it
Vectors

Vectors have direction
and magnitude; can also
be thought of as
displacement
Rendering
The process of computing a
2-D image using a combination
of a 3-D database, scene
characteristics, and viewing
transformations.
Various algorithms according
to the needs of the application.
Tessellation
 The subdivision of an entity
or surface into one or more
non-overlapping primitives.
Typically, renderers
decompose surfaces into
triangles as part of the
rendering process.
Level of Detail (LOD)
To improve rendering efficiency when
dynamically viewing a scene, more or
less detailed versions of a model may
be swapped in and out of the scene
database depending on the
importance (usually determined by
image size) of the object in the
current view.
Surface normal
 A vector perpendicular to a
surface and “outward” facing
 Surface normal are used to
determine visibility and also in
the calculation of shading
values
Types of Transformation

 Translation
 Rotation
 Scaling
 Reflection
 Shearing
Now x′ = x + tx , y′ = y + ty
and z′ = z + tz can be expressed as a
single matrix equation:
P′ = P + T
 x x' =  tx 
Where P =  y P′ = T  t 
   y '  y
 z   z '   t z 
Homogeneous
Coordinates
 x'  1 0 0 tx   x
 y '  0 1 0   
t y   y
   .
 z'  0 0 1 tz   z 
    
 1  0 0 0 1   1
Abbreviated as:
P’ = T (tx, ty , tz) . P
 x'  x  t x 
 y '  y  t 
   y

 z'  z  t z 
   
 1  1 
Rotation

Rotation is the process of


moving a point in space in a
non-linear manner
 We need to know three different
angles:
 How far to rotate around the X
axis(YZ rotation, or “pitch”)
 How far to rotate around the Y axis
(XZ rotation, or “yaw”)
 How far to rotate around the Z axis
(XY rotation, or “roll”)
 Column vector representation:
P′ = R . P
 Where

 x'  cos  sin    x


P '   R   P  
 y '  sin  cos   y
Rotation: Homogeneous
Coordinates
The rotation can now be expressed
using homogeneous coordinates as:
 x'  cos  sin  0  x 
 y '  sin  cos 0 . y 
  
 1   0 0 1  1 

Abbreviated as:
P’ = R (θ) . P
… Now in 3D

 Rotation can be about any of the


three axes:
 About z-axis (i.e. in xy plane)
 About x-axis (i.e. in yz plane)
 About y-axis (i.e. in xz plane)
Roll : around z-axis
Pitch: around x-axis
Yaw: around y-axis
 Rotation about z-axis
(i.e. in xy plane):
• x′ = x cosθ – y sinθ
• y′ = x sinθ + y cosθ
• z’ =z
Cyclic permutation
Rotation about x-axis
(i.e. in yz plane):
x′ =x
y′ = y cosθ – z sinθ
z′ = y sinθ + z
cosθ
Rotation about y-axis
(i.e. in xz plane):
x′ = z sinθ + x
cosθ
y′ =y
z′ = z cosθ – x
sinθ
Around arbitrary axis
Around arbitrary axis
Around arbitrary axis
Around arbitrary axis
Around arbitrary axis
 Coordinate transformations for
scaling relative to the origin are
 X` = X . Sx
 Y` = Y . Sy
 Z` = Z . Sz
Uniform Scaling

 We preserve the original shape


of an object with a uniform
scaling

 ( Sx = Sy = Sz)
Differential Scaling

 We do not preserve the original


shape of an object with a
differential scaling

 ( Sx <> Sy <> Sz)


Scaling w.r.t. Origin

 Sx 0 0 0
0 Sy 0 
0

0 0 Sz 0
 
0 0 0 1
Scaling w.r.t. a fixed position

Scaling with respect to a selected


fixed position (Xf,Yf,Zf) can be
represented with the
transformation sequence:
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 or view plane, which
constitutes the display surface
Methods of Projection

1. Parallel Projection
2. Perspective Projection
1. Orthographic
2. Oblique
Here are three orthographic views of an
object.
There are three axonometric
projections:

1. Isometric
2. Dimetric
3. Trimetric
1. Isometric

The projection plane intersects each


coordinate axis in the model coordinate
system at an equal distance or the
direction of projection makes equal
angles with all of the three principal
axes
2. Dimetric

The direction of projection makes


equal angles with exactly two of
the principal axes
3. Trimetric

The direction of projection makes


unequal angles with the three
principal axes
 Xp = x + z ( L1 cos (Ф) )
 Yp = y + z ( L1 sin (Ф) )
Computer
Graphics
Lecture

You might also like