When inserting a Face4
into the faces
array, you will generate a quad when calling faces. However, if you insert a Face3
into faces
, you will receive a triangle in return. If you see a d
when making a faces
call, it means you have inserted a Face4
.
If you're wondering how to obtain triangles from a quad, that is a separate question.
Essentially, considering the 'order' of the quad as A B C D
, you can deduce that A B C
and A C D
generally form triangles sharing the same approximate normal as the quad. Note that this approximation may vary if the quad is somewhat distorted due to non-coplanar points. The less coplanar the points are, the more noticeable the skew will be, resulting in different normals.
There are other valid combinations as well. A simple method is to sketch out A B C D
on paper and observe the direction (Clockwise or Counterclockwise). As long as your new triangles follow the same direction, they will work correctly. For instance, if A B C
is a viable triangle, so would be B C A
and C A B
. Similarly, for A C D
, consider C D A
and D A C
. Alternatively, you could also split it along the other diagonal to create A B D
and B C D
, forming corresponding triangles based on the given logic.