Calculating normals

Soldato
Joined
9 Jun 2006
Posts
2,642
Hi, would be much appreciated if someone could give me a hand with this. Well as part of my graphics coursework in OpenGL I need to find a way of calculating normals automatically. So before I do that, I need to understand how it is done on paper (i.e. if i worked it out myself).

So im told to find the direction that a face, is facing, I simply take two vectors in a counter-clockwise direction and that gives me the vector of the direction.

Sounds easy enough, but when I try it, it doesn't quite work. Lets use the rather crude picture below:

planepicij8.png


If i do the cross product of (1,0,0) and (1,1,0), I get the vector (0,0,1). Which says the face is facing down the z axis, when it should be facing down the x axis.

So where am I going wrong? I've been looking through a textbook to try and figure it out, but they decided not to include any examples. A google doesn't really shed much light on it.

Thanks in advance

EDIT: Ok so I've missed out the sin theta bit, but when I calculate that part, it returns something like 0.7 which seems like the wrong angle between the two edges to me.
 
Last edited:
Just take the vectors representing two adjacent sides of the surface and take their cross product. The direction of the resultant vector is your normal :)

For example, if you have a quadrilateral surface with vertices a, b, c, d, then to find the the surface vector A, take the cross product of two adjacent sides:

A = (b - a) x (d - a)

normal2ej1.png

The magnitude and direction of A are then the area and normal to the surface respectively.

Of course, which way the normal is pointing will be defined by the situation. You'll need to decide which sides to use in calculating the cross product accordingly.


The reason you're going wrong is because you're taking the cross product of the vertices' position vectors, not the sides:

normalrl2.png

Remember, the cross product always gives a vector perpendicular to its two operands, so you need to choose vectors that are both perpendicular to the direction you want (i.e. the normal) :)

Hope that helped explain it!
 
Last edited:
Back
Top Bottom