home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / graphics / 13104 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  1.7 KB

  1. Path: sparky!uunet!think.com!rpi!gatech!uflorida!reef.cis.ufl.edu!sdk
  2. From: sdk@reef.cis.ufl.edu (Steven "Scrib" Kuck)
  3. Newsgroups: comp.graphics
  4. Subject: Ordered triplets->homogenized vectors
  5. Message-ID: <38000@uflorida.cis.ufl.edu>
  6. Date: 21 Dec 92 22:51:25 GMT
  7. Sender: news@uflorida.cis.ufl.edu
  8. Organization: Univ. of Florida CIS Dept.
  9. Lines: 44
  10. Nntp-Posting-Host: reef.cis.ufl.edu
  11.  
  12. I have having some problems doing 3d clipping to a canonical view volume.
  13. My points are represented in camera relative points with +Z into the
  14. screen.  The problem stems that I need to convert these points from
  15. x,y,z ordered triplets to homogenized vertices.  The equation I'm using
  16. is from the Texas Instruments 3D Graphics Library documention, and
  17. looks like this:
  18.  
  19. given an ordered triplet of ( x, y, z, 1 ), convert to a homogenized
  20. vector of ( x, y, z, w ).
  21.  
  22. x = D * x / Sx
  23. y = D * y / Sy
  24. z = a * z + b
  25. w = z
  26.  
  27. D = distance to the viewport
  28. Sx = viewport half-width
  29. Sy = viewport half-height
  30. a  = z-input scaling constant
  31. b  = z-input translating constant
  32.  
  33.  a = 1 + ( N/F ) 
  34.      -----------
  35.      1 - ( N/F )
  36.  
  37.  b = -2 * N
  38.      -------
  39.      1 - ( N/F )
  40.  
  41. where N is near-clipping plane distance and F is the far clipping plane dist.
  42.  
  43. Okay, now that that is out of the way, the problem becomes rather apparent.
  44. In order to convert back to an ordered triplet, where the fourth element
  45. is 1, you divide by "w", i.e.
  46.  
  47. [ x, y, z, w ] == [ x /w , y/w, z/w, 1 ]
  48.  
  49. Now, when I convert TO homogenous vectors and I have an initial Z value of
  50. 0, then W becomes zero, and when I try to divide out by W, I get a divide
  51. by zero....I know this has been tackled somewhere else, so if someone can
  52. tell me how to accomplish I would appreciate it.
  53.  
  54. Brian
  55.  
  56.