# Planes (Noob question)

This topic is 3947 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

A plane is defined as ax + by + cz + d = 0, where abc is the normal and d is the distance from origo, right? Is the normal pointing to or from origo? More exactly, my problem is that I have a point which I consider belonging in the plane but when I calculate the distance it becomes d * 2. Take the plane π: (0,1,0,6) and the point P: (0,6,0) I think this point should belong in the plane, but when calculating ax + by + cz + d the result is 12 and not 0 as it should. I've tried reading a book on the subject but it doesn't explain such "simple" things.

##### Share on other sites

From the values you gave..
Quote:
 Take the plane π: (0,1,0,6) and the point P: (0,6,0)

The distance of P from the plane is 12.

It looks like you think the plane you quoted (0,1,0,6) is y = 6
so (0,6,0) would lie on it...

But it's not..

ax + by + cz + d = 0
0x + 1y + 0z + 6 = 0
y + 6 = 0
y = -6

So the point (0,-6,0) would be on the plane.
The point (0,6,0) is 12 from the plane.

Does that clear things up??

##### Share on other sites
Yes, I think I understand now, and I've misunderstood what d was. I've changed the way I'm calculating (mostly mental) and I get correct results now.

I'm still trying to learn linear algebra but it's not going to well. Thanks for explaining this thought!

##### Share on other sites
I'll also add that d might not be an absolute distance, either. If the normal, <a,b,c> is not length = 1, then d will have to be scaled accordingly to represent the same plane.

##### Share on other sites
Are you using the ax + ay + az + d = 0 representation of planes in code, or are you only concerned with the math of that representation. If you are using this for a program then I might add in a little of what I have experienced.

I have found in all math courses planes are represented by the form talked about above. However, I have found it easier to represent planes in code as an origin point and a normal. The origin can be any point on the plane, and the normal is just a unit vector which is tangent to the plane surface. The vector points technically into the positive space of the plane and can be used for neat stuff.

Below is generally how I represent it.

class gtVector
{
public:
float x;
float y;
float z;
};

class gtPlane
{
public:
gtVector origin;
gtVector normal;
}

With this representation you can find distance of a point to the plane with the code below.

float gtVectorToPlaneDistance(const gtVector& point, const gtPlane& plane)
{
return gtDot(plane.normal, plane.origin - point);
}

Where
gtDot = A dot product function between two vectors

- Kiro

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634150
• Total Posts
3015801
×