home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2907 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.9 KB

  1. Path: news.uni-c.dk!news
  2. From: pyramide@po.ia.dk (Bjarne Laursen)
  3. Newsgroups: comp.lang.pascal.borland,comp.lang.pascal.mac,comp.lang.pascal.ansi-iso,comp.lang.pascal.misc,comp.sys.amiga.programmer,comp.graphics.algorithms,comp.os.ms-windows.programmer.graphics,comp.sys.amiga.graphics
  4. Subject: Re: 3d programming
  5. Date: Tue, 06 Feb 1996 21:39:55 GMT
  6. Organization: Pyramide Data
  7. Message-ID: <4f8hot$lg1@news.uni-c.dk>
  8. References: <4f3od9$2jg@zeus.tcp.co.uk>
  9. NNTP-Posting-Host: sdbg-02.ia.dk
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. agale@agale.tcp.co.uk (Aaron Gale) wrote:
  13.  
  14. >Hi,
  15.  
  16. >I have a problem with a program I am trying to write:
  17.  
  18. >Does anyone know how to find the intersection of a line and plane
  19. >in simple x,y and z cartesian coordinates.  I have a model made
  20. >up of facets, each facet being defined by 4 points.  The working
  21. >envelope that this model is in, is then scanned from the bottom
  22. >to the top.  However I can't work out how to calculate the z
  23. >coordinate along the scan line that may intersect with a facet.
  24.  
  25. >The scanning line is always horizontal and is defined with the
  26. >x and y coordinates remaining the same, with one end of the line
  27. >minus z and the other end positive z. As an example at what point
  28. >does the line whose start point is (54,46,-100) and whose end
  29. >point is (54,46,100) intersect with a plane facet defined by 4
  30. >points in a anti-clockwise direction point 1 (40,20,-70),
  31. >point 2 (40,60,-40), point 3 (120,60,-40) and point 4 (120,20,-70).
  32.  
  33. >--
  34. >I must get round to writing myself a decent signature
  35.  
  36. A line can be described in 2 eq, in your case it's simple like
  37. X=54; Y=46
  38.  
  39. A plane can be describet using one eq like  A*X+B*Y+C*Z=D
  40. If (0,0,0) is part of the plane you will have to set D=0 in all other
  41. cases you can those a constant value like 1.
  42. Then you will need tre points from the plane that must not be in one
  43. line. (You have a point more than you need to calculate this).
  44.  
  45. Then you must solve the tree eq to find A,B and C
  46. A*X1+B*Y1+C*Z1=D
  47. A*X2+B*Y2+C*Z2=D
  48. A*X3+B*Y3+C*Z3=D
  49.  
  50.      D*Y2*Z3+ D*Y3*Z1+ D*Y1*Z2 - D*Y3*Z2- D*Y1*Z3- D*Y2*Z1     
  51. A= -----------------------------------------------------------
  52.     X1*Y2*Z3+X2*Y3*Z1+X3*Y1*Z2 -X1*Y3*Z2-X2*Y1*Z3-X3*Y2*Z1
  53.  
  54.     X1* D*Z3+X2* D*Z1+X3* D*Z2 -X1* D*Z2-X2* D*Z3-X3* D*Z1
  55. B= -----------------------------------------------------------
  56.     X1*Y2*Z3+X2*Y3*Z1+X3*Y1*Z2 -X1*Y3*Z2-X2*Y1*Z3-X3*Y2*Z1
  57.  
  58.     X1*Y2* D+X2*Y3* D+X3*Y1* D -X1*Y3* D-X2*Y1* D-X3*Y2* D
  59. C= -----------------------------------------------------------
  60.     X1*Y2*Z3+X2*Y3*Z1+X3*Y1*Z2 -X1*Y3*Z2-X2*Y1*Z3-X3*Y2*Z1
  61.  
  62.  
  63. Last you insert the known x and y into the eq: A*X+B*Y+C*Z=D
  64. and solving for the only unknown: Z
  65.  
  66. If the (0,0,0) is part of the plane this will not work as
  67. X1*Y2*Z3+X2*Y3*Z1+X3*Y1*Z2 -X1*Y3*Z2-X2*Y1*Z3-X3*Y2*Z1=0
  68.  
  69. One way to solve this will be to move the cordinate-system.
  70. I hope this will help you.
  71.  
  72. -Bjarne Laursen, Pyramide Data , Denmark
  73.  
  74.  
  75.  
  76.