如何在给定外接矩形的情况下找到椭圆长轴的旋转角度?

发布于 2024-07-05 17:55:52 字数 179 浏览 17 评论 0原文

我有一个以 (0,0) 为中心的椭圆,边界矩形为 x = [-5,5],y = [-6,6]。 椭圆与矩形相交于 (-5,3)、(-2.5,6)、(2.5,-6) 和 (5,-3)

我对椭圆一无所知,但我唯一需要知道的是主轴旋转的角度。

看起来答案一定很简单,但我只是没有看到它......感谢您的帮助!

I have an ellipse centered at (0,0) and the bounding rectangle is x = [-5,5], y = [-6,6]. The ellipse intersects the rectangle at (-5,3),(-2.5,6),(2.5,-6),and (5,-3)

I know nothing else about the ellipse, but the only thing I need to know is what angle the major axis is rotated at.

seems like the answer must be really simple but I'm just not seeing it... thanks for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

叹沉浮 2024-07-12 17:55:52

如果 (0, 0) 是中心,则椭圆的方程为:

F(x, y) = Ax^2 +By^2 + Cxy + D = 0

对于任何给定的椭圆,并非所有系数 A、B 、C和D是唯一确定的。 可以将该方程乘以任何非零常数并获得同一椭圆的新方程。

你有 4 个点,给你 4 个方程,但由于这些点是两对对称点,所以这些方程不会独立。 你会得到2个独立的方程。 利用椭圆与软管点中的矩形相切的事实,您可以得到另外两个方程(这就是我的理解)。

因此,如果 F(x, y) = Ax^2 +By^2 + Cxy + D 您的条件是:
dF/dx = 0 点 (-2.5,6) 和 (2.5,-6)
dF/dy = 0 在点 (-5,3) 和 (5,-3) 中

得到的四个线性方程

F(5, -3) = 5^2 * A + (-3)^2 * B + (-15) * C + D = 0  
F(2.5, -6) = (2.5)^2 * A + (-6)^2 * B + (-15) * C + D = 0  
dF(2.5, -6)/dx = 2*(2.5) * A + (-6) * C = 0  
dF(5, -3)/dy = 2*(-3) * B + 5 * C = 0  

这是经过一些清理后

   25A +  9B - 15C + D = 0 //1
6.25A + 36B - 15C + D = 0 //2
   5A       -  6C     = 0 //3
      -  6B +  5C     = 0 //4

:仍然不是所有 4 个方程都是独立的,这是一件好事。 该集合是同质的,如果它们是独立的,您将得到唯一但无用的解决方案 A = 0,B = 0,C = 0,D = 0。

正如我之前所说,系数不是唯一确定的,因此您可以设置其中一个系数如你所愿并摆脱一个方程式。 例如,

   25A + 9B - 15C = 1 //1
   5A      -  6C = 0 //3
      - 6B +  5C = 0 //4

从中你可以得到:A = 4/75,B = 1/27,C = 2/45(D当然是-1)

现在,为了得到角度,应用坐标变换:(

x = ξcos(φ) - ηsin(φ)
y = ξsin(φ) + ηcos(φ)

我只是不能不要抗拒使用这些字母:) )
方程 F(x, y) = 0

F(x(ξ, η), y(ξ, η)) = G(ξ, η) =
  A (ξ^2cos^2(φ) + η^2sin^2(φ) - 2ξηcos(φ)sin(φ))
+ B (ξ^2sin^2(φ) + η^2cos^2(φ) + 2ξηcos(φ)sin(φ))
+ C (ξ^2cos(φ)sin(φ) - η^2cos(φ)sin(φ) + ξη(cos^2(φ) - sin^2(φ))) + D

使用这两个恒等式:

2cos(φ)sin(φ) = sin(2φ)
cos^2(φ) - sin^2(φ) = cos(2φ)

您将得到系数 C',它表示 G(xi, η) 中的乘积 xiη 为:

C' = (BA)sin(2φ) + Ccos (2φ)

现在你的问题是:对于什么角度 φ 系数 C' 消失(等于零)
由于存在多个轴,因此存在多个角度 φ。 在主轴线B'>的情况下, A'

If (0, 0) is the center, than equation of Your ellipse is:

F(x, y) = Ax^2 +By^2 + Cxy + D = 0

For any given ellipse, not all of the coefficients A, B, C and D are uniquely determined. One can multiply the equation by any nonzero constant and obtain new equation of the same ellipse.

4 points You have, give You 4 equations, but since those points are two pairs of symmetrical points, those equations won't be independent. You will get 2 independent equations. You can get 2 more equations by using the fact, that the ellipse is tangent to the rectangle in hose points (that's how I understand it).

So if F(x, y) = Ax^2 +By^2 + Cxy + D Your conditions are:
dF/dx = 0 in points (-2.5,6) and (2.5,-6)
dF/dy = 0 in points (-5,3) and (5,-3)

Here are four linear equations that You get

F(5, -3) = 5^2 * A + (-3)^2 * B + (-15) * C + D = 0  
F(2.5, -6) = (2.5)^2 * A + (-6)^2 * B + (-15) * C + D = 0  
dF(2.5, -6)/dx = 2*(2.5) * A + (-6) * C = 0  
dF(5, -3)/dy = 2*(-3) * B + 5 * C = 0  

After a bit of cleaning:

   25A +  9B - 15C + D = 0 //1
6.25A + 36B - 15C + D = 0 //2
   5A       -  6C     = 0 //3
      -  6B +  5C     = 0 //4

Still not all 4 equations are independent and that's a good thing. The set is homogeneous and if they were independent You would get unique but useless solution A = 0, B = 0, C = 0, D = 0.

As I said before coefficients are not uniquely determined, so You can set one of the coefficient as You like and get rid of one equation. For example

   25A + 9B - 15C = 1 //1
   5A      -  6C = 0 //3
      - 6B +  5C = 0 //4

From that You get: A = 4/75, B = 1/27, C = 2/45 (D is of course -1)

Now, to get to the angle, apply transformation of the coordinates:

x = ξcos(φ) - ηsin(φ)
y = ξsin(φ) + ηcos(φ)

(I just couldn't resist to use those letters :) )
to the equation F(x, y) = 0

F(x(ξ, η), y(ξ, η)) = G(ξ, η) =
  A (ξ^2cos^2(φ) + η^2sin^2(φ) - 2ξηcos(φ)sin(φ))
+ B (ξ^2sin^2(φ) + η^2cos^2(φ) + 2ξηcos(φ)sin(φ))
+ C (ξ^2cos(φ)sin(φ) - η^2cos(φ)sin(φ) + ξη(cos^2(φ) - sin^2(φ))) + D

Using those two identities:

2cos(φ)sin(φ) = sin(2φ)
cos^2(φ) - sin^2(φ) = cos(2φ)

You will get coefficient C' that stands by the product ξη in G(ξ, η) to be:

C' = (B-A)sin(2φ) + Ccos(2φ)

Now your question is: For what angle φ coefficient C' disappears (equals zero)
There is more than one angle φ as there is more than one axis. In case of the main axis B' > A'

深爱成瘾 2024-07-12 17:55:52

椭圆的梯度与沿椭圆一侧的边界矩形相交的梯度相同。 就您而言,这是从 (-2.5,6) 到 (5,-3) 的线,即椭圆的顶边。 该线的垂直落差为 9,水平落差为 7.5。

所以我们最终得到下面的直角三角形。

(-2.5,6)
  *-----
  |\x
  | \
  |  \
9 |   \
  |    \
  |    x\
  +------* (5,-3)
    7.5

我们要寻找的角度是 x,它在两个位置都是相同的。

我们可以将其计算为:

   -1
tan   (9/7.5)

角度为 -50.19 度

The gradient of the ellipse is identical to the gradient of the intersects with the bounding rectangle along one side of the ellipse. In your case, that's the line from (-2.5,6) to (5,-3), the top side of your ellipse. That line has a vertical drop of 9 and a horizontal run of 7.5.

So we end up with the following right-angled triangle.

(-2.5,6)
  *-----
  |\x
  | \
  |  \
9 |   \
  |    \
  |    x\
  +------* (5,-3)
    7.5

The angle we're looking for is x which is the same in both locations.

We can calculate it as:

   -1
tan   (9/7.5)

which gives us an angle of -50.19 degrees

篱下浅笙歌 2024-07-12 17:55:52
  1. 设置椭圆的角度 = 0
  2. 计算 4 个交点
  3. 计算计算出的交点与所需交点之间的误差(即 4 个距离之和)。
  4. 请使用割线法或 Newton-Rhapson 计算出椭圆的新角度,然后转到 2。

我使用类似的方法来计算另一个椭圆问题:

如果误差太大, net/2008/07/18/a-mathematical-digression/" rel="nofollow noreferrer">http://successfulsoftware.net/2008/07/18/a-mathematical-digression/

http://successfulsoftware.net/2008/08/25/a-mathematical-digression -revisited/

另请参阅:

http://en.wikipedia.org/wiki/Secant_method< /a>

http://en.wikipedia.org/wiki/Newton_Rhapson

  1. Set the angle of the ellipse = 0
  2. Calculate the 4 points of intersection
  3. Work out the error between the calculated intersection points and the desired ones (i.e. sum the 4 distances).
  4. If error is too large use the secant method or Newton-Rhapson to work out a new angle for the ellipse and go to 2.

I used a similar approach to work out another ellipse problem:

http://successfulsoftware.net/2008/07/18/a-mathematical-digression/

http://successfulsoftware.net/2008/08/25/a-mathematical-digression-revisited/

See also:

http://en.wikipedia.org/wiki/Secant_method

http://en.wikipedia.org/wiki/Newton_Rhapson

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文