Discussion Section 8 - Clipping
Overview
These are the issues discussed in this discussion section:
- What is clipping?
- Why do we do clipping?
- What if clipping isn't enough?
- How is the visible region defined?
- What What is a line in RN?
- What utilities do we need to do Line/Polygon clipping?
- Inside-p
- Intersect
1. What is clipping?
Clipping is the removal of some geometry from our system (typically that
we wouldn't see anyway) prior to rendering.
2. Why do we do clipping?
- Speed
- To prevent drawing hardware overflow and "screen scribbling"
- To remove objects behind our eye
3 What if clipping isn't enough? (research question)
There are times when clipping just isn't enough. Two recent Berkeley Ph.D.
students, Tom Funkhouser (now at Bell Labs) and Seth
Teller (now at MIT) worked on this problem for their doctorates in recent
years. Imagine if you have a database of geometry describing, say, Soda
Hall which is in the order of 10s of Mb. Not only can you not store
the whole geometry in main memory, but you can't even pipe the whole thing
through your clipping algorithms fast enough that you can guarantee
a frame rate of 10fps. Using techniques such as pre-fetching, pre-processed
adjacency and visibility graphs and stabbing lines you can "clip"
away enough geometry to achieve interactive frame rates before you even
get to your clipping algorithms.
4. How is the visible region defined?
The visible region is defined as the intersection of half-spaces in whatever
dimension you are in. A half-space is a geometric entity that cuts space
in half. In R2 it is a line. Normally we define a line as:
Ax + By + C = 0
But that only defines the locus of points that are on
the line. What if we want the locus of points that are one one side of the
line?
Ax + By + C < 0
or
Ax + By + C > 0
Do we want to include the line? In most cases we do, so we end up with
the formal definition in R2 as:
Ax + By + C ¾ 0
In R3 our halfspace is a plane. We define a plane as:
Ax + By + Cz + D = 0
And make similar arguments about the need for an inequality as in R3
resulting in our formal definition of a halfspace in R3.
Ax + By + Cz + D ¾ 0
You can see how this trivially extends to RN.
5. What is a line in RN?
The parametric definition of a line, we'll remember is:
P(t) = P0 * (1 - t) + P1 * t
Note that our two endpoints P0 and P1 are defined
in RN so we're done.
6. What utilities do we need to
do Line/Polygon clipping?
What utilities do we need to perform Line and Polygon clipping? We need
to test whether a point is inside or outside a halfspace. We also need to
calculate the intersection of a line with a halfspace.
Boolean Inside-p (testVertex:vertex; clipBoundary:edge/plane)
In the most general sense, we can "test the sign of the dot product
of the normal to the clip plane and the polygon edge", as described
in Section 3.12.4 of Computer Graphics: Principles and Practice.
However, since here we are clipping against particularly nice (axis-aligned)
planes, we need only "check the sign of the distance to the boundary".
E.g. if we are clipping to the x=1 plane, we just see if xvertex-in-question
is less than 1. If it is, it's inside. If we are clipping in homogenous
coordinates, we are clipping to the x=w plane, and the test is exactly the
same, determining if xvertex-in-question is less than w.
vertex Intersect(first, second:vertex; clipBoundary:edge/plane)
Here, we simply plug P(t) from our line equation in to the plane equation
determining the edge/plane and solve for t. Once we have t, we plug it back
into our initial equation for P(t) to find out point. If the line and plane
are parallel we won't be able to solve for t, so we have to make sure P0
is on one side of the plane and P1 is on the other to guarantee
it'll intersect.
WWW Maven: Dan Garcia (ddgarcia@cs.berkeley.edu)
Send me feedback