5
votes

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?

1
Firstly you need to define what you mean by 'most closely' surely??mathematician1975
I think math.stackexchange.com is the right place to raise this question.Shashank Kadne
by "most closely" I mean anything plausible where transforming one triangle makes it pretty much registered with the other one. I'm open to suggestions for sensible (and fairly simple to compute) meanings of "most closely"kazimpal
not a duplicate of that. that question is asking about affine mappings which is what I don't wantkazimpal

1 Answers

2
votes

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.