Precise commutative rotation on global X and Y I am trying to find a way to rotate a vector with python so that the angle between the z axis and this vector is exactly _x° from the right ortho view and the angle between the z axis and this vector is exactly _y° from the front ortho view.

[![Front ortho][1]][1][![Right ortho][2]][2]

Using the XYZ Euler rotation system dont look a good way to perform such a rotation since an y rotation will modify the initial x rotation, and rotating around the local y axis after the first x rotation will keep a valid x rotation but give an invalid _y angle from the global point of view. 

What i am trying to find is an Axis angle, (or quaternion) were the rotation axis is a combination of global x and y vector ([1,0,0] and [0,1,0]) and a corresponding angle. 

In this case if _x==_y , the resulting rotation vector will be [0.5,0.5,0.0] and the corresponding angle will be a little more than _x. But i have some difficulties to figure out the maths to find this vector and this angle for any _x and y between 0 and 89.99° (90 would be a problem for sure), or a built in function in Blender that could give this exact result. 

NB: The example given here is based on blender global axis but my problem is actualy to rotate around any two perpendicular vectors (local axis of an object). A basic solution in global referential would be enough to find the solution to my initial problem.
The angle between a vector and the Z axis and a vector in the right ortho view appears to be such that tan(θ)=y/z.  The angle between a vector and the Z axis in the front ortho view appears to be such that tan(φ)=x/z.

As long as θ and φ aren't going to be π/2 you can pretty easily set z=1 and then y=tan(θ) and x=tan(θ) .  If the π/2 is a possibility you'll want to have code to check for that case and use an alternate formula like tan(π/2-θ) = z/y and similar for φ.

So after following that procedure we have an &lt;x,y,z&gt;, but since you talk about rotations, I assume you have an object with some feature you want to align with this vector.

To accomplish this requires an understanding of quaternions, or you just copy the code from http://web.purplefrog.com/~thoth/blender/python-cookbook/rotate-to-match.html

import bpy

from mathutils import *
from math import *

def compute_rotation(src_vec, dest_vec):

    a = src_vec.normalized()
    b = dest_vec.normalized()

    c = a.cross(b)

    theta = asin(c.magnitude)

    if (c.magnitude&gt;0):
        d = c.normalized()
        st2 = sin(theta/2)
        q = Quaternion( [cos(theta/2), st2*d.x, st2*d.y, st2*d.z] )
    else:
        q = Quaternion( [1,0,0,0] )

    return q

obj = bpy.context.active_object

obj.rotation_quaternion = compute_rotation(Vector([1,1,1]), Vector([1,0,0]))


The src_vec is a vector on the object (it might be the X, Y or Z axis, or some other important feature like an antenna) and dest_vec is the world space vector we want that source vector to be rotated to match.

Another thing to consider is that there are many orientations that are compatible with dest_vec = q*src_vec (just imagine spinning the object around src_vec), but the q calculated by this procedure will have the minimum θ.  

To see how messy things can get, read http://web.purplefrog.com/~thoth/blender/python-cookbook/narratives/animate-random-spin.html