Class to perform a Procrustes Analysis

Procrustes analysis is a form of statistical shape analysis used to analyze the distribution of a set of shapes. It allows to compare shapes (datasets) that have different rotations, scales and positions. It defines a measure called Procrustes distance that is an image of how different the shapes are.

References: Wikipedia contributors. "Procrustes analysis" Wikipedia, The Free Encyclopedia, 21 Sept. 2015. Available at: https://en.wikipedia.org/wiki/Procrustes_analysis Amy Ross. "Procrustes Analysis" Available at :

Inheritance: IAnalysis
        public void ProcrustesAnalysisConstructorTest()
        {
            // Define a square
            double[,] square = { { 100, 100 },
                                 { 300, 100 },
                                 { 300, 300 },
                                 { 100, 300 }
                               };
            // Define a diamond with different orientation and scale
            double[,] diamond = { { 170, 120 },
                                  { 220, 170 },
                                  { 270, 120 },
                                  { 220, 70 }
                                };

            // Create the Procrustes analysis object
            ProcrustesAnalysis pa = new ProcrustesAnalysis(square, diamond);

            // Compute the analysis on the square and the diamond
            pa.Compute();

            // Assert that the diamond is a square
            Assert.AreEqual(0.0, pa.ProcrustesDistances[0, 1], 1E-11);

            // Transform the diamond to a square
            double[,] diamond_to_a_square = pa.ProcrustedDatasets[1].Transform(pa.ProcrustedDatasets[0]);

            // Check that the diamond matches (quite) perfectly the square
            for (int i = 0; i < diamond_to_a_square.GetLength(0); i++)
            {
                for (int j = 0; j < diamond_to_a_square.GetLength(1); j++)
                {
                    Assert.AreEqual(diamond_to_a_square[i, j], square[i, j], 1E-11);
                }
            }
        }