tetrahedron
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 569 Accepted Submission(s): 219
Problem Description
Given four points ABCD, if ABCD is a tetrahedron, calculate the inscribed sphere of ABCD.
Input
Multiple test cases (test cases ≤100).
Each test cases contains a line of 12 integers [−1e6,1e6] indicate the coordinates of four vertices of ABCD.
Input ends by EOF.
Output
Print the coordinate of the center of the sphere and the radius, rounded to 4 decimal places.
If there is no such sphere, output “O O O O”.
Sample Input
0 0 0 2 0 0 0 0 2 0 2 0
0 0 0 2 0 0 3 0 0 4 0 0
Sample Output
0.4226 0.4226 0.4226 0.4226
O O O O
Author
HIT
Source
2016 Multi-University Training Contest 1
题意:给你四个点,让你判断是否能形成四面体,如果能形成,求出内切球球心和半径。
思路:因为四个点有可能会形不成四面体,当发生这种情况的时候,肯定会有至少3个点在同一平面,所以说我们要先确定一个平面,然后判断四点共面
1.任取三个点,判断是否共线,如果存在3个点共线,则必不可能形成四面体。
2.当满足1后,判断第四个顶点距离底面的距离,如果小于eps,说明四点共面,则必不可能形成四面体,点面距离公式为:
其中 P 为所求点,
3.当1、2都满足的时候,说明可以形成四面体,就要求它的内切球球心了,根据公式得:球心坐标(X,Y,Z),求法为: