-
Notifications
You must be signed in to change notification settings - Fork 5
polyhedron
A polyhedron defines a closed volume limited by a surface mesh consisting of vertices with 3d coordinates and flat faces with N sides. A polyhedron can be specified with implicit or explicit faces.
A polyhedron can be specified with zero faces as long as it has 4 or more vertices not all lying in the same plane. In this case the polyhedron is understood as equivalent to a convex hull (ref. hull3d) defined from the polyhedron vertices, the faces are automatically computed.
Using this option, a general concave or convex polyhedron may be defined, optionally with internal cavities.
-
The vertices listed are implicitly numbered [0,N-1], where N is number of vertices in the polyhedron.
-
Faces may refer to N vertices. Each face must be flat, i.e. the vertices referenced from a face must all lie in the same plane.
-
The implicit face normals must point away from the polyhedron material. Notice that this must always be true, also for faces in any internal cavities. The face normal must never point into the body material. For a triangular face, the face normal can be computed as the cross product between the first and second edge. However, for a general polygon face (potentially concave) this will not be sufficient, a more elaborate procedure such as e.g. Newell's method is then required to reliably establish the face normal.
Below is a polyhedron example with explicit faces, a pyramid with a square base. Note that by omitting the <faces>
block, the polyhedron is computed as a convex hull. With the given vertices the result is the same in both cases.
<?xml version="1.0" encoding="utf-8"?>
<xcsg version="1.0">
<polyhedron>
<vertices>
<vertex x="-10" y="-10" z="-10"/>
<vertex x="10" y="-10" z="-10"/>
<vertex x="10" y="10" z="-10"/>
<vertex x="-10" y="10" z="-10"/>
<vertex x="0" y="0" z="10"/>
</vertices>
<faces>
<face>
<fv index="3"/>
<fv index="2"/>
<fv index="1"/>
<fv index="0"/>
</face>
<face>
<fv index="0"/>
<fv index="1"/>
<fv index="4"/>
</face>
<face>
<fv index="1"/>
<fv index="2"/>
<fv index="4"/>
</face>
<face>
<fv index="2"/>
<fv index="3"/>
<fv index="4"/>
</face>
<face>
<fv index="3"/>
<fv index="0"/>
<fv index="4"/>
</face>
</faces>
</polyhedron>
</xcsg>