椭圆隐式方程和参数方程的互相转换
1. 隐式方程转参数方程
二次曲线的一般方程为:
Ax2+2Bxy+Cy2+2Dx+2Ey+F=0.(1)A{x^2}+2Bxy+C{y^2}+2Dx+2Ey+F=0. \tag{1}Ax2+2Bxy+Cy2+2Dx+2Ey+F=0.(1)
若B2−AC<0B^2-AC<0B2−AC<0, 为椭圆;B2−AC=0B^2-AC=0B2−AC=0, 为抛物线;B2−AC>0B^2-AC>0B2−AC>0,为双曲线。
二次曲线可通过旋转和平移来变成标准方程,从而得到其几何参数。旋转的作用是消去交叉项,平移的作用是使中心为原点,下面以椭圆为例。
方程的二次项为:
[x,y][ABBC][xy].(2)[x, y] \left[ \begin{matrix} A &B\\ B &C \end{matrix} \right] \left[ \begin{matrix} x\\ y \end{matrix} \right]. \tag{2} [x,y][ABBC][xy].(2)
一次项为
2[x,y][DE].2[x, y] \left[ \begin{matrix} D\\ E \end{matrix} \right]. 2[x,y][DE].我们对二次项进行旋转,消去交叉项,旋转角θ\thetaθ就是椭圆的偏角。假设新的坐标为(x′,y′)(x^{'}, y^{'})(x′,y′), 那么
[x′y′]=[cosθsinθ−sinθcosθ][xy].\left[ \begin{matrix} x^{'}\\ y^{'}\\ \end{matrix} \right]= \left[ \begin{matrix} \cos\theta & \sin\theta\\ -\sin\theta &\cos\theta\\ \end{matrix} \right] \left[ \begin{matrix} x\\ y\\ \end{matrix} \right]. [x′y′]=[cosθ−sinθsinθcosθ][xy].
将
[xy]=[cosθ−sinθsinθcosθ][x′y′]\left[ \begin{matrix} x \\ y \\ \end{matrix} \right]= \left[ \begin{matrix} \cos\theta &-\sin\theta\\ \sin\theta & \cos\theta\\ \end{matrix} \right]\left[ \begin{matrix} x^{'}\\ y^{'}\\ \end{matrix} \right] [xy]=[cosθsinθ−sinθcosθ][x′y′]
带入式(2),然后令矩阵(1,2) 位置的元素为0,可得,
(C−A)sin2θ+2Bcos2θ=0,(C-A)\sin2\theta+2B\cos2\theta=0,(C−A)sin2θ+2Bcos2θ=0,
那么,tan2θ=2BA−C.\tan2\theta=\frac{2B}{A-C}.tan2θ=A−C2B. 那么原来的二次项矩阵变为:
[cosθsinθ−sinθcosθ][ABBC][cosθ−sinθsinθcosθ]=[A′00C′].\left[ \begin{matrix} \cos\theta &\sin\theta\\ -\sin\theta &\cos\theta\\ \end{matrix} \right] \left[ \begin{matrix} A & B\\ B& C\\ \end{matrix} \right] \left[ \begin{matrix} \cos\theta &-\sin\theta\\ \sin\theta & \cos\theta \end{matrix} \right]= \left[ \begin{matrix} A^{'} & 0\\ 0& C^{'}\\ \end{matrix} \right]. [cosθ−sinθsinθcosθ][ABBC][cosθsinθ−sinθcosθ]=[A′00C′].两边同时乘以旋转矩阵的逆,并比较两边矩阵的(1,1)和(2,2)位置元素可得:
A′=A+Btanθ,C′=C−Btanθ.A^{'}=A+B\tan\theta, C^{'}=C-B\tan\theta.A′=A+Btanθ,C′=C−Btanθ.对于一次项,做同样的旋转操作可得,
[D′E′]=[cosθsinθ−sinθcosθ][DE]=[Dcosθ+Esinθ−Dsinθ+Ecosθ].\left[ \begin{matrix} D^{'}\\ E^{'} \end{matrix} \right]= \left[ \begin{matrix} \cos\theta & \sin\theta\\ -\sin\theta & \cos\theta\\ \end{matrix} \right] \left[ \begin{matrix} D\\ E\\ \end{matrix} \right]= \left[ \begin{matrix} D\cos\theta+E\sin\theta\\ -D\sin\theta+E\cos\theta\\ \end{matrix} \right]. [D′E′]=[cosθ−sinθsinθcosθ][DE]=[Dcosθ+Esinθ−Dsinθ+Ecosθ].那么化简后的椭圆方程为
A′x′2+C′y′2+2D′x′+2E′y′+F=0.A^{'}x^{'}{^2}+C^{'}y^{'}{^2}+2D^{'}x^{'}+2E^{'}y^{'}+F=0.A′x′2+C′y′2+2D′x′+2E′y′+F=0.
我们对它进一步配方化为标准椭圆方程:
(x′+D′/A′)2D′2A′2+E′2C′A′−FA′+(y′+E′/C′)2D′2A′C′+E′2C′2−FC′=1,\frac{(x^{'}+D^{'}/A^{'})^2}{\frac{D^{'}{^2}}{A^{'}{^2}}+\frac{E^{'}{^2}}{C^{'}A^{'}}-\frac{F}{A^{'}}}+\frac{(y^{'}+E^{'}/C^{'})^2}{\frac{D^{'}{^2}}{A^{'}C^{'}}+\frac{E^{'}{^2}}{C^{'}{^2}}-\frac{F}{C^{'}}}=1,A′2D′2+C′A′E′2−A′F(x′+D′/A′)2+A′C′D′2+C′2E′2−C′F(y′+E′/C′)2=1,化简后我们得到椭圆5个参数(xc,yc,a,b,θ)(x_c, y_c, a,b,\theta)(xc,yc,a,b,θ)为
{xc=BE−CDAC−B2yc=BD−AEAC−B2a=xc2+(yc2(C−Btanθ)−F)A+Btanθb=yc2+(xc2(A+Btanθ)−F)C−Btanθtan2θ=2BA−C(θ=12arctan2BA−C).\left\{\color{blue}{ \begin{array}{rcl} &x_c=\frac{BE-CD}{AC-B^2} \\ &y_c=\frac{BD-AE}{AC-B^2}\\ &a=\sqrt{\frac{x_c^2+(y_c^2(C-B\tan\theta)-F)}{A+B\tan\theta}}\\ &b=\sqrt{\frac{y_c^2+(x_c^2(A+B\tan\theta)-F)}{C-B\tan\theta}}\\ &\tan2\theta=\frac{2B}{A-C}(\theta=\frac{1}{2}\arctan{\frac{2B}{A-C}}) \end{array}}. \right. ⎩⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎧xc=AC−B2BE−CDyc=AC−B2BD−AEa=A+Btanθxc2+(yc2(C−Btanθ)−F)b=C−Btanθyc2+(xc2(A+Btanθ)−F)tan2θ=A−C2B(θ=21arctanA−C2B).
将相应的值带入就好。注意二次型(式1)系数是否有2\color{red}{注意二次型 (式1) 系数是否有2}注意二次型(式1)系数是否有2.
2. 参数方程化为隐式方程
假设椭圆5参数(xc,yc,a,b,θ)(x_c, y_c, a,b,\theta)(xc,yc,a,b,θ), 其中 a≥ba\geq ba≥b。它对应的标准方程为
x2a2+y2b2=1.\frac{x^2}{a^2}+\frac{y^2}{b^2}=1.a2x2+b2y2=1. 通过坐标变换(旋转+平移)把标准坐标变到一般坐标:
[x′y′]=[cosθsinθ−sinθcosθ][xy]+[xcyc].\left[ \begin{matrix} x^{'}\\ y^{'}\\ \end{matrix} \right]= \left[ \begin{matrix} \cos\theta & \sin\theta\\ -\sin\theta &\cos\theta\\ \end{matrix} \right] \left[ \begin{matrix} x\\ y\\ \end{matrix} \right]+\left[ \begin{matrix} x_c\\ y_c\\ \end{matrix} \right]. [x′y′]=[cosθ−sinθsinθcosθ][xy]+[xcyc].反解出(x,y)(x, y)(x,y) 带入标准方程,通过简单的化简可得:
{A=cos2θa2+sin2θb2B=sinθcosθ(1a2−1b2)C=sin2θa2+cos2θb2D=−xccos2θ−ycsinθcosθa2+−xcsin2θ+ycsinθcosθb2E=−ycsin2θ−xcsinθcosθa2+−yccos2θ+xcsinθcosθb2F=(xccosθ+ycsinθ)2a2+(xcsinθ−yccosθ)2b2−1.\left\{\color{blue}{ \begin{aligned} &A=\frac{\cos^2\theta}{a^2}+\frac{\sin^2\theta}{b^2} \\ &B=\sin\theta\cos\theta(\frac{1}{a^2}-\frac{1}{b^2})\\ &C=\frac{\sin^2\theta}{a^2}+\frac{\cos^2\theta}{b^2} \\ &D=\frac{-x_c\cos^2\theta-y_c\sin\theta\cos\theta}{a^2}+\frac{-x_c\sin^2\theta+y_c\sin\theta\cos\theta}{b^2}\\ &E=\frac{-y_c\sin^2\theta-x_c\sin\theta\cos\theta}{a^2}+\frac{-y_c\cos^2\theta+x_c\sin\theta\cos\theta}{b^2} \\ &F=\frac{(x_c\cos\theta+y_c\sin\theta)^2}{a^2}+\frac{(x_c\sin\theta-y_c\cos\theta)^2}{b^2}-1&\\ \end{aligned}}. \right. ⎩⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎧A=a2cos2θ+b2sin2θB=sinθcosθ(a21−b21)C=a2sin2θ+b2cos2θD=a2−xccos2θ−ycsinθcosθ+b2−xcsin2θ+ycsinθcosθE=a2−ycsin2θ−xcsinθcosθ+b2−yccos2θ+xcsinθcosθF=a2(xccosθ+ycsinθ)2+b2(xcsinθ−yccosθ)2−1.
注意二次型(式1)系数是否有2\color{red}{注意二次型 (式1) 系数是否有2}注意二次型(式1)系数是否有2.
3.MATLAB代码验证
%%=====================
%椭圆参数方程和隐式方程互化
%input: geometric parameter [xc,yc,a,b,theta], suppose a>=b;
% or algebraic parameter [A,B,C,D,E,F];
%
%output: the transformed result
%%=======================
function [result]=geo2alg(parameter)
close all;
if (nargin==0)%parameter=[2,-1,5,4,1]; % geometric parameterparameter=[0.0559 -0.0102 0.0466 -0.1221 0.0670 -0.6888];% algeraic
end
%-----------Geometric to Algebraic-----------%
if(size(parameter,2)==5)%geometricxc=parameter(1);yc=parameter(2);a=parameter(3);b=parameter(4);theta=parameter(5);% convert to algebraic coefficientsA=cos(theta)^2/a^2+sin(theta)^2/b^2;B=sin(theta)*cos(theta)*(1/(a^2)-1/(b^2));C=sin(theta)^2/a^2+cos(theta)^2/b^2;D=(-xc*cos(theta)^2-yc*sin(theta)*cos(theta))/a^2+(-xc*sin(theta)^2+yc*sin(theta)*cos(theta))/b^2;E=(-yc*sin(theta)^2-xc*sin(theta)*cos(theta))/a^2+(-yc*cos(theta)^2+xc*sin(theta)*cos(theta))/b^2;F=(xc*cos(theta)+yc*sin(theta))^2/a^2+(xc*sin(theta)-yc*cos(theta))^2/b^2-1;result=[A,B,C,D,E,F];
end
%-----------Algebraic to Geometric-----------%
if(size(parameter,2)==6)%algebraicA=parameter(1);B=parameter(2);C=parameter(3);D=parameter(4);E=parameter(5);F=parameter(6);% convert to geometric theta=1/2*atan2(2*B,(A-C));xc=(B*E-C*D)/(A*C-B^2);yc=(B*D-A*E)/(A*C-B^2);a=sqrt(xc^2+(yc^2*(C-B*tan(theta))-F)/(A+B*tan(theta)));b=sqrt(yc^2+(xc^2*(A+B*tan(theta))-F)/(C-B*tan(theta)));result=[xc,yc,a,b,theta];
end
%-------------Plot Two Modes-------------%%geometric t= linspace(0,2*pi,60);x=a*cos(t);y=b*sin(t);Ex = x*cos(theta)-y*sin(theta) + xc;Ey = x*sin(theta)+y*cos(theta) + yc;figureplot(Ex,Ey,'g-','linewidth',2);hold on;%algebraicsyms x y;z1=ezplot(A*x^2+2*B*x*y+C*y^2+2*D*x+2*E*y+F,[-8,8]);set(z1,'Color','r');legend('Geo','Alg');if (size(parameter,2)==5)title('Geo2Alg');elsetitle('Alg2Geo');end
end
结果:
1.Geo2Alg
input: parameter=[2,-1,5,4,1];
output: result=[0.0559 -0.0102 0.0466 -0.1221 0.0670 -0.6888];
几何参数转代数系数,绿色是几何作图,红色为转换的代数作图,两图重合.
2.Alg2Geo
input: parameter=[0.0559 -0.0102 0.0466 -0.1221 0.0670 -0.6888];
output: result=[2.0019 -0.9996 3.9593 4.9450 -0.5715];
代数系数转几何参数,绿色为转换的几何作图,红色为代数系数作图,两图重合。
椭圆隐式方程和参数方程的互相转换相关推荐
- 椭圆一般式方程面积求解
对于一般式的椭圆方程来说,例如,来说是比较难以配凑的,最主要的是找到a跟b. 在这里介绍两种方法, (1)条件极值法 (2)线性代数法 第一种方法:条件极值法 椭圆上的点到椭圆的距离是: 只需要构建在 ...
- python解隐式方程_求解隐式ODE(微分代数方程DAE)
如果代数操作失败,可以对约束进行数值求解,例如在每个时间步运行fsolve:import sys from numpy import linspace from scipy.integrate imp ...
- matlab将求解sin隐式解,Matlab隐式符号方程求解和赋值
近日处理了一个隐式方程的求解,由于方程含有较多的未知数,而且这些参数均是跟实验相关的一些参数,所以,必须得到需要求解的解与 这些参数之间的一个表达式.之前是考虑用的Maple推导求解了该隐私方程,求解 ...
- matlab用方程的解赋值,Matlab隐式符号方程求解和赋值
近日处理了一个隐式方程的求解,由于方程含有较多的未知数,而且这些参数均是跟实验相关的一些参数,所以,必须得到需要求解的解与 这些参数之间的一个表达式.之前是考虑用的Maple推导求解了该隐私方程,求解 ...
- 虎书学习笔记4:图形学基础数学(隐式二维直线、隐式二次曲线、二维参数曲线、二维参数直线、二维参数圆)
关于图形学的基础数学知识 基础数学 隐式二维直线 我们最熟悉的直线:斜截式 他的隐式方程为: 我们再函数y-mx-b=0两边同乘一个系数,将得到一摸一样的直线. 因为两个点觉得一条直线,所以必然满足: ...
- 计算机图形学九:几何1—隐式曲面(代数形式,CSG, 距离函数,分型几何)与显式曲面
隐式曲面与显式曲面 1 隐式曲面(Implicit Surface)与显示曲面(Explicit Surface)的特点 1.1 隐式曲面的特点 1.2 显式曲面的特点 2 具体的几种隐式曲面 2.1 ...
- Adams隐式4阶方法解常微分方程,fortran实现
解微分方程的时候,大多数方程都是隐式方法比较稳定.虽然隐式方法需要迭代,写起来比较麻烦,我还是建议尽量使用隐式方法.Adams隐式是一种精度高,稳定性高的算法,属于隐式四阶龙格库塔法的一个特例.我之前 ...
- Scala 隐式(implicit)详解
文章正文 通过隐式转换,程序员可以在编写Scala程序时故意漏掉一些信息,让编译器去尝试在编译期间自动推导出这些信息来,这种特性可以极大的减少代码量,忽略那些冗长,过于细节的代码. 1.Spark 中 ...
- 如何在 C# 中使用隐式和显式操作符
C# 有一个鲜为人知的特性是通过定义 显式和隐式操作符 实现类型之间的转换,这篇文章我们将会讨论如何使用这些 显式 和 隐式 操作符. 什么是显式,什么是隐式 隐式类型转换 它是运行时自动帮你完成的, ...
最新文章
- 转载-Android数据库高手秘籍(一)——SQLite命令
- 青龙羊毛——可推(搬运)
- Spring核心技术之IOC容器(一):IOC容器与Bean简介
- java socket ip_JAVA 网络编程 TCP/IP、Socket 和协议设计
- 数据结构---BF字符串模式匹配
- 小程序switch内部加上文字_文字游戏大全:模拟游戏会长经营公会的小程序,你会管理公会吗?...
- SpringBoot防XSS攻击
- html是什么型语言,HTML笔记
- m()在php中的意思,计算器上的mc m+ m- mr是什么意思?
- Prophet模型预测商品销售量
- 将15位的身份证号码升级到18位的关键是校验码
- javascript的笔记精简版
- c语言课程设计,学生信息管理系统
- 安防监控专用工业交换机与普通交换机的区别
- python文件操作(1)
- ink css,CSS text-decoration-skip-ink属性用法及代码示例
- L1-078 吉老师的回归
- 使用BoundsChecker查找内存泄露
- 2016届蓝桥杯省赛B组 第5题 勾股定理
- 商业级4G代理搭建指南【搭建篇之Docker版】
热门文章
- 如何计算每月还多少房贷
- java中实现工厂日历_Java实现的日历功能完整示例
- table(单击行,把当行的单选按钮(radio)设为选中状态,并应用当前样式)
- 360 android框架,360 董福源 - Android框架虚拟化实战.pdf
- 为什么阿里不允许用Executors创建线程池,而是通过ThreadPoolExecutor的方式?
- Python案例篇3-pip install 失败 Command “python setup.py egg_info“ failed with error code 1
- 物联网网关神器 Kong ( 四 )- 利用 Konga 来配置生产环境安全连接 Kong
- enable anomaly detection to find the operation that failed to compute its gradient, with torch.autog
- HadoopHA部署(1+x)
- 微信头像更新了,有你喜欢的吗?