I receive the following points as an input:
Point A(200 ; 400)
Point B(400 ; 400)
Point C(400 ; 200)
Point D(600 ; 200)
Point E(700 ; 500)
Point F(500 ; 700)
Point G(200 ; 600)
These points are forming the segments AB, BC, CD, DE, EF, FG and GA, to be drawn that way:
Now I've been tasked to write an automatic scaling algorithm, based on the closest numbers determining the real segment's length:
As I have to decide the constraints on my own, I've just decided to do the best to keep the angles intact. First, I determine the longest segment in order to establish a scale (for i.e. "labelled length 6" = 250px, then labelled length 1 ~= 41.7).
Then I process the next segment shorter, rescale it from it's center, and apply the same vector translation to its neighboor.
This is the best output I can get right now:
But that method would end up in an infinite loop, or being really inaccurate in other cases, especially when the lines were handdrawn and not perfectly straight.
Are there well known algorithms to solve that situation ? I don't have any clue where to start while searching into some geometry libraries such as GEOS, libigl, ...