Problem: Barycentric Planet
Background:
In the galaxy of Triangulum, there's a unique planet named Barycentra. This planet has a fascinating property. Whenever three spaceships (let's label them A, B, and C) land on its surface at three distinct points, a mysterious energy point, the "Energy Center" E, forms somewhere on the planet's surface.
The local inhabitants have observed that the position of this Energy Center E is not random, but it follows the principles of Barycentric Lagrange Interpolation.
You are provided the coordinates of the three spaceships and some weights associated with them. Your task is to determine the position of the Energy Center E.
Input:
Three lines, each containing two integers, represent the x,yx, yx,y coordinates of the three spaceships A, B, and C. It's guaranteed that the three points are distinct and form a triangle.
A fourth line containing three real numbers, wAw_AwA, wBw_BwB, and wCw_CwC, which are the weights associated with the spaceships A, B, and C, respectively.
Output:
A single line containing two real numbers, the x,yx, yx,y coordinates of the Energy Center E.
Constraints:
\[|x_i|, |y_i| \leq 10^{15}\] \[0 \leq w_A, w_B, w_C < 10^{15}\] \[w_A + w_B + w_C \neq 0\]
Sample Input:
0 0
2 0
0 2
1 2 3
Sample Output:
(0.6666666666666666, 1.0000000000000000)
Explanation:
The coordinates of the Energy Center E can be calculated using Barycentric Lagrange Interpolation. When the provided values are plugged in, the coordinates obtained are \[x_E = 0.6666666666666666\] and \[y_E = 1.0\]. The solutions must ensure their calculations have precision up to \[10^{-16}\] to be deemed correct.
Comments