Sub topic 3
Faces: Surfaces Bounded by Edges
Prerequisites: basic 3D coordinates, vectors, cross products, and simple Python. This chapter focuses on how a face describes one flat part of a polygon mesh.
What a face represents
A face is a polygonal surface bounded by connected edges. Its boundary is a loop of vertices. For example, a triangular face has three vertices and three boundary edges. A quad has four of each.
A face does not usually store separate edge objects. Instead, it stores the vertices in order. Each pair of neighboring vertices forms an edge, including the pair formed by the last and first vertices.
face = (0, 3, 2, 1)
for i in range(len(face)):
start = face[i]
end = face[(i + 1) % len(face)]
print(start, end)This prints the four directed boundary edges:
0 3
3 2
2 1
1 0The % len(face) expression wraps the final vertex back to the first one. Without this wraparound, the polygon would have an open boundary.
Faces are surfaces, not just outlines
A face uses the coordinates of its vertices to define a surface in 3D space. A face is planar when all of its vertices lie on one geometric plane.
Triangles are always planar. A four-sided polygon can also be planar, but a general n-gon with five or more sides might not be. A non-planar polygon cannot represent one flat surface without some adjustment or triangulation.
| Face type | Number of vertices | Common use |
|---|---|---|
| Triangle | 3 | Rendering and simple surfaces |
| Quad | 4 | Modeling and subdivision |
| N-gon | 5 or more | Large modeling regions |
A face can be connected to other faces along shared edges. Two adjacent faces that share an edge form part of a larger surface. The face boundaries are still useful because they determine how the surface is divided and how modeling operations work.
Face order and its direction
The order of a face's vertices gives the face a direction. This is called its winding order. When the vertices appear counter-clockwise from the front side, the face normally points toward the viewer. Reversing the order points it in the opposite direction.
The direction can be computed with a cross product. Given three consecutive positions, form two edge vectors and cross them:
\[ \mathbf{n} = (\mathbf{p}1-\mathbf{p}0) \times (\mathbf{p}2-\mathbf{p}1) \]
The resulting vector is perpendicular to the face. It is called the face normal.
def face_normal(points):
p0, p1, p2 = points[:3]
e1 = tuple(b - a for a, b in zip(p0, p1))
e2 = tuple(b - a for a, b in zip(p1, p2))
normal = (
e1[1] * e2[2] - e1[2] * e2[1],
e1[2] * e2[0] - e1[0] * e2[2],
e1[0] * e2[1] - e1[1] * e2[0],
)
return normal
print(face_normal([(0, 0, 0), (1, 0, 0), (1, 1, 0)]))The output is (0, 0, 1), so this winding order faces upward along the positive z-axis. Reversing the points changes the result to (0, 0, -1).
Why renderers triangulate faces
Graphics hardware processes triangles because they are always planar and have a single, unambiguous interior. A quad is commonly split into two triangles. An n-gon must be split into several triangles.
The diagonal chosen during triangulation can affect the result when a quad is twisted or when an n-gon is concave. Concave means that part of the polygon bends inward. Poorly chosen diagonals can create triangles outside the intended surface or produce unexpected shading.
For predictable results, use triangles when exact rendering behavior matters. Use quads when modeling tools and deformation workflows benefit from their regular structure.
Exercise
A face has vertex indices (4, 7, 6, 5). Which edge closes the boundary loop?
Show answer
The edge from vertex 5 back to vertex 4 closes the loop.