
Hi,
I'm trying to do a warp affine transformation with source and destination triangle's points.
To find the triangles, I'm using the following code:
InputGeometry sourceGeometry = new InputGeometry();
foreach (var sourcePoint in sourcePoints)
{
sourceGeometry.AddPoint(sourcePoint.X, sourcePoint.Y);
}
Mesh sourceMesh = new Mesh();
sourceMesh.Behavior.ConformingDelaunay = true;
sourceMesh.Triangulate(sourceGeometry);
var sourceTriangles = sourceMesh.Triangles;
And the same code to find the destination triangles.
To do the affine transformation, I need to pass the points from the two nearest triangle for each triangle found.
The problem is that the triangles order returned by the mesh.Triangulate is not the same for source and destination points.
Is there a way to set the returned order? Or maybe reorder the triangles?
Thanks,
Bruno


Coordinator
Mar 25, 2014 at 4:07 PM
Edited Mar 25, 2014 at 4:12 PM

Not sure what's your objective:
 You got a source pointset and triangulate it. You apply a transform to the pointset and triangulate again. Obviously, you'll get two meshes with very different topologies. No trivial mapping between the two topologies.
 My guess what you'd like to do: triangulate your source pointset, make a copy of the mesh, transform the points(~) and compare the transformed mesh (which most likely will not be Delaunay) to the copy of the original triangulation.
?
~ The coordinates of the TriangleNet.Geometry.Point class are readonly, so if my guess is right, you'll have to add setters to the X and Y properties.



Hi wo80,
Thanks for your answer..
What I'd like to do is to transform a image using triangulation with source and destination points as base to find the triangles.
For example, I have two pointsets.
points found in the image (source):
x = 86; y = 55
x = 85; y = 817
x = 85; y = 1585
x = 1184; y = 55
x = 1183; y = 822
x = 1184; y = 1584
points where the found points should be (destination):
x = 88; y = 59
x = 88; y = 825
x = 88; y = 1588
x = 1186; y = 59
x = 1186; y = 825
x = 1186; y = 1588
With those pointsets, first I ran the mesh the find the source triangles only with the source points. Then I ran the mesh again to find the destination triangles.
Oops, just found my error here. I don't need to run the mesh twice. I just need to run the mesh with the source points.
For each triangle found, I have the points with an ID which is the position in the array. This position is the same for the destination array.
So, that's exactly what I needed!! ;) Now I have the source and destination points to apply the affine transformation.
Thank you very much,
Bruno

