3

我有不规则多边形的坐标点,例如(x1,y1)...(x1,y1)。我可以使用坐标计算多边形的面积。如何使用坐标扩展或缩小多边形区域。?

4

1 回答 1

5

只需将每个坐标乘以一个固定值即可围绕原点进行缩放。

for each vertex i
  result[i].x = input[i].x * scale
  result[i].y = input[i].y * scale

如果您想围绕不同的点进行缩放:

translate to origin (subtract the scaling center)
scale by the correct amount (multiply by a constant)
translate from origin (add the scaling center)

要将区域缩放四倍,您需要将距离缩放两倍。因此,如果您的比例是根据面积定义的,请不要忘记转换为线性测量:

scale = sqrt area_scale

如果您想缩放音量:

scale = volume_scale ^ (1/3)
于 2012-11-02T11:23:27.460 回答