projection Onto Plane.

 BBS: Inland Empire Archive
Date: 05-09-92 (16:05)             Number: 129
From: PAUL LEONARD                 Refer#: NONE
  To: DAVID BLISS                   Recvd: NO  
Subj: projection Onto Plane.         Conf: (2) Quik_Bas
On or about <May 06 23:44>, David Bliss (1:3639/ scribbled:
 RG>     Lets say we have a four sided plane in 3-D space,
 RG> like this:
 DB> This is so amazingly simple <g> (no offense of course!).  To find
 DB> X,Y,Z of the point you said (assuming i understand you), assuming the
 DB> plane has four corners 1-4 and X,Y,Z of these are X1-4 Y1-4 and Z1-4
 DB> and the point you need is X5 Y5 Z5,
 DB> X5=(x1-x2)+(x3-x4)/2   or whichever corners are on same line
 DB> Y5=(y1-y2)+(y3-y4)/2   "    "          "     "   "   "    "
 DB> Z5=(z1+z2+z3+z4)/4+64
 DB> What this does, is find the middle of the left side of the plane, then
 DB> the middle of the top side, and then give you a point 64 units above
 DB> that point.  very simple geometry <bg> but then i'm in very advanced
 DB> math <g>

This is so amazingly wrong <g> (no offense of course!).
Sorry, i couldn't resist :).

Try a plane section that has corners P1(0,2,0), P2(2,2,0), P3(2,0,0), and
P4(0,0,0) - the point Rich is looking for would be
P5(1,1,64|-64) - your equations (as written) yield P5(-
1,0,64).  The only term that's right is Z5, and that's
only because the example plane is (parallel to) the x-y
plane.  As soon as the plane is rotated about either the x-
 or y-axis, this term will also be incorrect.  I think you
should get some other "advanced math" textbook :).

Actually, the problem Rich Geldreich described is rather
complicated.  Given three points to describe the plane
P1(x1,y1,z1), P2(x2,y2,z2) and P3(x3,y3,z3), the center
point of the rectangle they form has coordinates

( (x1+2*x2+x3)/4, (y1+2*y2+y3)/4, (z1+2*z2+z3)/4 )

and the distance between this point (xm,ym,zm) and the
unknown point P(x,y,z) is given by

D^2 = (x-xm)^2 + (y-ym)^2 + (z-zm)^2

which is the equation of a sphere with center (xm,ym,zm) and radius D.

Now we need to define the line that contains the center
point and P(x,y,z).  To do this we need a point on the
line and a parallel vector, from which we can derive three
parametric equations for the line.  By the definition of
the problem, any vector that is normal (perpendicular) to
the plane will be parallel to this line.  We can define
two vectors in the plane and then get their cross product,
which will produce a normal vector to the plane.

Two vectors in the plane are PmP1 and PmP2 and the cross
product PmP1 X PmP2 yields a vector whose components are

< -y1zm+y1z2+ymz1-y2z1, x1zm-x1z2-xmz1+x2z1, -x1ym+x1y2+xmy1-x2y1 >

The line passing through the point P0(x0,y0,z0) and parallel to the vector
v=<a,b,c> has parametric equations x=x0+a*t, y=y0+b*t and
z=z0+c*t.  Our point is Pm(xm,ym,zm) and our vector is
PmP1 X PmP2, so substituting we get

x = xm + (-y1zm+y1z2+ymz1-y2z1)*t
y = ym + ( x1zm-x1z2-xmz1+x2z1)*t
z = zm + (-z1ym+x1y2+xmy1+x2y1)*t

We now have 4 equations (the distance equation and these
three) and four unknowns (x, y, z and t).  Substitute the
three parametric equations into the distance equation and
solve for t.  Substitute that value back into the three
parametric equations and you've found P(x,y,z), the point
where the line intersects the sphere (actually, there are
two such points).  Ta-dah.


P.S.  Have fun coding this sucker, Rich. :)

--- msged 2.07
 * Origin: PTL Pointwork (1:105/48.111)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET