private void polarize(Svd<double> DG_SVD, out Vector3d RotationAxis, out double RotationAngle) { DenseMatrix RotationalMatrix = (DenseMatrix)DG_SVD.U.Multiply(DG_SVD.VT); Quaterniond RotationQ = OpenTK_To_MathNET.MatrixToQuaternion(RotationalMatrix); RotationQ.Normalize(); RotationQ.ToAxisAngle(out RotationAxis, out RotationAngle); }
private Matrix<double> orientationMatrix(Vector3 v1, Vector3 v2, Vector3 v3) { DenseMatrix result = new DenseMatrix(3, 3); //Edge 1 of the triangle Vector3 v21 = v2 - v1; //Edge 2 of the triangle Vector3 v31 = v3 - v1; //Normal vector of the triangle Vector3 n = Vector3.Cross(v21, v31); n.Normalize(); result.SetColumn(0, OpenTK_To_MathNET.Vector3ToVector(v21).ToArray()); result.SetColumn(1, OpenTK_To_MathNET.Vector3ToVector(v31).ToArray()); result.SetColumn(2, OpenTK_To_MathNET.Vector3ToVector(n).ToArray()); return result; }