已知三点求圆⼼c语⾔,转已知两点坐标和半径求圆⼼坐标程序
C++
数学思想:利⽤圆⽅程和直线⽅程
已知两点坐标和半径求圆⼼坐标程序
#include
#include
#include
using namespace std;
ofstream fout;
typedef struct
{
double x;
double y;
}Point;
double Y_Coordinates(double x,double y,double k,double x0);//4个参数
void Circle_Center(Point p1,Point p2,double dRadius);
bool Data_Validation(Point p1,Point p2,double dRadius);
void ReadData(Point &p1,Point &p2,double &dRadius);
void main()
{
Point p1,p2;
double dRadius = 0.0;
ReadData(p1,p2,dRadius);
fout.open("");
Circle_Center(p1,p2,dRadius);
fout.close();
}
void Circle_Center(Point p1,Point p2,double dRadius)
{
double k = 0.0,k_verticle = 0.0;
double mid_x = 0.0,mid_y = 0.0;
double a = 1.0;
double b = 1.0;
double c = 1.0;
Point center1,center2;
k = (p2.y - p1.y) / (p2.x - p1.x);
if(k == )
{
center1.x = (p1.x + p2.x) / 2.0;
center2.x = (p1.x + p2.x) / 2.0;
center1.y = p1.y + sqrt(dRadius * dRadius -(p1.x - p2.x) * (p1.x - p2.x) / 4.0);
center2.y = p2.y - sqrt(dRadius * dRadius -(p1.x - p2.x) * (p1.x - p2.x) / 4.0);
}
else
{
k_verticle = -1.0 / k;
mid_x = (p1.x + p2.x) / 2.0;
mid_y = (p1.y + p2.y) / 2.0;
a = 1.0 + k_verticle * k_verticle;
b = - * mid_x - k_verticle * k_verticle * (p1.x + p2.x);
c = mid_x * mid_x + k_verticle * k_verticle * (p1.x + p2.x) * (p1.x + p2.x) / 4.0 -(dRadius * dRadius - ((mid_x - p1.x) * (mid_x - p1.x) + (mid_y - p1.y) * (mid_y - p1.y))); center1.x = (-1.0 * b + sqrt(b * b - * a * c)) / ( * a);
center2.x = (-1.0 * b - sqrt(b * b - * a * c)) / ( * a);
center1.y = Y_Coordinates(mid_x,mid_y,k_verticle,center1.x);
center2.y = Y_Coordinates(mid_x,mid_y,k_verticle,center2.x);
}
fout << center1.x << " " << center1.y << endl;
fout << center2.x << " " << center2.y << endl;
}
double Y_Coordinates(double x,double y,double k,double x0)
{
return k * x0 - k * x + y;
}
bool Data_Validation(Point p1,Point p2,double dRadius)
{
double dDistance = 0.0;
dDistance = sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
if(dDistance == 0.0)
{
cout << "\n输⼊了相同的点!\n";
return false;
}
if(( * dRadius) >= dDistance)
return true;
else
{
cout << "\n两点间距离⼤于直径!\n";
return false;
}
}
void ReadData(Point &p1,Point &p2,double &dRadius)
{
cout << "请输⼊圆周上⼀点的坐标:";
cin >> p1.x >> p1.y;
cout << "请输⼊圆周上另⼀点的坐标:";
cin >> p2.x >> p2.y;
cout << "请输⼊圆的半径:";
cin >> dRadius;
if(! Data_Validation(p1,p2,dRadius))
{
cout << endl << "数据不合理!\n";
exit();
}
}
【POJ 1981】Circle and Points&lpar;已知圆上两点求圆⼼坐标)
已知两点的经度和纬度,计算两点间的距离(php,javascript)
NX⼆次开发-UFUN已知两个向量⽅向求夹⾓⾓度UF_VEC3_angle_between NX9+VS2012 #include #include #include #include
【C语⾔】已知三⾓形三边长,求三⾓形⾯积
angular和angularjs⼀. 数学基础: 已知三⾓形的三边,计算三⾓形⾯积,需要⽤到海伦公式: 即p=(a+b+c)/2 ⼆. 算法: 输⼊三个边长,套⽤海伦公式计算⾯积,并输出. 可以先判断是否可以构成三⾓形,即任意两边之 ...
js已知A,B两点坐标,在线段AB上有C点,已知AC的距离,求C点的坐标
/** * @param {Number} _x1 A点坐标 * @param {Number} _y1 A点坐标 * @param {Number} _x2 B点坐标 * @param {Numbe ...
Codeforce 459A - Pashmak and Garden (已知两点求另外两点构成正⽅形)
Pashmak has fallen in love with an attractive girl called Parmida since one Today, Pashm ...
正⽅形已知两点对⾓线求另外两点(POJ2002)
⾄于为什么,上图.转载于MZW_BG 枚举正⽅形的⼀条边,此时有上正⽅形和下正⽅形. 最后正⽅形个数/4,因为每个正⽅形被枚举了4条边
#include u ...
ACM题⽬————已知前序和中序求后序
#include #include #include using namespace std; ], z ...
已知两点经纬度&lpar;百度地图),⽤js求解两点之间的⾓度
随机推荐
eclipse启动tomcat⽆法访问
简单的sql server连接
private string constring="data source=112.74.73.122;initial catalog=qzyData;user id=sa;password ...
使⽤T4模板合并js⽂件
不知道该怎么表达,或许直接贴图贴代码更好 前因:在第⼀个使⽤angularjs的项⽬中我将所有的controller写到⼀个⽂件⾥⾯,深知维护起来那滋味,所以再次使⽤angularjs的时候,我便把所 ...
android 5.0以下版本使⽤atof报错解决
经过测试,如果⼿机系统在5.0之下,项⽬project.properties的target若在5.0以上(android-20), NDK 使⽤atof就会报错: cannot locate symb ...
stock 当天盘势
看盘 (⼀)怎样看⼤盘当天的指数收阴.收阳 投资者每天都看⼤盘,但多数⼈看不准⼤盘.⼤盘到底当天是收阴,还是收阳?我通过很长时间的记录.验证,发现⼤盘在正常时间内,收阴.收阳是有规律的.我判断的准确率 ...
js和jquery设置disabled属性为true使按钮失效
设置disabled属性为true即为不可⽤状态. JS: ElementByIdx("btn").disabled=true;  Jquery: $(& ...
spark集搭建
⽂中的所有操作都是在之前的⽂章scala的安装及使⽤⽂章基础上建⽴的,重复操作已经简写: 配置中使⽤了
master01.slave01.slave02.slave03: ⼀.虚拟机中操作(启动⽹卡)s ...
ENQ: KO - FAST OBJECT CHECKPOINT tips
ENQ: KO - FAST OBJECT CHECKPOINT tips Question: What does the wait event ENQ: KO - FAST OBJECT CHECK ...
启⽤SharePoint 的 web application下⾯所有站点&ldquo&semi;备⽤语⾔&rdquo;
clear $PSSnapin = Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-N ...
Asp.Net Core发布绑定域名和端⼝

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。