# Get normal form of plane equation

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

## Recommended Posts

hi, i have a triangle with 3 points, e.g. P1(x1,y1,z1), P2(x2,y2,z2) and P3(x3,y3,z3). how can i get the point normal form of the plane equation: ax + by + cz + d = 0 of it? can anyone tell me how to calculate a, b, c and d? thanks for help.

##### Share on other sites
P*| \ |  \ |   \ *____* QR

You can calculate the normal (a,b,c) of the plane by finding the cross-product of PQ and PR (assuming clockwise is front-facing). Then, take a vector from the origin to P (actually, any of the 3 points will do) and project it onto the normal, the length of the resulting vector is the distance to the plane from the origin (d).

EDIT: My ASCII art crapped itself!!

##### Share on other sites
http://home.planet.nl/~woute890/normals.html

this is a short thing i once wrote. there's a nice geometry serie on flipcode.

##### Share on other sites
what do you mean with project it onto the normal???

##### Share on other sites
project onto means dot product.

##### Share on other sites
No, it doesn't. When you project one vector onto another, your finding out how much of the 1st vector is in the same direction as the 2nd vector. In general, the projection of U onto V is
(U.V)     V----- * ----- |V|     |V|

When projecting onto a normal (ie. a unit vector), the length is 1 so this becomes
(U.V) * V

And again because V is a unit vector, the length of the projection is (U.V). So, the length of the projection onto a unit vector is the dot product of the two vectors.

##### Share on other sites
k,

now i'm totally confused.
i have my 3 points and my normal e.g. (1,2,3)
a vector from the origin to one of the 3 points is similar to one of these 3 points, isn't it? so when i have point1 with (4,5,6),
point2 with (8,9,0) and point3 with (11,44,22) everyone of these points could be the vector to my triangle.

and now ???

:-(

##### Share on other sites
Quote:
 Original post by pikebuk,now i'm totally confused.i have my 3 points and my normal e.g. (1,2,3)a vector from the origin to one of the 3 points is similar to one of these 3 points, isn't it? so when i have point1 with (4,5,6), point2 with (8,9,0) and point3 with (11,44,22) everyone of these points could be the vector to my triangle.and now ???:-(

That's correct. The reason I made a point of saying 'a vector from the origin to a point' is that conceptually points and vectors are 2 different things. A vector is a direction and distance that can be positioned anywhere in space, whereas a point is a fixed position in space. Having said that, when it comes to game programming the distinction usually isn't that important. BTW, if I mention a point O below (or a vector that's something like OP) then the O is the origin.

OK, to start off you want to get the normal of the triangle's plane, that is the direction it is facing. Now, the normal is perpendicular to the triangles face. If a triangle was lying flat on the ground, it's normal would point up or down (from here I'll keep refering to the direction of the normal as up). Now, you can use the cross product to calculate a vector that is perpendicular to 2 other vectors, so you need 2 vectors that lie flat on the plane. For this you can use the vectors between the triangle's points, that is you need 2 of three sides of the triangle. But, you also need to be careful about the order of the vectors as the order will determine if the normal points up or down. To get the normal to point up the vectors should be specifid in clockwise order, and to point down they should be specified in counter-clockwise order. This is the same as when you specify the front face of the triangle as being clockwise or counter-clockwise in OpenGL or Direct3D.

Lets consider the triangle PQR in my previous post. Say I want clockwise to point up, I could use the vectors PQ and PR in clockwise order.
P           _*             \ | \            |  Clockwise|  \          / |   \     < -*    * QR

So, I would find the cross of PQ and PR to get a vector that points up. Since I only care about direction, I now normalise that vector (ie. keep it's direction but make it's length 1) by dividing each element by the vectors length. So,
                  PQ x PRplane's normal = ---------                 |PQ x PR|

This gives you a,b and c of the plane equation as the plane's normal = (a,b,c). You now need d, the distance of the plane from the origin. To understand calculating this, imagine a triangle somewhere in space and extend it's side into infinity (ie. form a plane). Now take any point on that plane and keep sliding it around (keeping it on the plane) until you find a point where the distance from the origin to the point is at it's smallest. This is the distance from the origin to the plane. Not only this, but if you were to move in the direction of the plane's normal from the origin, this point is where you intersect with the plane. In other words, the direction in which the distance from the origin to the plane is shortest is also the normal. Since we already know the normal this makes life that much easier, since what you're now asking 'if I had any random point on the plane and made a vector from the origin to it, how much of that vector would be in the same direction as the normal?'.

Now, with the triangle PQR you only know 3 points on the plane (P, Q and R) so you need to start with one of them. It doesn't matter which one, so I'll just use P. You want to know how much of the vector OP lies in the same direction as the normal. This is called projection of OP onto the normal. Since, we are projecting onto a unit vector (the normal) and only want the distance of the projection, so we can just take the dot product (as I described in my previous post).
distance to plane = |OP| . normal

So to wrap things up, here's all the equations you need in one place. Given a triangle PQR, the plane the the triangle lies on is
ax + bx + cz + d = 0

Where,
           PQ x PR(a,b,c) = ---------          |PQ x PR|

and
d = |OP| . normal

Hope that helps!!!

##### Share on other sites
great ascii art joanusdmentia. rated you up just for that.

##### Share on other sites
There's a very nice article about geometric planes and how they are represented in different form.
The link is here and is written by Dan Sunday.
It's very concise. I hope you find answers on your questions there.

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 10
• 9
• 9
• 46
• 41
• ### Forum Statistics

• Total Topics
631750
• Total Posts
3002067
×