# What is theoretical background of tilt angle calculation in attitude control?

Hello. Nowadays, I am trying to understand attitude control code. But I can’t understand the code that we can see below which is for calculating tilt angle. Why v.norm is the tilt angle? I want to know theoretical background of that code. Please help me.(y is roll angle and -x is pitch angle. Is it right?)

``````/*
* Input mapping for roll & pitch setpoints
* ----------------------------------------
* We control the following 2 angles:
* - tilt angle, given by sqrt(x*x + y*y)
* - the direction of the maximum tilt in the XY-plane, which also defines the direction of the motion
*
* This allows a simple limitation of the tilt angle, the vehicle flies towards the direction that the stick
* points to, and changes of the stick input are linear.
*/
_man_x_input_filter.setParameters(dt, _param_mc_man_tilt_tau.get());
_man_y_input_filter.setParameters(dt, _param_mc_man_tilt_tau.get());
_man_x_input_filter.update(_manual_control_setpoint.x * _man_tilt_max);
_man_y_input_filter.update(_manual_control_setpoint.y * _man_tilt_max);
const float x = _man_x_input_filter.getState();
const float y = _man_y_input_filter.getState();

// we want to fly towards the direction of (x, y), so we use a perpendicular axis angle vector in the XY-plane
Vector2f v = Vector2f(y, -x);
float v_norm = v.norm(); // the norm of v defines the tilt angle-
``````

I tried to find answer for several hours.
And I think this code is came from equation below which is induced by pythagorean theorem.

``````inclination = atan(sqrt(tan^2(roll)+tan^2(pitch)))
``````

In a small angle, we can assume tanX = X. So, finally we can induce PX4 code.