Imagine an infinite plane existing in three-dimensional coordinate space.
Extending infinitely, the plane must intersect each of the X, Y, and Z axes at some point
(let's assume for now that the plane is not parallel to any of those axes).
If we choose three points such that each lies on an axis - (a, 0, 0); (0, b, 0); (0, 0, c) - we can easily create a formula in "intercept-form" which defines the coordinates of any point on the plane.
$$ \Large 1 = \frac{x}{a} + \frac{y}{b} + \frac{z}{c} $$
Figuring out any specific coordinate by hand would require some rearranging to solve the above equation and obtain the exact values, but it implicitly works. It's a fast method to create an equation intersecting three points, as long as each of those three points rests on each axis.
But what if we wanted to define the plane which intersects any three points?
You will be given the x, y, z coordinates of three points.
You must find the parameters a, b, c of the intercept-form equation defining the plane which intersects all 3 points.
It is guaranteed that the plane which intersects the three lines will not be parallel to any axis.
Input Data
First line will be Q, the quantity of testcases.
Q lines will follow, each with a testcase in the form x0 y0 z0 x1 y1 z1 x2 y2 z2 describing three points.
Answer
Should consist of 3 * Q space-separated values, corresponding to the a b c parameters of the plane which intersects the points in each testcase.
Error should be less than 1e-4.
Example
input data:
3
1 0 0 0 1 0 0 0 1
7 5 3 8 6 9 1 4 2
-1 2 3 4 -5 6 7 8 -9
answer:
1 1 1 -25 3.571 -25 5.455 4.286 4.186