【问题标题】:自己生成的多边形的面积
【发布时间】:2022-01-23 16:12:54
【问题描述】:

我正在生成随机点,然后使用凸包算法来获取形成凸多边形的点(以正确的顺序)。问题是有时多边形很小,而不是我想要的那种多边形。所以我想用我选择的最小面积制作“大多边形”。 有人可以帮我解决这个问题吗?是否只有检查该区域并查看它是否小于我选择的最小区域然后再试一次的可能性?

【问题讨论】:

  • 计算面积,相应地缩放点数?

标签: c polygon area convex-hull


【解决方案1】:
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));
  }
}

【讨论】:

    猜你喜欢
    • 2021-03-20
    • 2013-07-18
    • 2013-11-13
    • 1970-01-01
    • 2014-06-03
    • 2013-10-24
    • 2013-11-22
    • 2014-12-31
    • 2012-01-26
    相关资源
    最近更新 更多