Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Similarity transform between two triangles

I have two 2D triangles (ie. they both lie in the plane), and would like to find the similarity transform (rotation + scale + translation) that maps one of them most closely onto the other one.

The two triangles are NOT actually similar so I just want the transformation to align them as best as possible.

I know I can create an affine transform between the two triangles which will map one exactly onto the other, but I don't want the shearing effect which is present in affine transforms. I want my transform to be composed only of translations, rotations, and scaling.

Any idea how to do this?

like image 972
kazimpal Avatar asked Nov 03 '22 22:11

kazimpal


1 Answers

Defining similarity is not an easy task, but here are a few ideas you can play with. Say you want to transform triangle A (almost) to triangle B

  • Scale: Scale triangle A by area(B)/area(A)
  • Transformation: Transform triangle A by such a vector that makes both triangle centroids to match.
  • Rotation: Use an optimization method to choose a value in range [0, 360) for rotation that meets your personal similarity criteria.

The rotation part is probably the most difficult. A simple yet effective idea would be to apply hill climbing starting from three points and taking the best. The three points are the amount of rotation needed to put one of the points of A on each of the points of B.

The similarity criterion itself is also not easy. One thing that comes to mind is the amount of overlapping surface after the transformation. Computing this is not easy or at least is cumbersome.

like image 80
Shahbaz Avatar answered Nov 14 '22 20:11

Shahbaz