已知a,b和直线上的两点,中心在原点,求直线与椭圆相交求交点坐标

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
double a,b,c,x1,x2,y1,y2,k,j;
printf("\nplease input a,b:\n");
scanf("%lf%lf",&a,&b);
printf("\nplease input x1,y1,x2,y2\n");
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
k=(y1-y2)/(x1-x2);
c=y1-k*x1;
j=(2*a*a*k*c)*(2*a*a*k*c)-4*(b*b+a*a*k*k)*a*a*(c*c-b*b);
if(j<0)
printf("\nthe line don't intersect with the ellipse");
else
if(j==0)
{
x1=-2*k*c*a*a/(2*(b*b+a*a*k*k));
y1=k*x1+c;
printf("\nthe line and ellipse intersect at\n(%lf,%lf)",x1,y1);
}
else
{

本文介绍如何使用C语言计算直线与中心在原点的椭圆相交的交点坐标,已知椭圆参数a, b以及直线上两个点的信息。"
100518785,1371531,CentOS上Go语言环境配置与工作目录结构,"['Go开发', 'Linux环境', '编程环境', '软件安装', 'CentOS系统']
最低0.47元/天 解锁文章
2559

被折叠的 条评论
为什么被折叠?



