Expand fill of convex polygon

前端 未结 5 1407
你的背包
你的背包 2020-12-23 23:06

I have a convex polygon P1 of N points. This polygon could be any shape or proportion (as long as it is still convex).

I need to compute an

5条回答
  •  滥情空心
    2020-12-23 23:41

    If the polygon is centered on the origin simply multiply each of the points by a common scaling factor.

    If the polygon is not centered on the origin then first translate so the center is on the origin, scale, and then translate it back to where it was.

    After your comment

    It seems you want all points to be moved the same distance away from the origin. You can do this for each point by getting the normalised vector to this point. multiplying this by your 'expand constant' and adding the resulting vector back onto the original point.

    n.b. You will still have to translate-modify-translate if the center is not also the origin for this solution.

提交回复
热议问题