Public Group

# Computing a normal for an arbitrary quad

This topic is 4270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've got four vertices and I'd like to compute a general normal for the entire quad. Cross-producting two of the vectors will give me a normal for that corner, but I suspect it won't be accurate for the entire quad. Should I take all of the normals and average them? Add them together and normalize? Is one in fact sufficient? Thanks in advance.

##### Share on other sites
If the quad is planar, then one normal is sufficient -- they'll all be the same, anyway. If, though, the quad is really composed of two non-coplanar triangles, then you'll want to average the two triangles' normals. In that case, it'd probably make sense to switch to rendering triangles.

Note that this only applies to per-poly normals. For per-vertex normals, you'd want to sample the normals for all polygons using each of the four vertices and average them together.

-jouley

##### Share on other sites
Break it into a triangle and take the cross product of the triangle.

Normal for a triangle ->
p1 = v2 - v1
p2 = v3 - v1

Normal = CrossProduct(p1, p2)

##### Share on other sites
Quote:
 Original post by jouleyIf the quad is planar, then one normal is sufficient -- they'll all be the same, anyway. If, though, the quad is really composed of two non-coplanar triangles, then you'll want to average the two triangles' normals. In that case, it'd probably make sense to switch to rendering triangles.

If the quad is non-planar, it could be broken into two triangles in two different ways (i.e. along either diagonal).

But yeah, render triangles. It avoids these complications :)

##### Share on other sites
If a 'quad' isn't planar then it isn't a quad, and the solution is undefined. Could you tell us where the vertices came from and what you need the face normal for? Perhaps then we could propose an optimal triangulation from which to work.

##### Share on other sites
The vertices are coming out of a .ply file that I believe is not of the typical format...because it's intended to be loaded and drawn with GL_QUAD_STRIPS (or the like). Are GL_QUADS necessarily composed of coplanar vertices? If that's the case perhaps I should try to break this into triangles...but that would invalidate the format =(

##### Share on other sites
From my experience with OpenGL, GL_QUADs would be rendered no matter what data you threw at the graphics card, but the results were ambiguous and driver-specific if the vertices didn't lie in roughly in a plane.

I suppose planarity is in the file-format's contract, so you shouldn't have to worry about accommodating non-degenerate tetrahedra. In this case, assuming non-collinearity, crossing any two ordered, non-parallel edge vectors will give you a satisfactory (and unique) face normal. If the input is invalid as we've discussed, then your results won't necessarily be well-defined, but that's not your problem. As they say, GIGO.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633723
• Total Posts
3013541
×