//! sets new Quaternion based on euler angles
public static Quaternion FromEulerAngles(float x, float y, float z)
{
Quaternion t_tmp = new Quaternion();
//TODO Duplicated code (Method Set(x,y,z))
double angle;
angle = x * 0.5;
double sr = (float)Math.Sin(angle);
double cr = (float)Math.Cos(angle);
angle = y * 0.5;
double sp = (float)Math.Sin(angle);
double cp = (float)Math.Cos(angle);
angle = z * 0.5;
double sy = (float)Math.Sin(angle);
double cy = (float)Math.Cos(angle);
double cpcy = cp * cy;
double spcy = sp * cy;
double cpsy = cp * sy;
double spsy = sp * sy;
t_tmp.X = (float)(sr * cpcy - cr * spsy);
t_tmp.Y = (float)(cr * spcy + sr * cpsy);
t_tmp.Z = (float)(cr * cpsy - sr * spcy);
t_tmp.W = (float)(cr * cpcy + sr * spsy);
t_tmp.Normalize();
return t_tmp;
}