% euler angles, theta in [0 2pi), phi in [0 pi) function tensor = gTensor3(e1, e2, v1) tensor = [e1 0 0; 0 e2 0; 0 0 e2]; v2 = rand(3,1); v2 = v2-(v1'*v2)*v1; v2 = v2/norm(v2); v = [v1, v2, cross(v1,v2)]; tensor=v*tensor*v';