I have a polygon where I'm looking for 2 segments that are approximately 90 degree (+-20°). I always found the first one which is between p1 and p2 and I want to find p3, but in the image below, we can se that between p3 and p2 it's not a direct line.
I had thought maybe looking not directly the first point after p2 but a certain number of points and to see if it's still 90° between p1 p2 and that point but then I have the problem that it will not stop to the good p3. So I thought maybe a cost function calculated with the distance between p2 and the looking point and maybe the dot product, but it didn't turned out to be good.
Does someone maybe have an idea how could I just ignore the points between p3 and p2?