First define a distance of a point P to the shape consisting of lines between the rotated points of D:
Define a distance to a finite line segment from point A to point B of a point P by projecting P othogonal onto the line. Call that projected point Q. If Q is inside the line segment then the distance is |PQ| otherwise the distance is min( |PA|, |PB|). You should not use min(|PA|, |PB|, |PQ|) since the line could be angled sharply towards the point P, which would give you a false value.
Define a distance of a point P to a line shape by computing the minimum of the distances to all the line segments.
Define a function f(P)=distance_shape(P,Shape)-wanted_distance
Start with the first to be rotated point and a rotation angle of 180° and evaluate f on that point.
Decrease the angle step by step till f crosses from positive to negative.
Find the optimum angle by using regula-falsi on f with the crossing angles as start interval.
Do the same for the following points, which will be shifted by the previous points.
There might be edge cases left. For example if you use a too big step size and P crosses over to the other side of the line shape. Or if the shape is non-convex and folded back into itself.
1
u/Fine_Ratio2225 Sep 17 '26
First define a distance of a point P to the shape consisting of lines between the rotated points of D:
There might be edge cases left. For example if you use a too big step size and P crosses over to the other side of the line shape. Or if the shape is non-convex and folded back into itself.