From: x9999bvj@maple.circa.ufl.edu
Newsgroups: comp.graphics
Subject: Re: Ordered triplets->homogenized vectors
Date: 23 Dec 92 02:38:07 GMT
Reply-To: X9999BVJ@oak.circa.ufl.edu
Organization: Center for Instructional and Research Computing Activities

In article <1992Dec22.051616.1811@cis.uab.edu>, sloan@willis.cis.uab.edu (Kenneth Sloan) writes:
>In article <38000@uflorida.cis.ufl.edu> sdk@reef.cis.ufl.edu (Steven "Scrib" Kuck) writes:
>
>Beware of cookbooks.  You need a graphics textbook.  For this
>subject, I recommend Newman&Sproull - but any decent text will do.

Believe it or not, I have several good graphics textbooks, including
Foley and Van Dam, David F. Rogers', etc.  The TI book is REAL good
because it isn't just a bunch of library routines == I don't even own
a TI based board ( which is required for the routines ).  It does
a VERY good explanation of what basic 3d is about.  It just overlooked
this one point ( not bad for about a 20 page intro ).

>STOP!  Think! 
>
>Question: What does it mean for a point fo have "an initial Z value
>          of 0"?  
>
>Answer: this point is directly alongside the eyepoint.  It is neither in
>front of, nor behind the eye.  In order to "see" this point, you would
>need a 180deg field of view.
>
>Question: Where in the image plane will this point project?
>
>Answer: either the projected x value, or the projected y value, or both,
>will be infinite.  This looks bad.

Yes, this POINT will project infinitely.  The problem is that the point
can be part of a line, and thus it needs to be clippped.  I'm using a
derivative of the Sutherland-Hodgman clipping algorithm extended to
three dimensions, and it works for the most part.  You see, when you
have a line from, say, 10,0,0 to 0,0,100, you CAN see it....I can't
just ignore the first vertex because its Z value is 0!  It needs to be
clipped into the canonical view volume so that it IS a valid point,
which is why I'm using a canonical view volume and homogenous coordinates
in the first place!

>>... then W becomes zero, and when I try to divide out by W, I get a divide
>>by zero....
>
>
>Which turns out to be correct, more or less.  Not the answer you want -
>but correct nonetheless.  

Yes, that is correct, assuming that the POINT IS BEING CLIPPED, not a LINE
with the point as one of its endpoints.

>Back to our Extra Credit Question.  After a little thought (or perhaps
>some experimentation) you will discover that you cannot apply the
>perspective transformation to points with an initial Z value *less than
>or equal* to 0.  You must CLIP BEFORE PERSPECTIVE.
>
>Next, you will decide that it is bad news to divide by even very small
>positive values.  Instead of clipping against Z==0.0, you should clip
>against Z==hither - where the value of "hither" depends on other
>parameters.  All we know so far is that "hither" should be larger than
>the smallest number you feel comfortable dividing by.

I am aware of all this.  I DO clip before perspective.  Here is the pipeline:

	local*
	  |
	world*
	  |
	camera*
	  |
        trivial rejection/acceptance
	  |
	clip3D^
	  |
	project^

* ordered triplets
^ homogenous vectors


The problem still stems that my ordered->homogenous transformation ( done
before clipping ) assumes a Z >= 0, which won't cut it.  Because although
it works wonderfully up until projection, it still pukes.  It pukes
because in order to "unnormalize" the vector,  I divide by the fourth
element ( when Z is 0 , W is 0 ) and get a divide by 0.  See?

Anyway, more info is appreciated.

Brian