PDA

View Full Version : Questions about face normals and the crossproduct



chronozphere
29-07-2007, 10:47 AM
Hi PGD people. :)

I have a few math questions.

1) what is the conventional way of computing a face normal?
I know this is done using the crossproduct, but the resulting vector depends on the definition-order of the vertices (Clockwise or Counterclockwise). So i was wondering...
The D3DXComputeNormals routine computes face normals too, but there is no parameter to specify the correct definition-order you want to use. So this function assumes you to deliver your faces defined clockwise or counterclockwise. What is the commonly used definition order?

2) Some things about the crossproduct are not yet clear to me. Okay.. it can be used to determine the plane normal. But does it point up or down??. Most websites say that you must use the right hand rule to determine the normal direction, but doesn't this depend on the handedness of your coordinate system??? :? I'm using a left-handed system. Should i use some kinda left hand rule? :? Can someone explain me the left/right hand rule in detail?

Thanx for your time. :)

tpascal
30-07-2007, 06:12 PM
1) what is the conventional way of computing a face normal?
I know this is done using the crossproduct, but the resulting vector depends on the definition-order of the vertices (Clockwise or Counterclockwise). So i was wondering...
The D3DXComputeNormals routine computes face normals too, but there is no parameter to specify the correct definition-order you want to use. So this function assumes you to deliver your faces defined clockwise or counterclockwise. What is the commonly used definition order?


This is somtimes a tricky topic; there is not a standard for this; the two main graphic API directx and Opengl are different in that by default; and several CAD programs uses different coordinate system; in some you define faces in closewise order, some in counterclockwise; in some Y positive mean going up, in some Y negative mean going Up; heck, in some Z coordinate mean Up/down and Y coordinate is used for depht.

That is why several import models tools dialogs includes options for invert Y or Z values, or swap YZ planes when reading from different file format models.

For Directx I think it is in clockwise by default for defining front faces; Y positive mean going UP; and the camera should be aiming to the positive Z plane;

If you calc a normal passing the vertex order, v1,v2,v3 you will get the same result when you calc the normal passing the order v3,v2,v1 BUT THE RESULT IS INVERSE SIGNED. This mean the calc for computing the normal is exactly the same whatever what coordinate system your are using; just the result have to be interpreted different; the normal (0,0,-1) could mean pointing front in one coordinate system, or could mean pointing back in another coordinate system.

Dont ask which coordinate system is better or which you should use; i dont think there are adventages in one agaist the other.



2) Some things about the crossproduct are not yet clear to me. Okay.. it can be used to determine the plane normal. But does it point up or down??. Most websites say that you must use the right hand rule to determine the normal direction, but doesn't this depend on the handedness of your coordinate system???


The normal dosent just point Up or down; it point perpendicular to the plane; in a flat floor face into a room it point UP; in a flat ceiling face it point down; in the flat vertical left wall in the room it point to the righ; in a slanted floor it could point diagonal. it dosent matter the handedness of your coordinate system your are using as long you pass the vertices order accordilly to that system when you calc the normals.

If you are geting procedures/functions downloaded from internet which involve passing normals to it then YES; you have to be carefull to pass the normal calculated using the handedness of the system expected by the rutine;

chronozphere
01-08-2007, 11:11 PM
thanks for you answer. :)



he normal dosent just point Up or down; it point perpendicular to the plane;


haha... yes i know that. I just didn't describe it as good as you do. :oops:
I assume the plane to be like a floor.

So i guess it's possible to set up some kind of rule for the cross product.

When i define my vertices in clockwise order (from my point of view),
the resulting vector alway's points away from me.

Is this correct??

If so, it does sound easier than any left/right hand rules. :razz:

P.S: i used this applet for my conclusion. Since the handedness of the coordinate system doesn't have influence on the result, my rule is always correct, isn't it????

http://physics.syr.edu/courses/java-suite/crosspro.html

tpascal
02-08-2007, 12:36 AM
Ok,

Left Handed coordinate system mean "X" positive point from left to right, example:

(10,0,0) -----------> (20,0,0)

for to draw a triangle in front of your point of view you have to define in clockwise order.


Righ Handed coordinate system mean "X" positive point from Right to left,
example:

(20,0,0) <----------- (10,0,0)

for to draw a triangle in front of your point of view you have to define in anti-clockwise order.



When i define my vertices in clockwise order (from my point of view),
the resulting vector alway's points away from me.

Is this correct??


When you define your vertices in clockwise order and if your API graphics system is setuped in LEFT handed mode then you can see the triangle; and the normal vector point toward to your position.

When you define your vertices in clockwise order and if your API graphics system is setuped in RIGHT handed mode then you dont see the triangle (you are seeing the back which normally is culled); and the normal vector point away from your position.

The most commun use for normals is for lighting and for doing culling, becouse it tells if any desired point in the world (a light, a camera etc) is in front or back or inside the triangle.