Blocked View

Problem #35

Tags: geometry apollonius

Who solved this?

Previous:Ant Colonies Next:Flat Belts


James is a child playing in the forest nearby his house. He climbs a nearby hill which is clear of trees and builds a small fort there, from which he has a clear 360° view in all directions. He spends many childhood days playing on his fort, and even plants a pinecone nearby with the plan of one day hanging a swing from the future pine tree's branches, but soon he grows older and his attention becomes focused on more mature pursuits.

Many years later after James has grown into an old man, he returns to the hill and is surprised to see that his childhood fort is still standing! Even more, he finds that the pinecone that he planted all those years ago has grown into an absolutely massive pine tree, having a cylindrical trunk too large for James to wrap his arms around! However, the tree now blocks quite a bit of the view from the fort, as anything on the other side of the trunk is obviously hidden from James's view standing atop the fort.

Fort and Tree

An Green observer looking at a large Blue tree.
The Red arc indicates the portion of the observer's vision which is blocked by the tree.
(In this pictured example, the angle is 45°)

Given the positions of the fort and the tree, how much of James's view will be blocked by the tree?

Problem Statement

Input Data
First line will be Q, the quantity of testcases.
Q lines will then follow, each with a testcase in the format r xt yt xf yf, where r is the radius of the tree, (xt, xy) are the coordinates of the tree's centerpoint, and (xf, yf) are the coordinates of an observer standing on the fort.

Answer
Should consist of Q space-separated values, corresponding to the portion of the observer's view which would be blocked by the tree.
Provide answers in units of degrees.
Error should be less than 1e-3.

Example

input data:
2
1 0 0 0 2
1.2 -3.4 5.6 7.8 -9.0

answer:
60 7.478
You need to login to get test data and submit solution.