calculate quaternion from euler angles

make sure scalar component is positive