Contraband
Time limit1sMemory limit128 MB
Given three sight lines and confidence weights from fixed stations, compute the point that minimizes the weighted sum of squared distances to the lines.
Problem
Someone reported that an aircraft approaching the airport dropped an object while crossing the bay. The police think the object was contraband left for a confederate to pick up, so they want to watch every aircraft that could have dropped it whenever one approaches the airport over the bay again. Three observation stations around the bay have night vision equipment.
Place station 0 at the origin, with measured east and measured north. Station 1 is 3.715 km east and 1.761 km north of station 0, and station 2 is 2.894 km east and 2.115 km south of station 0. Every distance is in kilometers.
When a suspect aircraft crosses the bay, the three observers stay in contact and follow it with the night vision equipment. An observer who sees something fall records a direction to the object and a confidence level for that direction. The confidence level is a value from 0 to 1. A value of 0 means the observer was more or less pointing at the aircraft, and 1 means the observer was pointing at the splash where the object hit the water.
The three sight lines usually miss a common point and form a triangle instead. The estimate of the actual position is the point that minimizes the squared distance to each line, weighted by :
Sight line passes through station along the direction that observer recorded, and is the perpendicular distance from to that line. Treat a sight line as a full line extending both ways, not a ray.
Given the three directions and the three confidence levels, write a program that computes the point minimizing the sum above.
Input
The first line contains the number of data sets . Each of the next lines holds one data set, and every data set is processed the same way and independently.
A data set is a single line: the data set number , then six space separated floating point values, in the order , , , , , . is the bearing measured at station in degrees clockwise from north . is the confidence level of observer .
No input has all three sight lines pointing along parallel directions, so the minimizing point is always unique.
Output
Print one line for each data set. Each line holds the data set number exactly as it was given, one space, then and separated by a space. is the distance east of station 0 and is the distance north (positive) or south (negative) of station 0, both in kilometers.
Round and to three decimal places and always print all three digits. Both coordinates sit at least away from a rounding boundary, so no input leaves the rounding direction ambiguous. A coordinate that rounds to zero is printed as 0.000, never -0.000.