0

I'm writing a BSP tree program. How do I classify a polygon as above or below a plane?

I don't know much about Matrix or Vector math so if it the answer does involve it could you explain how it pertains to classifying polygons?

Daraan
  • 1,797
  • 13
  • 24
  • You should at least provide some code what you did, where you failed, and what programming language you use. – kism3t Jun 20 '17 at 05:01
  • A polygon is usually embedded in some plane, what do you mean with above or below; Or do you look for a point inside a polygon? – gue Jun 20 '17 at 06:37
  • 1)Take any arbitray point(who you know is above or below plane(or line)). 2) Now, take a point of polygon(you may take vertex for ease) 3) Put those points in eqution of plane(or line) if both give same sign they are on same side of line else they are on opposite side. Note - you to add case when the vertex lies on line(or plane) – monster Jun 21 '17 at 08:05
  • @monster thanks could you put your comment in the form of an answer so I can you give you credit. – user2883202 Jun 24 '17 at 17:55

1 Answers1

0

Lets say we have a plane with normal n = (n1, n2, n3) and d its perpendicular distance from the origin.

If you have a point x that is on the plane, then

x1n1 + x2n2 + x3n3 = -d

if d has a positive or negative sign is not strictly defined. But we can formulate this as

x1n1 + x2n2 + x3n3 + d = z

if z>0 then a point is above the plane.

Now for a polygon p we have to do this for all points/vertices, lets stay in 3D we get 3 values for z.

if all(z > 0):
   p is above
else if all(z < 0):
   p is below
else
   p is cut by the plane

NOTE: Depending on the setting errors from floating point arithmetics can be relatively high and even up to ~1e-2 for points that are actually on the plane.


A similar question and answers can be found here and some hints on alternate forms.

Daraan
  • 1,797
  • 13
  • 24