Блог пользователя shank_punk

Автор shank_punk, история, 8 лет назад, По-английски

I'm facing a problem while trying to write a code that'll give the vertices of the inner polygon if the Outer polygon's vertices are given along with the "setback values" of each face.

in the example above, we'll be given the outer polygon vertices and the setback values a, b, c where a = distance from face A of the outer polygon to face A' of the inner polygon, b = distance from face A of the outer polygon to face B' and so on...

What's an optimal way to find the vertices of the inner polygon?

I tried to solve it but I'm unable to find the correct vertices while the slope value is > 0.

The number of vertices will be from 1 to 100 and the area of the polygon will not exceed 10^6.

Your help will be much appreciated :)

Thank you

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

sorry for the pic quality. I had to use MS Paint

»
8 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I think you just find the point on A' that is a distance of a away from A with perpendicular lines, and then find the equation of A'. After you acquire the lines of the new polygon, you do a brute force intersection check.

Or am I missing something?

»
8 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

I am not sure if this can handle the corner cases but here are my thoughts.

I suppose that you can compute the corresponding vertices of the inner polygon by considering the setback value of the adjacent sides. For the sake of easy trigonometry naming I will call the vertices on the figure in your post as x, y, z, in clockwise order and x is the vertice between line a and c.

If I am not mistaken, the delta of position between x and x' can be computed by a and c, as a contributes the vertical transposition while c contributes to horizontal transposition.

Therefore I propose that you can sort the vertices in the clockwise order, then compute the slope of each line, and use sine cosine ratio to compute the transposition of each vertice.

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by shank_punk (previous revision, new revision, compare).