question on gl

Gary Tarolli tarolli at westcoast.esd.sgi.com
Wed Apr 3 07:48:00 AEST 1991


In article <14154 at medusa.cs.purdue.edu>, avr at cs.purdue.EDU (Andrew V. Royappa) writes:
> 
> 
> >In article <1991Apr2.150125.22972 at odin.corp.sgi.com>, dave at sgi.com (dave "who can do? ratmandu!" ratcliffe) writes:
> >> In article <14144 at medusa.cs.purdue.edu> avr at cs.purdue.EDU (Andrew V. Royappa) writes:
> >> >The gl graphics user's guide says that the perspective & viewing
> >> >transformations transforms the perspective pyramid into the box 
> >> >-1.0 <= x,y,z <= 1.0, to facilitate clipping. Is this in fact
> >> >the case, 
> >> yep--this *is* the case -1.0 to 1.0 for x, y, *and* z clipping.
> >> 
> >
> >actually we clip against -w and +w, where w is normally 1.0 for orthographic
> >projections.  For perspective transformations, w is NOT 1.0, and instead of
> >transforming the pyramid into a unit box, we really do clip against the 
> >pyramid.  
> >
> 
> Huh. Well, I'm writing some simple 3D routines using X11, and decided
> to use the gl transformations printed at the back of the manual. After
> applying the MVP matrix to a line segment, I clip against 
> -1.0<=x,y,z<=1.0. I see errors sometime even though the clip appears
> to do exactly what I want it do. 
> 
> So then, should I clip against the cube only when using the ortho
> projections, and against the pyramid when using perspective ?
> 
> If yes, could you please give me the exact bounds of the pyramid used by
> gl ?
> 
If you are using ortho, you can safely clip against -1.0, 1.0 since this
is the value of w anyway.  But if you are using perspective, then things
get very tricky.  Most people clip in homogeneous space (x,y,z,w).  If you
don't then I believe it is very difficult to do things mathematically 
correct. Anyway, in homogeneous space you clip against -w and +w.  That is
the pyramid.  I suggest you look at Newman+Sproull or Foley and VanDam
for more info on homogeneous spaces and line clipping.  Its more tricky then
you think, and its even trickier then they allude to.  For example if
you try to clip in normalize device coords after division by w, what do
you do if w=0?  I think that's why most people clip in homogeneous space...
Good luck...


--------------------
	Gary Tarolli



More information about the Comp.sys.sgi mailing list