我怎么能写上任意四边形内的矩形或圆形矩形、写上、圆形、我怎么能

2023-09-11 04:07:08 作者:回到原点°

这可能是一个更注重数学问题,而是要问这里,因为它是在CS方面。我期待题矩形内的另一个(任意)四与具有最大的高度和宽度可以内切四。因为我觉得算法是相似的,我想看看,如果我能做到这一点的,圆为好。

This may be a more math focused question, but wanted to ask here because it is in a CS context. I'm looking to inscribe a rectangle inside another (arbitrary) quad with the inscribed quad having the largest height and width possible. Since I think the algorithm will be similar, I'm looking to see if I can do this with a circle as well.

要比较清楚听到是我的意思的边界四边形作为例子。

To be more clear hear is what I mean by the bounding quadrilateral as an example.

下面是刻最大化,我想实现的两个例子:

Here are 2 examples of the inscribed maximization I'm trying to achieve:

我已经做了一些preliminary搜索,但没有发现任何明确的。看来,一些形式的动态规划可能是溶液。看来,这应该是一个线性优化的问题,应该是比较常见的比我发现,也许我在寻找错误的条款。

I have done some preliminary searching but have not found anything definitive. It seems that some form of dynamic programming could be the solution. It seems that this should be a linear optimization problem that should be more common than I have found, and perhaps I'm searching for the wrong terms.

注:作为落款方假设,我们知道一个目标W / H比值,我们正在寻找(例如,4:3)。对于四元,假设双方将不交叉和,这将是凹(如果这简化了计算)。

Notes: For the inscribed square assume that we know a target w/h ratio we are looking for (e.g. 4:3). For the quad, assume that the sides will not cross and that it will be concave (if that simplifies the calculation).

推荐答案

1)圆。 对于一个三角形,这是从学校计划一个标准的数学问题。 对于四边形,你可以看到,最大的内圆将至少三次碰到其两侧。因此,采取三个侧面的每个组合和解决问题的每个三角形。 平行边的情况下,必须单独考虑(因为它们没有形成一个三角形),但它并不十分困难。

1) Circle. For a triangle, this is a standard math question from school program. For quadrilateral, you can notice that maximum inner circle will touch at least three of its sides. So, take every combination of three sides and solve the problem for each triangle. A case of parallel sides have to be considered separately (since they don't form a triangle), but it's not terribly difficult.

2)矩形。 你不能有最大的高度和宽度的,你需要选择其他标准。例如,在你的照片,我可以通过降低高度,反之亦然增加宽度。

2) Rectangle. You can't have "largest height and width", you need to choose another criteria. E.g., on your picture I can increase width by reducing height and vice versa.