多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > POJ 3808 Malfatti Circles(計算幾何)

POJ 3808 Malfatti Circles(計算幾何)

來源:程序員人生   發布時間:2015-05-19 08:12:53 閱讀次數:2636次
Malfatti Circles
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 250   Accepted: 125   Special Judge

Description

The con?guration 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), (⑷0, ⑵0) and (120, ⑵0) 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, ⑵0), (120, ⑵0) and (⑷0, 80) are approximately 
the circle with the center (25.629089, ⑴0.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 ⑴000 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.

Sample Input

20 80 ⑷0 ⑵0 120 ⑵0 20 ⑵0 120 ⑵0 ⑷0 80 0 0 1 0 0 1 0 0 999 1 ⑼99 1 897 ⑼16 847 ⑼72 890 ⑼25 999 999 ⑼99 ⑼98 ⑼98 ⑼99 ⑼99 ⑼99 999 ⑼99 0 731 ⑼99 ⑼99 999 ⑷64 ⑷64 999 979 ⑷36 ⑼55 ⑶37 157 ⑷39 0 0 0 0 0 0

Sample Output

21.565935 24.409005 27.107493 9.942044 19.150565 19.913790 0.148847 0.207107 0.207107 0.125125 0.499750 0.499750 0.373458 0.383897 0.100456 0.706768 0.353509 0.353509 365.638023 365.638023 365.601038 378.524085 378.605339 378.605339 21.895803 22.052921 5.895714


題意:給出1個3角形的3個頂點的坐標,求3角形的3個內切圓,它們兩兩相切,并且每一個頂點附近的圓和連接這個頂點的兩條邊也相切。求著3個內切圓的半徑。

分析:套公式。

其中r為3角形內切圓的半徑,s為半周長。

#include <cstdio> #include <cmath> using namespace std; struct Point { double x, y; } A, B, C, I; double get_dis(Point p1, Point p2) { return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); } int main() { 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; double a = get_dis(B, C); double b = get_dis(A, C); double c = get_dis(A, B); double 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); // 內切圓圓心坐標 double r = sqrt((s - a) * (s - b) * (s - c) / s); // 內切圓半徑 double IA = get_dis(A, I); double IB = get_dis(B, I); double IC = get_dis(C, I); double r1 = r / (2 * (s - a)) * (s - r + IA - IB - IC); double r2 = r / (2 * (s - b)) * (s - r + IB - IA - IC); double r3 = r / (2 * (s - c)) * (s - r + IC - IA - IB); printf("%.6lf %.6lf %.6lf ", r1, r2, r3); } return 0; }


更多解釋請見http://en.wikipedia.org/wiki/Malfatti_circles

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 欧美超清性videosfree | 东京干男人都知道的网站 | 日韩欧美一区二区三区在线视频 | 欧美男人天堂 | 亚洲不卡一区二区三区 | 国产女人18毛片水真多18精品 | 国产成人综合久久精品亚洲 | www久久精品| 一级免费毛片 | 国产专区在线视频 | 亚洲第一成年人网站 | 手机在线看片国产日韩生活片 | 亚洲综合爱爱久久网 | 国产a级午夜毛片 | 天堂最新版在线www在线 | 日韩一区二区精品久久高清 | 欧美性大战久久久久久 | 亚洲综合精品成人 | 亚洲欧美日韩国产精品 | 欧洲妇女成人淫片aaa视频 | 一二三四在线手机观看视频 | 91麻豆精品国产综合久久久 | 午夜影视福利 | 亚洲另类天堂 | 亚洲第成色999久久网站 | 欧美日韩三区 | 毛片毛片 | 国产女人体一区二区三区 | 日本无卡码高清免费观看 | 亚洲国产成人久久笫一页 | 欧美精品网站 | 福利在线网站 | 色成人亚洲 | 欧美黑人在线视频 | 国产或人精品日本亚洲77美色 | 巨大欧美黑人xxxxbbbb | 亚洲免费黄色网址 | 老王午夜69精品影院 | 尤物免费在线视频 | 老司机午夜免费福利 | 欧美一区二区三区网站 |