1

I am trying to shrink a polygon by a specific amount where all edges in the new polygon are of equal distance to the old one. To explain better I have a picture here.

example of scenario

If the picture doesnt work I have a link here. https://i.stack.imgur.com/gNWmI.jpg

This is a rough drawing.

I have a point array in ([x,y]) [[390,435], [388,430], [391,425], [425,428], [410,435]]

I am trying to shrink it so the new array [[x1,y1], [x2,y2] ... [x5,y5]]

ensures that the distance between the new area and the original one is 2 at all sides of the area.

How can I do this by only manipulating the co-ordinates. I know I need some kind of scalar vector but I'm unsure how to do this. I am trying to implement this in javascript

Matt Ellen
  • 11,268
  • 4
  • 68
  • 90
kquinn
  • 83
  • 7
  • 1
    Is your polygon always convex? Is it OK that the reduced polygon might have fewer sides when you apply that logic? – trincot Aug 20 '19 at 14:24
  • yes it is always convex, the number of sides doesnt matter as long as the area is always 2 less that the original at all points – kquinn Aug 20 '19 at 14:25
  • This problem does not have much to do with programming, might be a better fit for [math.stackexchange.com](https://math.stackexchange.com) – Wendelin Aug 20 '19 at 14:36
  • Ok I apologise I will ask maths first to get a conceptual idea first too see if I can implement it myself, I'm just a bit stumped – kquinn Aug 20 '19 at 14:39
  • Would it be easier if it was a rectangle? – kquinn Aug 20 '19 at 14:41
  • https://stackoverflow.com/questions/52420003/ – MBo Aug 20 '19 at 15:26

2 Answers2

3

In the general case this is indeed an arduous problem. But for a convex polygon, it is pretty easy.

At every angle, draw the bissector and find the point at distance of the vertex equal to d / sin α/2 where α is the measure of the angle.

enter image description here

1

Have you done some research because there is lots of topics in internet about that subject, the short answer is this is not easy because there is lots of edge cases (look this topic for exemple).

A good term if you want to look more and find nice libs to do this task for your is Polygon offsetting

Others good links :

Ben Souchet
  • 1,450
  • 6
  • 20