椭圆包围矩形 [英] Ellipse bounding a rectangle

查看:78
本文介绍了椭圆包围矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Maths101问题-有谁知道如何计算将包围给定矩形的椭圆(宽度/高度).显然没有一个椭圆-我正在寻找一种可以给我各种宽度/高度组合的算法-也许是椭圆的最小面积?它是用于GUI的,因此,我一直在寻找美观的高/宽比.

Maths101 question - does anyone know how to calculate an ellipse (width/height) that will enclose a given rectangle. Obviously there is no single ellipse - I'm after an algorithm that will give me various width/height combinations - or perhaps the smallest area of ellipse? It's for a GUI, so an aesthetically pleasing ratio of height/width is what I'm looking for.

谢谢.

推荐答案

以原点为中心的椭圆的方程是

The equation for a ellipse centered in the origin is

(x/A)^2 + (y/B)^2 = 1

现在,如果要用月食将MxN矩形包围起来,可以将其中心移到坐标原点.右上角的坐标为(M/2,N/2),在椭圆方程式中替换为具有可用于求解给定A(或给定B)的B的公式.

Now if you want to enclose a rectangle of MxN with a eclipse you can move its center to the origin of coordinates. The top right coordinates are (M/2,N/2), replacing in the ellipse equation you have a formula you can use to solve B given A (or A given B).

如果您有一个4x2的矩形,则右上角的坐标为(2,1),替换为您的(2/A)^2 + (1/B)^2 = 1,然后如果A=4求解B给出了B=1/sqrt(1-(1/2)^2).

If you have a rectangle of 4x2, the top-right coordinates are (2,1), replacing you have the (2/A)^2 + (1/B)^2 = 1, then if A=4 solving for B gives B=1/sqrt(1-(1/2)^2).

这篇关于椭圆包围矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆