UVALive 4642 (B) Malfatti Circles
来源:互联网 发布:广告公司p图软件 编辑:程序博客网 时间:2024/06/05 04:46
公式:https://en.wikipedia.org/wiki/Malfatti_circles?setlang=zh-cn
// s=(a+b+c)/2;// 内心r=sqrt(s*(s-a)*(s-b)*(s-c))/s;// 内心坐标(a*x1+b*x2+c*x3)/(2*s),(a*y1+b*y2+c*y3)/(2*s);// d=MA,e=MB,f=MC// r1=r/(2*(s-a))*(s+d-r-e-f)// r2=r/(2*(s-b))*(s+e-r-d-f)// r3=r/(2*(s-c))*(s+f-r-d-e)#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<complex>using namespace std;typedef complex<double> Point;typedef Point Vector ;const double eps=1e-6;int dcmp(double x){ if(fabs(x)<eps) return 0; else return x<0?-1:1;}double Dot(Vector A,Vector B){ return real(conj(A)*B);}double Cross(Vector A,Vector B){ return imag(conj(A)*B);}Vector Rotate(Vector A,double rad){ return A*exp(Point(0,rad));}double Length(Vector A){ return sqrt(Dot(A,A));}double Length(Point A,Point B){ return Length(B-A);}int main(){ double a,b,c,d,e,f,r,r1,r2,r3,s; Point A,B,C,M; double x1,y1,x2,y2,x3,y3; while(scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3)) { if(!dcmp(x1)&&!dcmp(y1)&&!dcmp(x2)&&!dcmp(y2)&&!dcmp(x3)&&!dcmp(y3)) break; // printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",x1,y1,x2,y2,x3,y3); A=Point(x1,y1),B=Point(x2,y2),C=Point(x3,y3); //cout<<A<<" "<<B<<" "<<C<<endl; a=Length(B,C),b=Length(A,C),c=Length(A,B); s=(a+b+c)/2; //cout<<s<<endl; r=sqrt(s*(s-a)*(s-b)*(s-c))/s; M=Point((a*x1+b*x2+c*x3)/2/s,(a*y1+b*y2+c*y3)/2/s); d=Length(A,M); e=Length(B,M); f=Length(C,M); r1=(r/2/(s-a))*(s+d-r-e-f); r2=(r/2/(s-b))*(s+e-r-d-f); r3=(r/2/(s-c))*(s+f-r-d-e); printf("%.6lf %.6lf %.6lf\n",r1,r2,r3); } return 0;}
阅读全文
0 0
- UVALive 4642 (B) Malfatti Circles
- UVA LIVE-4642 - Malfatti Circles
- UVA LIVE-4642 - Malfatti Circles
- Malfatti Circles
- poj 3808 Malfatti Circles
- uva 1447 - Malfatti Circles
- LA4642 Malfatti Circles Malfatti 定理 Tokyo 2009
- Malfatti Circles - POJ 3808 几何
- POJ 3808 Malfatti Circles(计算几何)
- uva 1447 - Malfatti Circles(几何+二分)
- UVALive 5815 Pair of Touching Circles
- UVALive 4660 A+B
- UVaLive 6482 A+B
- Circles
- UVALive 4636 B - Cubist Artwork
- UVA 375 (暑假-几何 -B - Inscribed Circles and Isosceles Triangles)
- UVALive 6428A+B 【扩展欧几里得】
- Uvalive 6428 A+B(扩展欧几里得算法)
- 单源最短路径问题(带权图)
- 一个程序猿的随想1
- 提高工作、学习效率的几个自身感受
- React Native 原生UI组件的基本使用
- MFC 双缓冲技术和兼容DC
- UVALive 4642 (B) Malfatti Circles
- 深入浅出讲解:php的socket通信
- HttpClient访问报错 javax.net.ssl.SSLException: hostname in certificate didn't match
- 各种排序算法之插入排序
- 前端跨域大全
- MPAndroidChart—— pieChart 属性详解
- 有关windows钩子使用的两篇文章
- Qt之创建并使用静态链接库
- 100. Same Tree