Problem H
Circumsphere
You are given four points in space (i.e. $\mathbb {R}^3$). The points are not coplanar. In other words, there is no plane in space that contains all four points.
It is guaranteed that under such assumption, there exists a (unique) sphere whose surface touches all four points. Find the coordinates of the centre of the sphere.
Input
The input consists of four lines. Line $i$ consists of three integers $x_ i$, $y_ i$, $z_ i$, representing the coordinates $(x_ i, y_ i, z_ i)$ of point $i$.
For all test cases, $-100 \leq x_ i, y_ i, z_ i \leq 100$.
Output
Output three numbers (not necessarily integers) $x_ c$, $y_ c$, $z_ c$, representing the coordinates $(x_ c, y_ c, z_ c)$ of the centre of the sphere that touches all four points.
Let the jury’s answer be $(x_ j, y_ j, z_ j)$. Your answer will be considered as correct if and only if
\[ \sqrt {(x_ j - x_ c)^2 + (y_ j - y_ c)^2 + (z_ j - z_ c)^2} < 10^{-4}. \]Sample Input 1 | Sample Output 1 |
---|---|
0 0 0 1 0 0 0 1 0 0 0 1 |
0.5 0.5 0.5 |
Sample Input 2 | Sample Output 2 |
---|---|
-1 0 0 1 0 0 0 1 0 0 0 1 |
0.0 0.0 -0.0 |
Sample Input 3 | Sample Output 3 |
---|---|
0 0 0 7 0 0 0 6 0 1 -2 -3 |
3.5 3.0 -3.16666667 |