Delaunay points, quick question please :)

Apr 29, 2015 at 1:05 PM
Edited Apr 29, 2015 at 1:12 PM
Hi, thanks for this project it's exactly what I was looking for.
I'm trying to print on the console the Delaunay points that this algorithm has found (the four point of every tetrahedron he finds). Does any one have a clue ? I'm struggling a bit.

Thanks a lot to whom could help me !

P.S : To understand my question, I'm trying to get the same result as the output of the function 'delaunayn' in Octave. Thanks a lot again
Developer
Apr 29, 2015 at 6:41 PM
You can do something like this:
class Vertex : IVertex
{
  // For example, assign a serial id to each of your vertices.
  // You don't need to do this if you want to print just the positions of the vertices.
  public int Id { get; set; } 
  ....
}

var vertices = ....;
var tri = Triangulation.CreateDelaunay(vertices);

foreach (var c in tri.Cells)
{
  Console.WriteLine("[ {0} {1} {2} {3} ]", c.Vertices[0].Id, c.Vertices[1].Id, c.Vertices[2].Id, c.Vertices[3].Id);
}
Apr 30, 2015 at 7:16 AM
Thanks a lot Davecz, I'll try that and let you know how it works. Have a nice day
Apr 30, 2015 at 7:53 AM
Edited Apr 30, 2015 at 9:51 AM
Ok I've done what you give me thanks, but I get an error in Initialise.cs line 65 :

dimensions.Add(Vertices[r.Next(vCount)].Position.Length);
Object reference not set to an instance of an object

I do not see where the error could be.

I've set my main program to :
        int count = list.GetLength(0);
        List<Vertex> vertices = new List<Vertex>();

        for (int i = 0; i < count; i++)
        {
            vertices.Add(new Vertex(list[i, 0], list[i, 1], list[i, 2]));
        }
        var tri = Triangulation.CreateDelaunay(vertices);
        foreach (var c in tri.Cells)
        {
            Console.WriteLine("[ {0} {1} {2} {3} ]", c.Vertices[0].Id, c.Vertices[1].Id, c.Vertices[2].Id, c.Vertices[3].Id);
        }
Thanks a lot
Developer
Apr 30, 2015 at 12:57 PM
Edited Apr 30, 2015 at 12:58 PM
And what is your implementation of the Vertex class? Because it seems that you didn't set the Position property of the IVertex interface.
class Vertex : IVertex
{
  // For example, assign a serial id to each of your vertices.
  // You don't need to do this if you want to print just the positions of the vertices.
  public int Id { get; set; } 
  
  public double[] Position { get; set; }
  
  public Vertex(int id, double x, double y, double z) 
  {
    this.Id = id;
    this.Position = new double[] { x, y, z };
  }
}
EDIT: added the id to the constructor.
May 1, 2015 at 5:31 PM
Thanks for quick answer ill try that
May 4, 2015 at 6:12 AM
I can get the coordinates now, it works fine.

For example if I do c.Vertices[2].position[1] it will give the y coordinate of Vertices number 3 is that right ?

Thank you so much for your help again, really !
Developer
May 4, 2015 at 5:48 PM
olivertod wrote:
For example if I do c.Vertices[2].position[1] it will give the y coordinate of Vertices number 3 is that right ?
Yes, that is correct.
May 5, 2015 at 10:01 AM
Thanks a lot