Mesh geometry 1
Last updated
Last updated
The objective of this session is to introduce mesh geometries. Meshes are extensively used across computation for numerous applications scientific analysis visualization, video games, computer graphics and 3D printing.
Meshes are comprised of a number of polygonal faces. Graphics hardware typically support only triangles as being the simplest type of polygon. Therefore the simplest type of mesh is a single triangle. To construct meshes we use the “construct mesh” component which requires a list of points, or vertices in mesh parlance, a list of faces i.e. triangles and optionally a list of colours, one per point.
Constructing meshes requires to define triangles in relationship with their point list. Specifically, we use the index of each point as arranged in the point list. For example we construct a list of three points [p0, p1, p2] and a triangle using the indices [0, 1, 2].
In this particular CAD application, but not all, we can also define quadrilateral mesh faces using four indices. For example we construct a list of three points [p0, p1, p2, p3] and a quad using the indices [0, 1, 2, 3].
We may freely mix triangular and quad faces in the same mesh. All we need to keep track of is the point order in the vertex list and the face indices. Here we merged all points in one single list [p0, p1, p2, p3, p4, p5, p6], with the first three for the triangle and the next four for the quad and defined two faces [0, 1, 2] and [3, 4, 5, 6].
Despite the figure illustrating two visually separate polygons, they are in fact a single mesh. The ability to achieve disconnected domains is a feature of mesh geometries.
To construct a cube we need to assemble its eight points and six quad faces into a mesh. The points [p0, p1, p2, p3, p4, p5, p6, p7] are spatially arranged as seen in the figure below. The first four points express the bottom face and the next four points express the top face. We can assemble the face indices by visually creating chains of four consecutive point indices as seen in the graph.
Index Patterns
Looking vertically down the columns of indices we can observe that the sides of the cube follow a “cyclic” pattern.
If we define the range “R = [0, 1, 2, 3]” then the “D” column indices can be expressed as “D = R”. In addition, “C = ( R + 1 ) % 4” which captures the sense of cyclic order. Moreover, the “A” and “B” indices are just offsets “B = C + 4” and “A = D + 4” which captures the grouping of points in four bottom and four top.
Index Ordering
The top and bottom faces on the other hand follow horizontally a sequential pattern, in the sense that “Bottom = S” and “Top = Reverse( S + 4 )”. The ordering of the top face being reversed is not an accident. There is actually a very important reason for taking care of the index ordering, namely face orientation.
We can visualize the mesh’s face orientations using the “face normals” component. Face normal vectors are defined by the points of a face. For a triangle [p0, p1, p2] as well as a quad [p0, p1, p2, p3], the face normal is “n = ( p1 – p0 ) ⨯ ( p2 – p1 )” after we normalize it to unit length.
The orientation of a face, or equivalently the direction of the normal vector, is thus sensitive to the point ordering. Switching the index order has the effect of flipping the face normal direction. We thus need to take care such that all face normals are consistently oriented as we move between adjacent faces.