/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static bool IsRigidTransformation(this TransformMatrix transform, double tolerance = Tolerance.Distance) { if (!transform.IsValid()) { BH.Engine.Reflection.Compute.RecordError("The given TransformMatrix is not valid."); return(false); } double[,] rotation = new double[3, 3]; for (int m = 0; m < 3; m++) { for (int n = 0; n < 3; n++) { rotation[m, n] = transform.Matrix[m, n]; } } double[,] transposed = rotation.Transpose(); double[,] multiplied = new double[3, 3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { multiplied[i, j] += rotation[i, k] * transposed[k, j]; } } } double[,] identity = new double[, ] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } }; return(multiplied.IsEqual(identity, tolerance) && Math.Abs(1 - rotation.Determinant()) <= tolerance); }