# How to calculate Normals?

I have a wall made of 4 polygons and dont know how to go about calculating normals.

Originally posted by ac:
I have a wall made of 4 polygons and dont know how to go about calculating normals.

[b] Two vectors pointing in different directions and lying in the same plane are what you need.

You can get that with any flat surface. Triangles are the easiest, because their surface is always in one plane. All you need are its three points to get the two vectors.

Once you acquire those two vectors, you take the cross product of them, which gives you the normal.

Now, you have to make sure that the normal is pointing the way you want, i.e. toward the inside our outside of the planar surface. The order of vector cross product multiply is therefore crucial here.

You’ll likely also want to normalize it, i.e. divide by the magnitude of the normal vector.

My explanation may or may not have enough detail for you, depending upon how much math you have had. I can give you a more detailed ascii art sort of explanation if you’d like. Also, if you have it, you can check out page 64 and Appendix E of the Red book , which gives you a basic run down.

[/b]

[This message has been edited by Thales (edited 11-29-2001).]

Originally posted by Thales:
[b]
[b] Two vectors pointing in different directions and lying in the same plane are what you need.

You can get that with any flat surface. Triangles are the easiest, because their surface is always in one plane. All you need are its three points to get the two vectors.

Once you acquire those two vectors, you take the cross product of them, which gives you the normal.

Now, you have to make sure that the normal is pointing the way you want, i.e. toward the inside our outside of the planar surface. The order of vector cross product multiply is therefore crucial here.

You’ll likely also want to normalize it, i.e. divide by the magnitude of the normal vector.

My explanation may or may not have enough detail for you, depending upon how much math you have had. I can give you a more detailed ascii art sort of explanation if you’d like. Also, if you have it, you can check out page 64 and Appendix E of the Red book , which gives you a basic run down.

[/b]

[This message has been edited by Thales (edited 11-29-2001).][/b]

Thank you for your input. How do I calculate the cross product for vertices?

The cross product for <v1,v2,v3> and <u1,u2,u3> = <a, b, c> where a, b, c are as follows;

a = (v2u3)-(v3u2)
b = -(v1u3)+(u1v3)
c = (v1u2)-(v2u1)

I may be off on the signs but it has been a while since I had Calculus III.

ac,

[b]

I’m probably giving you more detail that you need, but I figure why not, perhaps a lurker can use this anyway!

Here is a little ascii art rendering. Hope this works in UBB!

a--------------> b (V1)
|
|
|
|
V
c
(V2)

Going by the illustration above,

a, b and c are the vertices of your triangle, (didn’t draw the third edge), each represented by three points in x, y, z space.

(ax, ay, az) would be the x,y,z points for vertex ‘a’. (bx, by, bz) for ‘b’, and (cx, cy, cz) for vertex ‘c’.

The next goal is to get the two vectors, V1 and V2.

They are thus:
V1 = b - a;
V2 = c - a

The math for V1 is thus:
V1 = <bx - ax, by - ay, bz - az>

for V2 it is thus:
V2 = <cx - ax, cy - ay, cz - cz>

That gets you the two vectors.

Then you take the cross product, X. Order counts here!

If I take V2 X V1 = Vn, the resulting normal vector, Vn, will be pointing perpendicular to the surface and out of the computer screen.

If I take V1 X V2 = Vn, the resulting normal vector, Vn, will be pointing in the opposite direction, i.e. straight into the computer screen.

And, Thug has the cross product worked out.