Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!masscomp!peora!tarpit!osceola.cs.ucf.edu!wilson From: wilson@cs.ucf.edu (tom wilson) Newsgroups: comp.graphics Subject: Re: newell plane equation Keywords: graphics, plane eqation Message-ID: <1991Mar7.085240.10865@osceola.cs.ucf.edu> Date: 7 Mar 91 08:52:40 GMT References: <9283@exodus.Eng.Sun.COM> Sender: news@osceola.cs.ucf.edu (News sysetm) Organization: University of Central Florida, Orlando Lines: 52 In article <9283@exodus.Eng.Sun.COM> stephenj@deblil.Eng.Sun.COM (Stephen Johnson) writes: >I have been using the Newell technique for computing the plane >equation in the form: >Ax + By + Cz + D = 0 >and I discovered that the plane defined by the following points is >computing incorrectly: >(2,2,0), (12,2,0), (2,2,3), (12, 2, 3) >From "Procedural Elements for Computer Graphics" bu David F. Rogers, >page 209, the Newell equations are >In the loops: if (i == n) j = 1 else j = i + 1 > >A = SUM(y[i] - y[j]) * (z[i] + z[j]) for i = 1 to N >B = SUM(z[i] - z[j]) * (x[i] + x[j]) for i = 1 to N >C = SUM(x[i] - x[j]) * (y[i] + y[j]) for i = 1 to N > >D = (A * x[0] + B * y[0] + C * z[0]) > >Unfortunately, with the previously mentioned points: > >A = (0 * 0) + (0 * -3) + (0 * 0) + (0 * 3) = 0 >B = (0 * 14) + (-3 * 14) + (0 * 14) + (3 * 14) = 0 >C = (-10 * 0) + (10 * 0) + (-10 * 0) + (10 * ) = 0 > >Oops, by inspection we can see that the equation for this plane is >y = -2. So, what's wrong? Has someone noticed this before and fixed ??? y=-2? How about y=2? Look at the y value for each point. >it. Well, first I don't have the book. Your values are right. This leads me to think that maybe the equations are meant to show that the points are coplanar (i.e. if all sums are 0, then they're coplanar), but that doesn't make sense since it says A=..., B=..., C=... Here's a way that works involving vectors (which I won't go into). Given three points on a plane p0=(x0,y0,z0), p1=(x1,y1,z1), and p2=(x2,y2,z2), then the equation for the plane is: A = (y1-y0)*(z2-z1) - (y2-y1)*(z1-z0) B = (z1-z0)*(x2-x1) - (z2-z1)*(x1-x0) C = (x1-x0)*(y2-y1) - (x2-x1)*(y1-y0) D = -A*x0 - B*y0 - C*z0 thus, A = (2-2)*(3-0) - (2-2)*(0-0) = 0 B = (0-0)*(2-12) - (3-0)*(12-2) = -30 C = (12-2)*(2-2) - (2-12)*(2-2) = 0 D = 0*2 - -30*2 - 0*0 = 60 Thus, the plane equation is -30y + 60 = 0 => y = 2. Tom