将固定大小的矩形包装在具有最大“缩放”的圆内。
我需要一种算法将一组 N 个矩形放置在半径为 R 的圆内,以便将它们放大到不超过圆边界的最大可能尺寸。我仍在努力,所以如果我找到答案,我会将其发布在这里......
I need an algorithm to place a set of N rectangles inside a circle of radius R, so that they are scaled up to the biggest possible size that doesn't exceed the border of the circle. I'm still working on it so If I find the answer I'll post it here...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
如果我要这样做,我可能会使用一个函数通过二分搜索来测试问题对于给定的 N、R 和矩形比例是否可解决。
测试函数可能应该是这样的:
testfunction(R,fragment_scale)
然后二分搜索将是标准的:
理想情况下,您当然希望以数学方式执行此操作如果.近似值对你来说很好,你可以通过区域来实现(rectangle_area*scale*N = pi*R^2)=>scale=scale = pi*R^2 / N/rectangle_area
。如果您需要准确性,我只会使用面积近似以智能方式设置初始下限/上限
希望这有帮助!
If I would do this I would probably do it through a binary search using a function testing whether the problem is solvable for a given N, R and rectangle_scale.
The test function should probably be something like:
testfunction(R, rectangle_scale)
The binary search would then be standard:
Ideally you would of course want to do this mathematically. If an approximation is fine for you, you could maybe do it through areas. A proximation would be (rectangle_area*scale*N = pi*R^2) => scale = scale = pi*R^2 / N / rectangle_area.
However, if you need accuracy I would only use the area approximation for setting the initial lower/upper bounds in an intelligent way.
Hope this helps!