Hi, have a question :

How do i calculate normals for a plane ?

thanks in advance

Started by Jul 05 2014 08:02 AM

,
8 replies to this topic

Posted 05 July 2014 - 08:02 AM

Hi, have a question :

How do i calculate normals for a plane ?

thanks in advance

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

Posted 05 July 2014 - 08:10 AM

Given a plane with the vertices A, B, C, D, you can calculate the normal by taking any two connection vectors between those vertices, like AB and AC. You normalize those vectors, take the cross product, and thats your normal (which you probably want to normalize again, I can't remember for sure if this product is of uniform length). Also note that the choice and ordering of vectors in the cross-product equation are not totally arbitrary, as you might get the normal in the wrong direction. In that case, instead of e.g. AB x AC you switch to AC x AB. I'd recommend to try it out until someone gets around to put those things into definitie place (I always have a hard time remembering the theories behind that math stuff...

EDIT: Since you posted in graphics theory, you did mean a plane with 4 vertices and not a mathematical plane given the equation f(x) = a*x + b*x + c*x + d; right?

**Edited by Juliean, 05 July 2014 - 08:11 AM.**

Posted 05 July 2014 - 08:30 AM

POPULAR

EDIT: Since you posted in graphics theory, you did mean a plane with 4 vertices and not a mathematical plane given the equation f(x) = a*x + b*x + c*x + d; right?

Those are called quads, not planes... though the method still works, of course, any three non-colinear points on a plane (aka not in a straight line, aka a proper triangle) are sufficient to determine the plane's normal (up to handedness, which is probably going to be defined depending on the rest of your geometry, so that all the normals correctly point either "in" or "out" - your modelling tool should be able to do this automatically for you using "unify normals" or similar which basically rotates the vertices of all the triangles to have a coherent winding order - then you only need to decide on "the right one" and stick to it).

And you do need to normalize, as even if the two vectors in your plane are unit length the cross product will not be unless they are also orthogonal. If your vectors are u and v then the length of the cross product will be equal to |u| |v| sin(theta) where theta is the angle between the two vectors, between 0 and pi. This also means that you typically do not need to normalize the two vectors before taking the cross product as its direction is independent of the magnitude of either vector, which can save some operations

*“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”*

Posted 05 July 2014 - 09:50 AM

Hi, i,m meaning a plane with 4 vertices, yes.

I need the normals for correct lighting.

**Edited by the incredible smoker, 05 July 2014 - 09:51 AM.**

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

Posted 05 July 2014 - 09:58 AM

Those are called quads, not planes...

Ah, those damn math terms, gets me all the time. Though I'm pretty sure I remember having heard the term "plane" being used what is actually called a quad (in the context of graphics & programming), so twice the confusion! Seems I was right though due to OP, I quess good luck that I misread the term ;)

Posted 05 July 2014 - 03:47 PM

You don't need to normalize the vectors **before** the cross product, the cross product will result in a vector in the normal direction of the plane anyway.

Posted 06 July 2014 - 05:48 AM

Hi, thanks for all the help, let me make it simpler, maybe i understand it to then ?

Ok : i only rotate the plane/quad on 1 axis, else my collision detection algorithm does not work.

Maybe you guys can give now a simpler solution for me ?

thanks in advance

**Edited by the incredible smoker, 06 July 2014 - 05:49 AM.**

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

Posted 06 July 2014 - 06:42 AM

Ok : i only rotate the plane/quad on 1 axis, else my collision detection algorithm does not work.

So you mean that the quad is locked around a certain axis, so that it only rotates around that very axis? In that case, wouldn't that axis already be the normal? Unless I don't understand your setup.

Posted 06 July 2014 - 08:58 AM

Yeah, i only use pitch or yaw or roll or whatever its called, no combination of these.

( not that i realy use rotation, i do place the vertices in the right spot ofcourse )

I cannot figure out the collision detection otherwise, but thats not the problem now.

**Edited by the incredible smoker, 06 July 2014 - 09:01 AM.**

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor