use*_*377 3 language-agnostic algorithm polygon
我有一个不规则多边形的坐标点,如(x1,y1)...(x1,y1).我可以使用坐标计算多边形的面积.如何使用坐标扩展或缩小多边形区域.?
只需将每个坐标乘以一个固定值即可围绕原点进行缩放.
for each vertex i
result[i].x = input[i].x * scale
result[i].y = input[i].y * scale
Run Code Online (Sandbox Code Playgroud)
如果您想围绕不同的点进行缩放:
translate to origin (subtract the scaling center)
scale by the correct amount (multiply by a constant)
translate from origin (add the scaling center)
Run Code Online (Sandbox Code Playgroud)
要将面积缩放四倍,您需要将距离缩放两倍.因此,如果您的比例是根据面积定义的,请不要忘记转换为线性度量:
scale = sqrt area_scale
Run Code Online (Sandbox Code Playgroud)
如果你想缩放音量:
scale = volume_scale ^ (1/3)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3889 次 |
| 最近记录: |