Hi, have a question :
How do i calculate normals for a plane ?
thanks in advance
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?
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
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 ;)
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.
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
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.