计算椭圆上坐标 分两步,求离心角和根据离心角求椭圆上坐标。
椭圆方程
椭圆方程是
x
2
a
2
+
y
2
b
2
=
(
x
a
)
2
+
(
y
b
)
2
=
(
c
o
s
(
t
)
)
2
+
(
s
i
n
(
t
)
)
2
=
1
\frac{x^2}{a^2} + \frac{y^2}{b^2} = \left(\frac{x}{a}\right)^2+\left(\frac{y}{b}\right)^2=\left(cos\left(t\right)\right)^2+\left(sin\left(t\right)\right)^2=1
a2x2+b2y2=(ax)2+(by)2=(cos(t))2+(sin(t))2=1
这个
t
t
t就是离心角的角度。
求离心角
如下图,已知椭圆的角
p
p
p,要求主离心角
t
t
t。如下图,小圆为椭圆内切,大圆为椭圆外切。虚线除OE外,全为垂线。
根据椭圆方程,可知E的y坐标
E
y
=
b
∗
s
i
n
t
(
t
)
=
A
y
E_y = b*sint\left(t\right)=A_y
Ey=b∗sint(t)=Ay
又有
t
a
n
(
t
)
=
B
D
/
O
D
tan\left(t\right)=BD/OD
tan(t)=BD/OD
t
a
n
(
p
)
=
E
D
/
O
D
tan\left(p\right)=ED/OD
tan(p)=ED/OD
那么
t
a
n
(
t
)
t
a
n
(
p
)
=
B
D
E
D
=
B
D
A
C
=
O
D
O
C
=
a
b
\frac{tan\left(t\right)}{tan\left(p\right)} = \frac{BD}{ED}=\frac{BD}{AC}=\frac{OD}{OC}=\frac{a}{b}
tan(p)tan(t)=EDBD=ACBD=OCOD=ba
所以,
t
a
n
(
t
)
=
t
a
n
(
p
)
∗
a
b
tan\left(t\right)=tan\left(p\right)*\frac{a}{b}
tan(t)=tan(p)∗ba
求解 t t t值时,用函数 a t a n 2 ( x , y ) atan2(x,y) atan2(x,y),这样求出的值是[ − π -\pi −π, π \pi π],使用 a t a n atan atan得到的值在[ − π 2 -\frac{\pi}{2} −2π, π 2 \frac{\pi}{2} 2π]
根据离心角求椭圆上给定角度的坐标
根据椭圆公式,可得
x
=
a
∗
c
o
s
(
t
)
x = a*cos\left(t\right)
x=a∗cos(t)
y
=
b
∗
s
i
n
(
t
)
y = b*sin\left(t\right)
y=b∗sin(t)
椭圆出现平移及旋转的情况
这种情况,需要先将椭圆旋转并平移到标准椭圆位置,计算完点坐标再反算回去。如下图
旋转后的椭圆坐标与标准椭圆坐标的对应关系如下所示公式:
(
x
y
)
=
R
∗
(
(
X
Y
)
−
(
X
c
Y
c
)
)
\begin{pmatrix}x \\ y\end{pmatrix} = R*\left(\begin{pmatrix}X \\ Y\end{pmatrix}-\begin{pmatrix}X_c \\ Y_c\end{pmatrix}\right)
(xy)=R∗((XY)−(XcYc))
其中 ,
R
=
(
c
o
s
(
γ
)
s
i
n
(
γ
)
−
s
i
n
(
γ
)
c
o
s
(
γ
)
)
R=\begin{pmatrix} cos\left(\gamma \right) & sin\left(\gamma \right) \\ -sin\left(\gamma \right) & cos\left(\gamma \right) \end{pmatrix}
R=(cos(γ)−sin(γ)sin(γ)cos(γ))
且
R
−
1
=
R
T
=
(
c
o
s
(
γ
)
−
s
i
n
(
γ
)
s
i
n
(
γ
)
c
o
s
(
γ
)
)
R^{-1}=R^{T}=\begin{pmatrix} cos\left(\gamma \right) & -sin\left(\gamma \right) \\ sin\left(\gamma \right) & cos\left(\gamma \right) \end{pmatrix}
R−1=RT=(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)+(XcYc)
最终,
X
=
c
o
s
(
γ
)
∗
x
−
s
i
n
(
γ
)
∗
y
=
c
o
s
(
γ
)
∗
a
∗
c
o
s
(
t
)
−
s
i
n
(
γ
)
∗
b
∗
s
i
n
(
t
)
+
X
c
Y
=
s
i
n
(
γ
)
∗
x
+
c
o
s
(
γ
)
∗
y
=
s
i
n
(
γ
)
∗
a
∗
c
o
s
(
t
)
+
c
o
s
(
γ
)
∗
b
∗
s
i
n
(
t
)
+
Y
c
\begin{array}{c} X= cos\left(\gamma \right)*x -sin\left(\gamma \right)*y = cos\left(\gamma \right)*a*cos\left(t\right) -sin\left(\gamma \right)*b*sin\left(t\right)+X_c \\ Y= sin\left(\gamma \right)*x +cos\left(\gamma \right)*y = sin\left(\gamma \right)*a*cos\left(t\right) +cos\left(\gamma \right)*b*sin\left(t\right)+Y_c \end{array}
X=cos(γ)∗x−sin(γ)∗y=cos(γ)∗a∗cos(t)−sin(γ)∗b∗sin(t)+XcY=sin(γ)∗x+cos(γ)∗y=sin(γ)∗a∗cos(t)+cos(γ)∗b∗sin(t)+Yc
参考:
网页1
网页2