Sign in to follow this  
giugio

normal of complex face

Recommended Posts

Hy. I know that for find a normal of a triangle i can execute the dot product of two faces , is corrct? but how i can find the normal of more "complex" faces? The faces are a T section face , i use it for a civil structure project. I also must find the normal of a T L C ecc.. faces. How? Thanks

Share this post


Link to post
Share on other sites
er... no. To find the normal of a triangle, you take the cross product of two of the edges. Be careful about the winding order (picking edges around clockwise or counterclockwise), or your will end up with a normal that faces the wrong way.

1) The simplest way is that you still probably use triangles to draw those faces, so just average the normals of all the triangles on that face. OR if you know the face is flat, just use the normal of a single triangle.

2) If they are flat faces, you only need any two, non-parallel lines on the surface of the face. Cross those lines, and get the normal (or its inverse).

3) If those aren't flat. Then they aren't going to have a normal, but many.

Share this post


Link to post
Share on other sites
Thanks.
But i can have flat face and no flat face , then i must identify by the geometry if a face is flat or no, and if is flat find his normal with the cross product of two non parallel lines.
How i can find that a face is flat?
I also have the axis if this can help.
thanks.

Share this post


Link to post
Share on other sites
Well, you could always check that all the vertices are coplanar... Since any three vertices must lie in a plane, I would get a plane from the normal of a triangle formed by any three vertices (direction doesn't matter), then use one of those points as the plane's point. Now, with this plane, check against all other points to see if they lie in this plane (simple boolean test). If all points are coplanar (return true for being in the plane), then the entire polygon is indeed planar ("flat").

So basically all you need is a point-on-plane boolean test, like this:

bool PointOnPlane( Point &p, Plane &pl )
{
return ( (pl.point - p) dot (pl.normal) == 0 );
}

... and of course, floating point precision may be off, so you probably instead of checking for equality to 0 want to check the absolute value of the dot against some very small threshold value.

-Pravin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this