public void CalculateAnglesFromMatrices() { this.Scale = this.Matrix.ExtractScale(); this.Translate = this.Matrix.ExtractTranslation(); Matrix4 mq = Matrix4.CreateFromQuaternion(this.Matrix.ExtractRotation()); double sy = Math.Sqrt(mq.M11 * mq.M11 + mq.M12 * mq.M12); bool singular = sy < 1e-6; if (!singular) { this.Rotate.X = DAE.GetSingle(Math.Atan2(mq.M23, mq.M33)); this.Rotate.Y = DAE.GetSingle(Math.Atan2(-mq.M13, sy)); this.Rotate.Z = DAE.GetSingle(Math.Atan2(mq.M12, mq.M11)); } else { this.Rotate.X = DAE.GetSingle(Math.Atan2(-mq.M32, mq.M22)); this.Rotate.Y = DAE.GetSingle(Math.Atan2(-mq.M13, sy)); this.Rotate.Z = 0; } }