示例#1
0
        //---------------------------------------------------------------------------------------
        //Аппроксимировать
        public EllipseDescriptor Approximate(Point2D[] points)
        {
            RealMatrix matrixD           = this.CreateMatrixD(points);
            RealMatrix transposedMatrixD = matrixD.GetTransposedMatrix();
            RealMatrix matrixS           = transposedMatrixD * matrixD;

            double[] eigenValues         = this.CalculateEigenValues(matrixS);
            double[] absoluteEigenValues = ArrayOperator.GetAbsoluteValues(eigenValues);

            int minAbsoluteEigenValueIndex = ArrayOperator.GetMinValueIndex(absoluteEigenValues);

            double     lambda  = eigenValues[minAbsoluteEigenValueIndex];
            RealMatrix matrixA = this.CreateMatrixA(matrixS, lambda);

            double[ , ] dataArrayMatrixA = matrixA.GetDataArray();
            double[] dataArrayVectorB = new double[] { 1, 0, 0, 0, 0, 0 };
            double[] values           =
                this.SolveLinearSystem(dataArrayMatrixA, dataArrayVectorB);

            EllipseDescriptor ellipse = this.CreateEllipseDescriptor(values);

            return(ellipse);
        }