Ski Jump

Time limit2sMemory limit128 MB

Problem

Ski jumping is one of the most popular winter sports. To keep athletes safe, the international ski federation sets maximum allowed values for the landing speed and the landing angle. Given the profile of a newly built ski-jumping venue, and assuming the athlete starts from the highest point of the in-run, write a program that computes the landing position, the landing speed, and the landing angle.

Use the following simplified physics. Set up a coordinate system whose $x$-axis is horizontal, with the origin directly below the take-off point, at the top of the landing hill. Heights are measured upward from the flat outrun at the bottom of the hill. Friction and air resistance are ignored, and $g = 9.81\ \mathrm{m/s^2}$.

The landing hill, described by its height above the outrun as a function of the horizontal distance $x$, is $$h(x)=\begin{cases} H\left(1-\dfrac{2x^2}{L^2}\right) & 0\le x\le \dfrac{L}{2}\ 2H\left(\dfrac{x}{L}-1\right)^2 & \dfrac{L}{2}\le x\le L\ 0 & x\ge L \end{cases}$$ where $H$ is the height and $L$ is the width of the hill. The top of the hill (at $x=0$) is at height $H$, and the hill descends to the flat outrun (height $0$) at $x=L$.

The take-off point is at $x=0$, at height $H+p$; that is, it lies $p$ above the top of the hill.

Starting from rest at the top of the in-run, whose vertical drop down to the take-off point is $j$, the athlete leaves the take-off point moving horizontally. By conservation of energy the take-off speed is $v_0=\sqrt{2gj}$, so the flight path is the parabola $$y(x) = (H+p) - \frac{g,x^2}{2v_0^2}.$$

The athlete lands at the first point where the flight path meets the hill, i.e. the smallest $x>0$ with $y(x)=h(x)$. Let $l$ be that horizontal landing distance and $y_l=h(l)$ the landing height.

Output three quantities:

  1. the horizontal landing position $l$;
  2. the landing speed $|v_l|$ (m/s), which by conservation of energy equals $\sqrt{2g,(j+p+H-y_l)}$;
  3. the landing angle $\alpha$ (in degrees): the angle between the athlete's velocity vector at the moment of landing and the tangent to the hill at the landing point.

Input

The first line contains the number of test cases $t$ ($0 < t < 160000$). Each of the next $t$ lines contains four integers $j$, $p$, $H$, $L$ ($0 < j, p, H, L \le 500$). All values are given in meters.

Output

For each test case print, on its own line, the landing position $l$, the landing speed $|v_l|$, and the landing angle $\alpha$ (in degrees), separated by single spaces. Print every value rounded to exactly six digits after the decimal point.

Hint

The landing angle $\alpha$ is the angle between two vectors: the athlete's velocity at landing and the direction of the hill surface at that point. The dot product of two vectors $\mathbf{a}=(a_x,a_y)$ and $\mathbf{b}=(b_x,b_y)$ is $\mathbf{a}\cdot\mathbf{b}=a_xb_x+a_yb_y=|\mathbf{a}|,|\mathbf{b}|\cos\alpha$, from which $\alpha$ follows. Taking the tangent direction of the flight path as $(1, f'(l))$ and of the hill as $(1, h'(l))$ gives $$\cos\alpha=\frac{1+f'(l),h'(l)}{\sqrt{1+f'(l)^2},\sqrt{1+h'(l)^2}}.$$ Here $f'(x)=-\dfrac{g x}{v_0^2}$, and $h'(x)=-\dfrac{4Hx}{L^2}$ for $0\le x\le L/2$, $h'(x)=\dfrac{4H}{L}\left(\dfrac{x}{L}-1\right)$ for $L/2\le x\le L$, and $h'(x)=0$ for $x\ge L$.