Exemplo n.º 1
0
        //----------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------
        public PlaneDescriptor Approximate(params Point3D[] points)
        {
            int        n       = 3;
            RealMatrix matrixA = new RealMatrix(points.Length, n);

            for (int index = 0; index < points.Length; index++)
            {
                Point3D point = points[index];

                matrixA[index, 0] = 1;
                matrixA[index, 1] = point.X;
                matrixA[index, 2] = point.Y;
            }

            RealVector vectorZ = new RealVector(SpaceManager.GetCoordinatesZ(points));

            RealMatrix transposedMatrixA  = matrixA.GetTransposedMatrix();
            RealVector coefficientsVector =
                (transposedMatrixA * matrixA).GetInverseMatrix() * transposedMatrixA * vectorZ;

            double d = coefficientsVector[0];
            double a = coefficientsVector[1];
            double b = coefficientsVector[2];

            double coefficientOfX = a / d;
            double coefficientOfY = b / d;
            double coefficientOfZ = -1 / d;
            double absoluteTerm   = 1;

            PlaneDescriptor planeDescriptor =
                new PlaneDescriptor(coefficientOfX, coefficientOfY, coefficientOfZ, absoluteTerm);

            return(planeDescriptor);
        }
        //---------------------------------------------------------------------------------------------
        //Матрица вращения для точек окружности
        private RealMatrix GetRotationMatrix(Point3D[] circlePoints)
        {
            //PlaneDescriptor circlePointsPlane = this.GetPlane( circlePoints );

            PlaneApproximator planeApproximator = new PlaneApproximator();
            PlaneDescriptor   circlePointsPlane = planeApproximator.Approximate(circlePoints);

            this.CirclePointsPlane = circlePointsPlane; //debug

            RealVector circlePointsPlaneNormalVector = circlePointsPlane.GetNormalVector();
            RealVector vectorN        = new RealVector(1, 1, 1);
            RealMatrix rotationMatrix = SpaceManager.GetRotationMatrixToTargetVector
                                            (circlePointsPlaneNormalVector, vectorN);

            return(rotationMatrix);
        }
Exemplo n.º 3
0
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------
        //------------------------------------------------------------------------------------------

        /*
         * //Значение целевой функции для интерферограмм при определенном значении гамма
         * //( Расстояния до средней точки )
         * private double GetTargetFunctionValue(
         *  double gamma, RealMatrix[] interferograms, BitMask2D bitMask
         * ) {
         *  RealMatrix[] gammaCorrectedInterferograms =
         *      this.GetGammaCorrectedInterferograms( gamma, interferograms );
         *  Point3D[] points = this.GetSpatialPoints( gammaCorrectedInterferograms, bitMask );
         *  Point3D midPoint = SpaceManager.GetMidPoint( points );
         *  double[] distancesFromPointsToMidPoint = SpaceManager.GetDistances( points, midPoint );
         *  double averageDistance = distancesFromPointsToMidPoint.Average();
         *  double targetFunctionValue =
         *      this.CalculateTargetFunctionValue( averageDistance, distancesFromPointsToMidPoint );
         *  return targetFunctionValue;
         * }
         */
        //------------------------------------------------------------------------------------------
        //Значение целевой функции для интерферограмм при определенном значении гамма
        //( Аппроксимация плоскостью - вычисление невязки )
        private double GetTargetFunctionValue(
            double gamma, RealMatrix[] interferograms, BitMask2D bitMask
            )
        {
            RealMatrix[] gammaCorrectedInterferograms =
                this.GetGammaCorrectedInterferograms(gamma, interferograms);
            Point3D[]         points            = this.GetSpatialPoints(gammaCorrectedInterferograms, bitMask);
            PlaneApproximator planeApproximator = new PlaneApproximator();
            PlaneDescriptor   planeDescriptor   = planeApproximator.Approximate(points);

            double[] misalignments       = planeDescriptor.GetPointsMisalignments(points);
            double   averageMisalignment = misalignments.Average();
            double   targetFunctionValue =
                this.CalculateTargetFunctionValue(averageMisalignment, misalignments);

            return(targetFunctionValue);
        }
Exemplo n.º 4
0
        //---------------------------------------------------------------------------------------------
        //Плоскость, проходящая через три точки
        protected PlaneDescriptor GetPlane(Point3D[] points)
        {
            Random random = new Random(DateTime.Now.Millisecond);

            int index1 = random.Next(points.Length - 1);
            int index2 = random.Next(points.Length - 1);
            int index3 = random.Next(points.Length - 1);

            Point3D point1 = points[index1];
            Point3D point2 = points[index2];
            Point3D point3 = points[index3];

            PlaneDescriptor planeSescriptor = SpaceManager.GetPlaneByThreePoints
                                                  (point1, point2, point3);

            return(planeSescriptor);
        }
Exemplo n.º 5
0
        //---------------------------------------------------------------------------------------------
        protected Point3D[] GetParallelToCoordinatePlanePoints3D(
            RealMatrix[] interferograms, Point[] imagePoints
            )
        {
            //Ортогональные векторы
            RealVector[] orthogonalVectors = this.GetOrthogonalVectors(interferograms, imagePoints);
            Point3D[]    points3D          = this.GetPoints3D(orthogonalVectors);
            this.OrthogonalVectorsPoints = points3D;

            //Перемещение в первый октант
            points3D = SpaceManager.DisplacePointsToFirstOctant(points3D);

            PlaneDescriptor planeDescriptor   = this.GetPlane(points3D);
            RealVector      planeNormalVector = planeDescriptor.GetNormalVector();

            points3D = this.RotateParallelToPlaneXY(points3D, planeNormalVector);
            return(points3D);
        }