public Matrix3f(Matrix3f rm) { for (int i = 0; i < 9; i++) { m_elements[i] = rm.getElement(i); } }
public void SetRotation(GK.Matrix3f Orientation) { float sy = Mathf.Sqrt(Orientation.getElement(0, 0) * Orientation.getElement(0, 0) + Orientation.getElement(1, 0) * Orientation.getElement(1, 0)); bool singular = sy < 1e-6; // If float x, y, z; if (!singular) { x = Mathf.Atan2(Orientation.getElement(2, 1), Orientation.getElement(2, 2)); y = Mathf.Atan2(-Orientation.getElement(2, 0), sy); z = Mathf.Atan2(Orientation.getElement(1, 0), Orientation.getElement(0, 0)); } else { x = Mathf.Atan2(-Orientation.getElement(1, 2), Orientation.getElement(1, 1)); y = Mathf.Atan2(-Orientation.getElement(2, 0), sy); z = 0; } Debug.Log("euler" + new Vector3(x, y, z)); transform.Rotate(new Vector3(x, y, z)); }
// returns diagonal of InertiaTensorMatrix public Vector3 GetInertiaTensor() { return(new Vector3(BodyInertiaInverseTensor.getElement(0, 0), BodyInertiaInverseTensor.getElement(1, 1), BodyInertiaInverseTensor.getElement(2, 2))); }