【发布时间】:2022-01-23 16:12:54
【问题描述】:
我正在生成随机点,然后使用凸包算法来获取形成凸多边形的点(以正确的顺序)。问题是有时多边形很小,而不是我想要的那种多边形。所以我想用我选择的最小面积制作“大多边形”。 有人可以帮我解决这个问题吗?是否只有检查该区域并查看它是否小于我选择的最小区域然后再试一次的可能性?
【问题讨论】:
-
计算面积,相应地缩放点数?
标签: c polygon area convex-hull
我正在生成随机点,然后使用凸包算法来获取形成凸多边形的点(以正确的顺序)。问题是有时多边形很小,而不是我想要的那种多边形。所以我想用我选择的最小面积制作“大多边形”。 有人可以帮我解决这个问题吗?是否只有检查该区域并查看它是否小于我选择的最小区域然后再试一次的可能性?
【问题讨论】:
标签: c polygon area convex-hull
Set_Random_Point_on_screen();
Surface = 0;
while (Surface < desired_surface) {
Set_Random_Point_on_screen();
Surface = Calculate_new_Surface();
}
另一种方法:
Create_set_of_Random_Points();
Surface = Calculate_Surface();
if (Surface < desired_surface)
{
ratio = desired_surface / Surface;
center = Calculate_Center_of_all_Random_Points();
foreach point in Random_points_on_screen{
Enlarge_point(point, center, sqrt(ratio));
}
}
【讨论】: