求圆和椭圆上任意角度的点的坐标 您所在的位置:网站首页 点的坐标表示方法有4种 求圆和椭圆上任意角度的点的坐标

求圆和椭圆上任意角度的点的坐标

2023-09-17 05:26| 来源: 网络整理| 查看: 265

圆上任意角度的点的坐标

在这里插入图片描述

如上图,给定圆心(Cx,Cy),半径为R, 求 θ \theta θ对应的点的坐标? 此处 θ \theta θ是相对于水平轴的角度。

显然我们可以使用极坐标转换来求: { p x = C x + R c o s ( θ ) p y = C y + R s i n ( θ ) \left\{\begin{matrix} px= Cx+Rcos(\theta) \\ py= Cy+Rsin(\theta) \end{matrix}\right. {px=Cx+Rcos(θ)py=Cy+Rsin(θ)​ 注意如果以上竖直坐标系向下,此时变为图像的坐标系,即 在这里插入图片描述

结果变成:

{ p x = C x + R c o s ( θ ) p y = C y − R s i n ( θ ) \left\{\begin{matrix} px= Cx+Rcos(\theta) \\ py= Cy-Rsin(\theta) \end{matrix}\right. {px=Cx+Rcos(θ)py=Cy−Rsin(θ)​ 仅仅是y变了。

椭圆上任意角度的点的坐标

首先我们先来考虑标准椭圆上任意角度的点的坐标,再进行推广。

在这里插入图片描述

已知主轴a(即椭圆箭头所指方向对应的轴),次轴b,求解与水平轴相交 θ \theta θ对应的点的坐标? { x 2 a 2 + y 2 b 2 = 1 y x = tan ⁡ ( θ ) \left\{\begin{matrix} \frac{x^2}{a^2}+\frac{y^2}{b^2};=;1 \\ \frac{y}{x}; =; \tan(\theta) \end{matrix}\right. {a2x2​+b2y2​xy​​==​1tan(θ)​ 将上面的第二式带入第一式,可以求解得到: x 2 = a 2 b 2 b 2 + a 2 tan ⁡ 2 ( θ ) x^2=\frac{a^2b^2}{b^2+a^2\tan^2(\theta)} x2=b2+a2tan2(θ)a2b2​ 这时我们考虑 θ \theta θ的范围,可以得到: (一). 0 ≤ θ ; p i / 2 0\leq\theta;pi/2 0≤θx=0y=−b​ 再考虑一般情况下的椭圆,如下:

在这里插入图片描述

如上 θ ∈ [ 0 , 2 ∗ p i ] \theta\in[0,2*pi] θ∈[0,2∗pi]是相对于主轴的角度, α ∈ [ − p i , p i ] \alpha\in[-pi,pi] α∈[−pi,pi], 不过我们一般仅仅考虑 α ∈ [ 0 , p i ] \alpha\in[0,pi] α∈[0,pi],求 θ \theta θ对应的点的坐标?

基本思路就是先转换成标准椭圆,再应用标准椭圆下的结果。

显然我们需要将以上椭圆的中心移到原点,再绕原点旋转 − α -\alpha −α ,即顺时针旋转 α \alpha α,即: ( x y ) = R ( ( X Y ) − ( X c Y c ) ) \begin{pmatrix} x\\ y \end{pmatrix}=R(\begin{pmatrix} X\\ Y \end{pmatrix}-\begin{pmatrix} X_c\\Y_c \end{pmatrix}) (xy​)=R((XY​)−(Xc​Yc​​)) 其中 R = ( c o s ( − α ) − s i n ( − α ) s i n ( − α ) c o s ( − α ) ) = ( c o s ( α ) s i n ( α ) − s i n ( α ) c o s ( α ) ) R=\begin{pmatrix} cos(-\alpha) ;-sin(-\alpha) \\ sin(-\alpha) ; cos(-\alpha) \end{pmatrix}=\begin{pmatrix} cos(\alpha) ;sin(\alpha) \\ -sin(\alpha) ; cos(\alpha) \end{pmatrix} R=(cos(−α)sin(−α)​−sin(−α)cos(−α)​)=(cos(α)−sin(α)​sin(α)cos(α)​) 因此 ( X Y ) = R − 1 ( x y ) + ( X c Y c ) \begin{pmatrix} X\\ Y \end{pmatrix} =R^{-1}\begin{pmatrix} x\\ y \end{pmatrix}+\begin{pmatrix} X_c\\Y_c \end{pmatrix} (XY​)=R−1(xy​)+(Xc​Yc​​) 其中 R − 1 = R T = ( c o s ( α ) − s i n ( α ) s i n ( α ) c o s ( α ) )                             ( ★ ) R^{-1}=R^{T}=\begin{pmatrix} cos(\alpha) ;-sin(\alpha) \\ sin(\alpha) ; cos(\alpha) \end{pmatrix}~~~~~~~~~~~~~~~~~~~~~~~~~~~(\bigstar) R−1=RT=(cos(α)sin(α)​−sin(α)cos(α)​)                           (★) 这样将前面 ( x y ) \begin{pmatrix} x\\ y \end{pmatrix} (xy​) 的四个结果应用过来,即得到倾斜的椭圆上的对应角度的点的坐标。

扩展:

如果以上的角度是相对于水平轴的角度,则对应的椭圆上的点的坐标如何求呢? 答: 其实很简单,只需要: θ ′ = { θ − α + 2 ∗ p i , θ ; α θ − α , θ ≥ α \theta'=\left\{\begin{matrix} \theta-\alpha+2*pi, ; \theta;\alpha \\ \theta-\alpha, ; \theta \geq \alpha \end{matrix}\right. θ′={θ−α+2∗pi,θ−α,​θ const double dLiXin = atan2(asin(radian), bcos(radian));//离心角 double x = a*cos(dLiXin)cos(dChangZhouAngle) - bsin(dLiXin)sin(dChangZhouAngle) + ptCenter.x; double y = acos(dLiXin)sin(dChangZhouAngle) + bsin(dLiXin)*cos(dChangZhouAngle) + ptCenter.y; return CDoublePoint2d(x, y); }

问题:

一,为什么不用atan?

答:atan的范围是[-π/2,π/2],atan2的范围是(-π,π]。前者只能表示两个象限,后者可以表示4个。

二,为什么不atan2(a*tan(radian),b)?

答:这样写,和用atan的效果一样。

参考文献 https://math.stackexchange.com/questions/22064/calculating-a-point-that-lies-on-an-ellipse-given-an-angle (主要参考这个)https://stackoverflow.com/questions/17762077/how-to-find-the-point-on-ellipse-given-the-angle (这里有一个从极坐标变换角度新的推导)https://blog.csdn.net/xiamentingtao/article/details/54934467


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有