Malfatti Circles - POJ 3808 几何
来源:互联网 发布:mac系统PPT怎么转换 编辑:程序博客网 时间:2024/06/06 07:11
Malfatti Circles
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 239 Accepted: 122 Special Judge
Description
The configuration of three circles packed inside a triangle such that each circle is tangent to the other two circles and to two of the edges of the triangle has been studied by many mathematicians for more than two centuries. Existence and uniqueness of such circles for an arbitrary triangle are easy to prove. Many methods of numerical calculation or geometric construction of such circles from an arbitrarily given triangle have been discovered. Today, such circles are called the Malfatti circles.
Figure 7 illustrates an example. The Malfatti circles of the triangle with the vertices (20, 80), (-40, -20) and (120, -20) are approximately
the circle with the center (24.281677, 45.219486) and the radius 21.565935,
the circle with the center (3.110950, 4.409005) and the radius 24.409005, and
the circle with the center (54.556724, 7.107493) and the radius 27.107493.
Figure 8 illustrates another example. The Malfatti circles of the triangle with the vertices (20, -20), (120, -20) and (-40, 80) are approximately
the circle with the center (25.629089, -10.057956) and the radius 9.942044,
the circle with the center (53.225883, -0.849435) and the radius 19.150565, and
the circle with the center (19.701191, 19.203466) and the radius 19.913790.
Your mission is to write a program to calculate the radii of the Malfatti circles of the given triangles.
Figure 7 illustrates an example. The Malfatti circles of the triangle with the vertices (20, 80), (-40, -20) and (120, -20) are approximately
the circle with the center (24.281677, 45.219486) and the radius 21.565935,
the circle with the center (3.110950, 4.409005) and the radius 24.409005, and
the circle with the center (54.556724, 7.107493) and the radius 27.107493.
Figure 8 illustrates another example. The Malfatti circles of the triangle with the vertices (20, -20), (120, -20) and (-40, 80) are approximately
the circle with the center (25.629089, -10.057956) and the radius 9.942044,
the circle with the center (53.225883, -0.849435) and the radius 19.150565, and
the circle with the center (19.701191, 19.203466) and the radius 19.913790.
Your mission is to write a program to calculate the radii of the Malfatti circles of the given triangles.
Input
The input is a sequence of datasets. A dataset is a line containing six integers x1, y1, x2, y2, x3 and y3 in this order, separated by a space. The coordinates of the vertices of the given triangle are (x1, y1), (x2, y2) and (x3, y3), respectively. You can assume that the vertices form a triangle counterclockwise. You can also assume that the following two conditions hold.
All of the coordinate values are greater than -1000 and less than 1000.
None of the Malfatti circles of the triangle has a radius less than 0.1.
The end of the input is indicated by a line containing six zeros separated by a space.
All of the coordinate values are greater than -1000 and less than 1000.
None of the Malfatti circles of the triangle has a radius less than 0.1.
The end of the input is indicated by a line containing six zeros separated by a space.
Output
For each input dataset, three decimal fractions r1, r2 and r3 should be printed in a line in this order separated by a space. The radii of the Malfatti circles nearest to the vertices with the coordinates (x1, y1), (x2, y2) and (x3, y3) should be r1, r2 and r3, respectively.
None of the output values may have an error greater than 0.0001. No extra character should appear in the output.
None of the output values may have an error greater than 0.0001. No extra character should appear in the output.
Sample Input
20 80 -40 -20 120 -2020 -20 120 -20 -40 800 0 1 0 0 10 0 999 1 -999 1897 -916 847 -972 890 -925999 999 -999 -998 -998 -999-999 -999 999 -999 0 731-999 -999 999 -464 -464 999979 -436 -955 -337 157 -4390 0 0 0 0 0
Sample Output
21.565935 24.409005 27.1074939.942044 19.150565 19.9137900.148847 0.207107 0.2071070.125125 0.499750 0.4997500.373458 0.383897 0.1004560.706768 0.353509 0.353509365.638023 365.638023 365.601038378.524085 378.605339 378.60533921.895803 22.052921 5.895714
题意:给你三角形的三个点,里面有三个相切的圆,已知其唯一性,求三个圆的半径。
思路:几何弱渣,借鉴下别人的图吧。
AC代码如下;
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;struct Point{ double x,y;};double dis(Point a,Point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}Point A,B,C,I;double a,b,c,s,r,ia,ib,ic,r1,r2,r3;int main(){ int i,j,k; while(~scanf("%lf%lf%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y)) { if(A.x==0 && A.y==0 && B.x==0 && B.y==0 && C.x==0 && C.y==0) break; a=dis(B,C); b=dis(A,C); c=dis(A,B); s=(a+b+c)/2; I.x=(a*A.x+b*B.x+c*C.x)/(a+b+c); I.y=(a*A.y+b*B.y+c*C.y)/(a+b+c); r=sqrt(s*(s-a)*(s-b)*(s-c))/s; ia=dis(I,A); ib=dis(I,B); ic=dis(I,C); r1=r/(2*(s-a))*(s-r-(ib+ic-ia)); r2=r/(2*(s-b))*(s-r-(ia+ic-ib)); r3=r/(2*(s-c))*(s-r-(ia+ib-ic)); printf("%.6f %.6f %.6f\n",r1,r2,r3); }}
0 0
- Malfatti Circles - POJ 3808 几何
- POJ 3808 Malfatti Circles(计算几何)
- poj 3808 Malfatti Circles
- uva 1447 - Malfatti Circles(几何+二分)
- Malfatti Circles
- uva 1447 - Malfatti Circles
- LA4642 Malfatti Circles Malfatti 定理 Tokyo 2009
- UVA LIVE-4642 - Malfatti Circles
- UVA LIVE-4642 - Malfatti Circles
- UVALive 4642 (B) Malfatti Circles
- Ex-circles - UVa 11731 几何
- In-circles Again(简单几何)
- uva 11731 - Ex-circles(几何)
- In-circles Again(计算几何基础)
- In-circles Again (计算几何)
- Circles
- ZOJ 1608 Two Circles and a Rectangle(简单计算几何)
- uva 375 Inscribed Circles and Isosceles Triangles 简单几何
- linux 下gprof 和 oprofile 分析程序性能工具
- 2014总结2015展望
- 你是什么命,好玩的很
- bzoj2631: tree LCT
- AutoCAD视口及布局的说明
- Malfatti Circles - POJ 3808 几何
- 公司考核题-(ORACLE篇二)
- UVA 10066 The Twin Towers
- 【BZOJ 3239】 Discrete Logging
- Linux IPC实践(1) -- 概述
- MAC PRO使用心得
- hdu3294---Girls' research
- IOS 自定义控件之UIAlertview
- Linux IPC实践(2) --匿名PIPE