Standard equation:
x 2 a 2 + y 2 b 2 = 1 \frac{x^2}{a^2}+\frac{y^2} {b^2}=1 a2x2+b2y2=1
Parametric equation:
x = a c o s α y = b s i n α \begin{align*} x=acos\alpha \\y=bsin\alpha \end{align*} x=acosαy=bsinα
General form equation:
A x 2 + B x y + C y 2 + D x + E y + F = 0 Ax^2+Bxy+Cy^2+Dx+Ey+F=0 Ax2+Bxy+Cy2+Dx+Ey+F=0
thereinto
A = a 2 s i n 2 θ + b 2 c o s 2 θ B = 2 ( b 2 − a 2 ) s i n θ c o s θ C = a 2 c o s 2 θ + b 2 s i n 2 θ D = − 2 A x 0 − B y 0 E = − B x 0 − 2 C y 0 F = − 1 2 ( D x 0 + E y 0 ) − a 2 b 2 \begin{align*} A = a^2sin^2\theta+b^2cos^2\theta \\B=2(b^2-a^2) sin\theta cos\theta \\C=a^2cos^2\theta +b^2sin^2\theta \\D=-2Ax_0-By_0 \\E=-Bx_0-2Cy_0 \\F=-\frac{1}{2}(Dx_0+Ey_0)-a^2b^2 \end{align*} A=a2sin2θ+b2cos2θB=2(b2−a2)sinθcosθC=a2cos2θ+b2sin2θD=−2Ax0−By0E=−Bx0−2Cy0F=−21(Dx0+Ey0)−a2b2
x 0 , y 0 x_0,y_0 x0,y0为椭圆圆心坐标, a , b a,b a,b分别为椭圆的长短半轴, θ \theta θ为长半轴与x轴的夹角。
l = a ∫ θ 1 θ 2 1 − e 2 s i n 2 θ , θ 1 , θ 2 ∈ [ 0 , π 2 ] l=a\int_{\theta_1}^{\theta_2}\sqrt{1-e^2sin^2\theta} ,\theta_1,\theta_2\in[0,\frac{\pi}{2}] l=a∫θ1θ21−e2sin2θ,θ1,θ2∈[0,2π]
thereinto, e = 1 − b 2 a 2 e=\sqrt{1-\frac{b^2}{a^2}} e=1−a2b2. Here, the angle we talk about is in the first quadrant.
C = 4 l C=4l C=4l
Using the Taylor series expansion, the circumference of the ellipse is
C ≈ π ( a + b ) C\approx\pi(a+b) C≈π(a+b)
x 2 3 2 + y 2 2 2 = 1 \frac{x^2}{3^2}+\frac{y^2}{2^2}=1 32x2+22y2=1
// 参数方程
theta = 0:0.01:2*pi %起止角度和步长
X = 3*cos(theta)
Y = 2*sin(theta)
plot(X,Y)
// 标准形式
theta = 0:0.01:2*pi
f =@(X,Y)X.^2/9+Y.^2/4-1
plot(X,Y)
// An highlighted block
% 参数设定
a = 3
b = 2
e = sqrt(1-b^2/a^2)
theta_1 = 0 %起始角度
theta_2 = pi/2 %终止角度
theta_x = theta_1:0.01:theta_2 % 被积区间
y= a * sqrt(1-e.^2*sin(theta_x).^2) % 直接以被积函数声明
syms theta_vx
y2=@(theta_vx)a * sqrt(1-e.^2*sin(theta_vx).^2) % 匿名函数,被积函数句柄
trapz(theta_x,y) % 梯度积分,trapz(X,Y)根据X指定的坐标或标量间距对Y进行积分,因椭圆第一象限曲线为凸曲线,则梯度法计算结果略小于精确值
quadgk(y2,theta_1,theta_2) % 高斯-勒让德积分,使用高阶全局自适应积分和默认误差容限在区间内对函数句柄求积分
integral(y2,theta_1,theta_2) % 数值积分,使用全局自适应积分和模型误差容限在区间内以数值形式为函数求积分
运行结果:
另, [ 0 , π 2 ] [0, \frac{\pi}{2}] [0,2π]区间四分之一椭圆弧长不精确计算结果:
a n s = π ∗ ( a + b ) / 4 = 3.1415 ∗ ( 2 + 3 ) / 4 = 3.9268 ans=\pi*(a+b)/4=3.1415*(2+3)/4=3.9268 ans=π∗(a+b)/4=3.1415∗(2+3)/4=3.9268
相同角度范围,椭圆弧长结果对比:
-------------------- [ π 4 , π 2 ] [\frac{\pi}{4},\frac{\pi}{2}] [4π,2π]间距下,
-------------------- [ 0 , π 4 ] [0,\frac{\pi}{4}] [0,4π]间距下,