Article View: comp.lang.pascal.borland
Article #19Re: 3d programming
From: Bjarne Laursen
Date: Tue, 06 Feb 1996 21:39
Date: Tue, 06 Feb 1996 21:39
61 lines
2988 bytes
2988 bytes
agale@agale.tcp.co.uk (Aaron Gale) wrote:
>Hi,
>I have a problem with a program I am trying to write:
>Does anyone know how to find the intersection of a line and plane
>in simple x,y and z cartesian coordinates. I have a model made
>up of facets, each facet being defined by 4 points. The working
>envelope that this model is in, is then scanned from the bottom
>to the top. However I can't work out how to calculate the z
>coordinate along the scan line that may intersect with a facet.
>The scanning line is always horizontal and is defined with the
>x and y coordinates remaining the same, with one end of the line
>minus z and the other end positive z. As an example at what point
>does the line whose start point is (54,46,-100) and whose end
>point is (54,46,100) intersect with a plane facet defined by 4
>points in a anti-clockwise direction point 1 (40,20,-70),
>point 2 (40,60,-40), point 3 (120,60,-40) and point 4 (120,20,-70).
>--
>I must get round to writing myself a decent signature
A line can be described in 2 eq, in your case it's simple like
X=54; Y=46
A plane can be describet using one eq like A*X+B*Y+C*Z=D
If (0,0,0) is part of the plane you will have to set D=0 in all other
cases you can those a constant value like 1.
Then you will need tre points from the plane that must not be in one
line. (You have a point more than you need to calculate this).
Then you must solve the tree eq to find A,B and C
A*X1+B*Y1+C*Z1=D
A*X2+B*Y2+C*Z2=D
A*X3+B*Y3+C*Z3=D
D*Y2*Z3+ D*Y3*Z1+ D*Y1*Z2 - D*Y3*Z2- D*Y1*Z3- D*Y2*Z1
A= -----------------------------------------------------------
X1*Y2*Z3+X2*Y3*Z1+X3*Y1*Z2 -X1*Y3*Z2-X2*Y1*Z3-X3*Y2*Z1
X1* D*Z3+X2* D*Z1+X3* D*Z2 -X1* D*Z2-X2* D*Z3-X3* D*Z1
B= -----------------------------------------------------------
X1*Y2*Z3+X2*Y3*Z1+X3*Y1*Z2 -X1*Y3*Z2-X2*Y1*Z3-X3*Y2*Z1
X1*Y2* D+X2*Y3* D+X3*Y1* D -X1*Y3* D-X2*Y1* D-X3*Y2* D
C= -----------------------------------------------------------
X1*Y2*Z3+X2*Y3*Z1+X3*Y1*Z2 -X1*Y3*Z2-X2*Y1*Z3-X3*Y2*Z1
Last you insert the known x and y into the eq: A*X+B*Y+C*Z=D
and solving for the only unknown: Z
If the (0,0,0) is part of the plane this will not work as
X1*Y2*Z3+X2*Y3*Z1+X3*Y1*Z2 -X1*Y3*Z2-X2*Y1*Z3-X3*Y2*Z1=0
One way to solve this will be to move the cordinate-system.
I hope this will help you.
-Bjarne Laursen, Pyramide Data , Denmark
Technical Details
Message-ID:
<4f8hot$lg1@news.uni-c.dk>Path:
arc1-ca.pugleaf.net!news.uni-c.dk!newsReferences:
<4f3od9$2jg@zeus.tcp.co.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.uni-c.dk!news From: pyramide@po.ia.dk (Bjarne Laursen) 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 Subject: Re: 3d programming Date: Tue, 06 Feb 1996 21:39:55 GMT Organization: Pyramide Data Message-ID: <4f8hot$lg1@news.uni-c.dk> References: <4f3od9$2jg@zeus.tcp.co.uk> NNTP-Posting-Host: sdbg-02.ia.dk X-Newsreader: Forte Free Agent 1.0.82