home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!rpi!gatech!uflorida!reef.cis.ufl.edu!sdk
- From: sdk@reef.cis.ufl.edu (Steven "Scrib" Kuck)
- Newsgroups: comp.graphics
- Subject: Ordered triplets->homogenized vectors
- Message-ID: <38000@uflorida.cis.ufl.edu>
- Date: 21 Dec 92 22:51:25 GMT
- Sender: news@uflorida.cis.ufl.edu
- Organization: Univ. of Florida CIS Dept.
- Lines: 44
- Nntp-Posting-Host: reef.cis.ufl.edu
-
- I have having some problems doing 3d clipping to a canonical view volume.
- My points are represented in camera relative points with +Z into the
- screen. The problem stems that I need to convert these points from
- x,y,z ordered triplets to homogenized vertices. The equation I'm using
- is from the Texas Instruments 3D Graphics Library documention, and
- looks like this:
-
- given an ordered triplet of ( x, y, z, 1 ), convert to a homogenized
- vector of ( x, y, z, w ).
-
- x = D * x / Sx
- y = D * y / Sy
- z = a * z + b
- w = z
-
- D = distance to the viewport
- Sx = viewport half-width
- Sy = viewport half-height
- a = z-input scaling constant
- b = z-input translating constant
-
- a = 1 + ( N/F )
- -----------
- 1 - ( N/F )
-
- b = -2 * N
- -------
- 1 - ( N/F )
-
- where N is near-clipping plane distance and F is the far clipping plane dist.
-
- Okay, now that that is out of the way, the problem becomes rather apparent.
- In order to convert back to an ordered triplet, where the fourth element
- is 1, you divide by "w", i.e.
-
- [ x, y, z, w ] == [ x /w , y/w, z/w, 1 ]
-
- Now, when I convert TO homogenous vectors and I have an initial Z value of
- 0, then W becomes zero, and when I try to divide out by W, I get a divide
- by zero....I know this has been tackled somewhere else, so if someone can
- tell me how to accomplish I would appreciate it.
-
- Brian
-
-