跳转至

正四面体

绘制

线框

struct MyTriMesh
{
    struct Point
    {
        double x, y, z;
    };
    using PointSet = std::vector<Point>;
    using TriangleIndices = std::array<int, 3>;
    using PrimitiveSet = std::vector<TriangleIndices>;

    PointSet        points;
    PrimitiveSet    faces;

    static MyTriMesh createTetrahedron(double r = 10)
    {
        MyTriMesh mesh
        {
            .points =
            {
                {0.0, 0.0, r},
                {0, -r, -r / 2},
                {sqrt(3) * r / 2, r / 2, -r / 2},
                {-sqrt(3) * r / 2, r / 2, -r / 2}
            },
            .faces = 
            {
                {0, 1, 2},
                {0, 1, 3},
                {0, 2, 3},
                {1, 2, 3}
            }
        };
        return mesh;
    }
};