public void Rescale() { Center(); Matrix <double> A = PositionMatrix(); Matrix <double> cov = 1.0f / ((float)A.RowCount) * A.Transpose() * A; Evd <double> eigen = cov.Evd(); MathNet.Numerics.LinearAlgebra.Vector <System.Numerics.Complex> eigenvals = eigen.EigenValues; double l1 = eigenvals[0].Real; //1 / Math.Sqrt(eigenvals[0].Real); double l2 = eigenvals[1].Real; //1 / Math.Sqrt(eigenvals[1].Real); double l3 = eigenvals[2].Real; // / Math.Sqrt(eigenvals[2].Real); Debug.Log("l1: " + l1 + ", l2: " + l2 + ", l3: " + l3); double vol = l1 * l2 * l3; double max = eigenvals.AbsoluteMaximum().Real; Debug.Log("max=" + max); //double det = cov.Determinant(); A = A / Math.Sqrt(max) * 0.2; Debug.Log(A); //Debug.Log("determinant:"); for (int i = 0; i < A.RowCount; i++) { poses_[i].Translation = new Vector3((float)A[i, 0], (float)A[i, 1], (float)A[i, 2]); } /* Matrix<double> A = PositionMatrix(); * Matrix<double> cov = 1.0f / ((float)A.RowCount ) *A.Transpose() * A; * * * Debug.Log(cov.ToString()); * Evd<double> eigen = cov.Evd(); * Matrix<double> m = eigen.EigenVectors; * Matrix<double> points = m * A * m.Inverse(); * * points = points * cov.Determinant() / 10; * points = m * points * m.Inverse(); * for (int i = 0; i < points.RowCount; i++) * { * poses_[i].Translation =new Vector3((float)points[i, 0], (float)points[i, 1], (float)points[i, 2]); * }*/ /*double det = cov.Determinant(); * cov_rotated = cov_rotated / det; * Matrix<double> cov_recovered = m * cov_rotated * m.Inverse();*/ //Debug.Log(cov_recovered.ToString()); }