Rocket Powered Hovercraft
Time limit2sMemory limit512 MB
Given a target (x, y), speed v, and turn rate w, find the minimum time for a hovercraft starting at the origin facing +X to reach the target.
Problem
You are programming an autonomous rocket powered hovercraft. The vehicle can travel very fast, but turning is difficult. Because it hovers, it turns by firing directional thrusters. The thrusters turn the vehicle whether it is moving forward or standing still.
The salt flats where you test the vehicle are mapped with a 2D Cartesian grid. The hovercraft starts at facing the positive direction. Your job is to move the vehicle to another point on the flats.
The hovercraft has a fixed ground speed of miles per second and a fixed rotation rate of radians per second. The rockets provide enough thrust to accelerate and decelerate almost instantly. The vehicle reaches its maximum speed right away and can stop from that speed just as quickly. Rotation works the same way: it can start turning at the fixed rate instantly and stop just as quickly. It can rotate either clockwise or counter-clockwise.
You must find the minimum time needed to bring the vehicle to the target. The control program may start forward motion, stop forward motion, start rotating, and stop rotating, but each of these actions happens exactly once. Starting and stopping forward motion is independent of starting and stopping rotation.
Input
Each test case consists of exactly two lines.
The first line contains two space-separated integers and (, ), the target location in miles.
The second line contains two space-separated real numbers with exactly two decimal places: () and (). Here is the fixed speed in miles per second, and is the fixed rotation rate in radians per second, in either direction.
Output
Print a single real number: the minimum time in seconds to bring the hovercraft from to . An answer is accepted if its absolute error is within .