This project is read-only.

2D triangulation of 3D Points

Nov 8, 2016 at 5:55 PM
I need to triangulate arbitrary XYZ values to render a surface in DirectX. I noticed the Vertex and Point classes are 2D. Will the algorithm will work if I add a z value or subclass Vertex? It appeared that the algorithm doesn't create points, so I'm assuming that all of the input points are retained.
Nov 8, 2016 at 11:15 PM
Edited Nov 8, 2016 at 11:16 PM
Yes, as long as you don't use quality meshing, which could introduce new points. Something along the following lines:
public class Vertex3 : Vertex
    public Vertex3(double x, double y, double z)
        : base(x, y)
        this.Z = z;

    public double Z { get; set; }

public static void Test()
    var points = new List<Vertex>();

    points.Add(new Vertex3(0, 0, 0.0));
    points.Add(new Vertex3(0, 1, 0.1));
    points.Add(new Vertex3(1, 1, 0.2));
    points.Add(new Vertex3(1, 0, 0.3));
    // Generate a default mesher.
    var mesher = new GenericMesher(new Dwyer());

    // Generate mesh.
    var mesh = mesher.Triangulate(points);

    foreach (var t in mesh.Triangles)
        // Get the 3 vertices of the triangle.
        for (int i = 0; i < 3; i++)
            var v = (Vertex3)t.GetVertex(i);

Alternatively, the latest source code can be compiled with the USE_Z symbol. It will add a z-coordinate to the Point class.
Marked as answer by mludlum on 11/9/2016 at 7:23 AM
Nov 9, 2016 at 3:23 PM
Thank-you very much.