Under construction

Still being built. Things may change

Drone Control

Time limit2sMemory limit1024 MB

Summary
Given pitch, roll, and yaw targets, find four flap angles that produce them while minimizing the largest absolute flap angle.
Level

Medium6 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

You are designing a controller for an interesting aircraft called the Single Copter. It has only one propeller, but the outgoing air flow is further shaped by four flaps that control three Euler angles (pitch, roll, and yaw) that help maintain the requested orientation of the craft. Each flap can assume any angle requested by the flight controller, and when the flaps are at certain angles, they exert the requested forces on pitch, roll, and yaw.

PitchRollYaw

Figure D.1: Pitch, roll and yaw on a Single Copter

Define the angles of the flaps as nn, ee, ss, and ww (for north, east, south, and west, respectively). The forces in the directions of pitch, roll, and yaw are defined by the following equations.

p=e−wr=n−sy=n+e+s+w\begin{aligned} p &= e - w \\ r &= n - s \\ y &= n + e + s + w \end{aligned}

There are four variables and three constraints. From the perspective of aerodynamics, it makes sense to make the largest flap angle as small as possible, so you also want to minimise max⁡{∣n∣,∣e∣,∣s∣,∣w∣}\max\{|n|, |e|, |s|, |w|\}.

Find the best parameters to send to the Single Copter to achieve the desired pitch, yaw, and roll.

Input

The first line contains the number qq, 1≤q≤1041 \le q \le 10^4, the number of requests. Each of the next qq lines contains three real numbers pip_i, rir_i, yiy_i (−1≤pi,ri,yi≤+1-1 \le p_i, r_i, y_i \le +1).

Output

Output qq lines. On the ii-th line, output four numbers nin_i, eie_i, sis_i, wiw_i, separated by whitespace, as the solution for the ii-th request.

Your answer is correct if the resulting pitch, roll, and yaw differ from the requested values by at most 10−610^{-6}, and the maximum absolute value of the flap outputs does not exceed the true optimum by more than 10−610^{-6}.

Examples1

  1. Example 1

    Input
    8
    0 0 0
    1 0 0
    0 1 0
    0 0 1
    1 1 0
    1 0 1
    0 1 1
    1 1 1
    
    Expected output
    0.0 0.0 0.0 0.0
    0.0 0.5 0.0 -0.5
    0.5 0.0 -0.5 0.0
    0.25 0.25 0.25 0.25
    0.5 0.5 -0.5 -0.5
    0.5 0.5 0.5 -0.5
    0.5 0.5 -0.5 0.5
    0.75 0.75 -0.25 -0.25