2D, 3D Clipping: Soon Tee Teoh CS 116A
2D, 3D Clipping: Soon Tee Teoh CS 116A
4 3 2 1
v1’ v1”
v3’
v3 v3”
v2 v2
v2 v2 v2 v2
v1’ v1’
v1 v1
v1 v1
v1’
v3’
Left Right Bottom Top
v1 Clipper Clipper Clipper Clipper
Sutherland-Hodgman
Weiler-Atherton
Clipping in 3D
• Suppose the view volume has been
normalized. Then the clipping boundaries
are just:
xwmin = -1 xwmax = 1
ywmin = -1 ywmax = 1
zwmin = -1 zwmax = 1
Clipping Homogeneous
Coordinates in 3D
• Coordinates expressed in homogeneous
coordinates
• After geometric, viewing and projection
transformations, each vertex is: (xh, yh, zh, h)
• Therefore, assuming coordinates have been
normalized to a (-1,1) volume, a point (xh, yh, zh, h) is
inside the view volume if:
xh yh zh
-1 < <1 and -1 < <1 and -1 < <1
h h h
4 3 2 1
6 5 4 3 2 1
This is because if -h > xh, then the point is to the left of the viewing volume.
Clipping Polygons
• First, perform trivial acceptance and
rejection using, for example, its coordinate
extents.
• Polygons usually split into triangle strips.
• Then each triangle is clipped using 3D
extension of the Sutherland-Hodgman
method
Arbitrary Clipping Planes
• Can specify an arbitrary clipping plane: Ax + By
+ Cz + D = 0.
• Therefore, for any point, if Ax + By + Cz + D < 0,
it is not shown.
• To clip a line against an arbitrary plane,
– If both end-points are in, then the line is in
– If both end-points are out, then the line is out
– If one end-point is in, and one is out, then we need to
find the intersection of the line and the plane
Intersection of Line and Plane
• First, given two end-points of a line, P1 and
P2, form a parametric representation of the
line:
P = P1 + (P2 – P1) u, where 0<u<1
– D – N.P1
u=
N . (P2 – P1)