Transform() public method

Transforms a coordinate point.
The passed parameter point should not be modified.
public Transform ( double point ) : double[]
point double An array containing the point coordinates to transform
return double[]
Ejemplo n.º 1
0
        private void calcControlPointsShifts()
        {
            _controlPointsShifts = new ICoordinate[_sourceControlPoints.Length];

            for (int i = 0; i < _sourceControlPoints.Length; i++)
            {
                ICoordinate transformed =
                    PlanimetryEnvironment.NewCoordinate(_optimalAffineTransform.Transform(_sourceControlPoints[i].Values()));

                _controlPointsShifts[i] =
                    PlanimetryEnvironment.NewCoordinate(_destinationControlPoints[i].X - transformed.X,
                                                        _destinationControlPoints[i].Y - transformed.Y);
            }
        }
Ejemplo n.º 2
0
        private int[] calculateOptimalAffineTransformPoints()
        {
            int[]  result  = new int[3];
            double minNorm = double.MaxValue;

            for (int i1 = 0; i1 < _sourceControlPoints.Length - 2; i1++)
            {
                for (int i2 = i1 + 1; i2 < _sourceControlPoints.Length - 1; i2++)
                {
                    for (int i3 = i2 + 1; i3 < _sourceControlPoints.Length; i3++)
                    {
                        ICoordinate p01 = _sourceControlPoints[i1];
                        ICoordinate p02 = _sourceControlPoints[i2];
                        ICoordinate p03 = _sourceControlPoints[i3];

                        ICoordinate p11 = _destinationControlPoints[i1];
                        ICoordinate p12 = _destinationControlPoints[i2];
                        ICoordinate p13 = _destinationControlPoints[i3];

                        Matrix m = getAffineTransformMatrix(p01, p02, p03, p11, p12, p13);

                        if (m != null)
                        {
                            ICoordinate[] tempPoints = new ICoordinate[_sourceControlPoints.Length];
                            for (int i = 0; i < _sourceControlPoints.Length; i++)
                            {
                                tempPoints[i] = (ICoordinate)_sourceControlPoints[i].Clone();
                            }

                            Affine affineTransform = new Affine(m);

                            for (int i = 0; i < tempPoints.Length; i++)
                            {
                                tempPoints[i] =
                                    PlanimetryEnvironment.NewCoordinate(
                                        affineTransform.Transform(tempPoints[i].Values()));
                            }

                            double currentNorm = 0;
                            for (int i = 0; i < tempPoints.Length; i++)
                            {
                                currentNorm += PlanimetryAlgorithms.Distance(_destinationControlPoints[i], PlanimetryEnvironment.NewCoordinate(tempPoints[i].X, tempPoints[i].Y));
                            }

                            if (currentNorm < minNorm)
                            {
                                minNorm   = currentNorm;
                                result[0] = i1;
                                result[1] = i2;
                                result[2] = i3;
                            }
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        private int[] calculateOptimalAffineTransformPoints()
        {
            int[] result = new int[3];
            double minNorm = double.MaxValue;

            for (int i1 = 0; i1 < _sourceControlPoints.Length - 2; i1++)
                for (int i2 = i1 + 1; i2 < _sourceControlPoints.Length - 1; i2++)
                    for (int i3 = i2 + 1; i3 < _sourceControlPoints.Length; i3++)
                    {
                        ICoordinate p01 = _sourceControlPoints[i1];
                        ICoordinate p02 = _sourceControlPoints[i2];
                        ICoordinate p03 = _sourceControlPoints[i3];

                        ICoordinate p11 = _destinationControlPoints[i1];
                        ICoordinate p12 = _destinationControlPoints[i2];
                        ICoordinate p13 = _destinationControlPoints[i3];

                        Matrix m = getAffineTransformMatrix(p01, p02, p03, p11, p12, p13);

                        if (m != null)
                        {
                            ICoordinate[] tempPoints = new ICoordinate[_sourceControlPoints.Length];
                            for (int i = 0; i < _sourceControlPoints.Length; i++)
                                tempPoints[i] = (ICoordinate)_sourceControlPoints[i].Clone();

                            Affine affineTransform = new Affine(m);

                            for (int i = 0; i < tempPoints.Length; i++)
                                tempPoints[i] = 
                                    PlanimetryEnvironment.NewCoordinate(
                                        affineTransform.Transform(tempPoints[i].Values()));

                            double currentNorm = 0;
                            for (int i = 0; i < tempPoints.Length; i++)
                                currentNorm += PlanimetryAlgorithms.Distance(_destinationControlPoints[i], PlanimetryEnvironment.NewCoordinate(tempPoints[i].X, tempPoints[i].Y));

                            if (currentNorm < minNorm)
                            {
                                minNorm = currentNorm;
                                result[0] = i1;
                                result[1] = i2;
                                result[2] = i3;
                            }
                        }
                    }

            return result;
        }