Skip to main content
GameDev.net gamedev.net
🔒 Locked

Plane representation

Started by Figgles Jul 1, 2006 at 12:38 AM 0 replies 1.6k views
Original Post
Figgles
Figgles
Hi all, Could someone explain to me why I see multiple forms of representing a plane's distance to a point? Form 1: dist = ax + by + cz + d, or dot(plane, vector) + d Form 2: dist = ax + by + cz - d, or dot(plane, vector) - d Form 3: dist = fabs(ax + by + cz) - d, or fabs(dot(plane,vector)) - d Assuming Hesse Normal for (ax+by+cz+dw = 0, where w=1 for 3D vectors), which one of these is correct? Plane = <1.0, 0.0, 0.0, 1.0>, that is, a=1, b=0, c=0, d=1 Point = <-1.0, 0.0, 0.0>, that is, x=-1, y=0, z=0 Shouldn't the distance between the two be 2.0 (unsigned that is)? Form 1: d = -1 + 0 + 0 + 1 = 0 Form 2: d = -1 + 0 + 0 - 1 = -2 Form 3: d = fabs(-1 + 0 + 0) - 1 = 0 Having seen these three forms, I am beginning to question my own understanding of planes. What is it I am missing? Which of these is correct?
Muzzafarath
Muzzafarath
Seeing as all those forms could be negative, they're all wrong. The first one comes closest to being correct, though.

Consider a plane ax + by + cz + d = 0, with N = (a, b, c) normalized. Let P = (p, q, r) be any point. Let Q be the point on the plane which is closest to P.

It should be geometrically clear that Q - P = kN for some real k (that is, Q - P must be perpendicular to the plane). Then

Q = kN + P = (ka + p, kb + q, kc + r)

but Q also lies on the plane, so we must have

a(ka + p) + b(kb + q) + c(kc + r) + d = 0
<=>
ka^2 + ap + kb^2 + bq + kc^2 + cr + d = 0
<=>
k(a^2 + b^2 + c^2) + ap + bq + cr + d = 0
<=>
k = -(ap + bq + cr + d).

(Remember that a^2 + b^2 + c^2 = 1 since (a, b, c) was assumed to be normalized). Hence the distance between P and the plane is

|Q - P| = |kN| = |k| * |N| = |k| * 1 = |ap + bq + cr + d|.

Quote:

Shouldn't the distance between the two be 2.0 (unsigned that is)?


No. The point (-1, 0, 0) lies on the plane x + 1 = 0. The distance must therefore be 0.
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.