Package org.geotools.referencing.operation.matrix

Examples of org.geotools.referencing.operation.matrix.GeneralMatrix


     * </pre>
     *
     * @return Matrix M.
     */
    protected GeneralMatrix getProjectiveMatrix() {
        GeneralMatrix M = new GeneralMatrix(3, 3);
        double[] param = calculateLSM();
        double[] m0 = { param[0], param[1], param[2] };
        double[] m1 = { param[3], param[4], param[5] };
        double[] m2 = { 0, 0, 1 };
        M.setRow(0, m0);
        M.setRow(1, m1);
        M.setRow(2, m2);

        return M;
    }
View Full Code Here


        return M;
    }

    protected void fillAMatrix() {
       
        super.A = new GeneralMatrix(2 * getSourcePoints().length, 6);

        int numRow = getSourcePoints().length*2;

        // Creates X matrix
        for (int j = 0; j < (numRow / 2); j++) {
View Full Code Here

            MismatchedReferenceSystemException {
        super.setMappedPositions(vectors);
    }

    protected void fillAMatrix() {
        super.A = new GeneralMatrix(2 * getSourcePoints().length, 4);

        int numRow = getSourcePoints().length * 2;

        // Creates X matrix
        for (int j = 0; j < (numRow / 2); j++) {
View Full Code Here

     * </pre>
     *
     * @return Matrix M.
     */
    protected GeneralMatrix getProjectiveMatrix() {
        GeneralMatrix M = new GeneralMatrix(3, 3);       
        double[] param = calculateLSM();
        double[] m0 = { param[0], -param[1], param[2] };
        double[] m1 = { param[1], param[0], param[3] };
        double[] m2 = { 0, 0, 1 };
        M.setRow(0, m0);
        M.setRow(1, m1);
        M.setRow(2, m2);

        return M;
    }
View Full Code Here

      final PixelScale pixScales = metadata.getModelPixelScales();



      // here is the matrix we need to build
      final GeneralMatrix gm = new GeneralMatrix(3);
      final double scaleRaster2ModelLongitude = pixScales.getScaleX();
      final double scaleRaster2ModelLatitude = -pixScales.getScaleY();
      // "raster" space
      final double tiePointColumn = tiePoints[0].getValueAt(0)
          + ((forceToCellCenter || rasterType == GeoTiffConstants.RasterPixelIsArea) ? - 0.5: 0);
     
      // coordinates
      // (indicies)
      final double tiePointRow = tiePoints[0].getValueAt(1)
          + ((forceToCellCenter || rasterType == GeoTiffConstants.RasterPixelIsArea) ? - 0.5: 0);

      // compute an "offset and scale" matrix
      gm.setElement(0, 0, scaleRaster2ModelLongitude);
      gm.setElement(1, 1, scaleRaster2ModelLatitude);
      gm.setElement(0, 1, 0);
      gm.setElement(1, 0, 0);

      gm.setElement(0, 2, tiePoints[0].getValueAt(3)
          - (scaleRaster2ModelLongitude * tiePointColumn));
      gm.setElement(1, 2, tiePoints[0].getValueAt(4)
          - (scaleRaster2ModelLatitude * tiePointRow));

      // make it a LinearTransform
      xform = ProjectiveTransform.create(gm);

View Full Code Here

            transform.rotate(Math.PI*random.nextDouble(), 100*random.nextDouble(), 100*random.nextDouble());
            transform.scale       (2*random.nextDouble(),   2*random.nextDouble());
            transform.shear       (2*random.nextDouble(),   2*random.nextDouble());
            transform.translate (100*random.nextDouble(), 100*random.nextDouble());
            compareTransforms("AffineTransform", new MathTransform[] {
                new ProjectiveTransform(new GeneralMatrix(transform)),
                new AffineTransform2D(transform)
            });
        }

        AffineTransform at = new AffineTransform(23.1570829174244540.0, 3220.1613428464952,
                                                 0.0, -23.157082917424457, 1394.4593259871676);
        MathTransform mt = factory.createAffineTransform(new GeneralMatrix(at));

        final double[] points = new double[] {
                -129.992589135802,    55.9226692948365, -129.987254340541,
                  55.9249676996729, -129.982715772093,    55.9308988434656,
                -129.989772198265,    55.9289277997662, -129.992589135802, 55.9226692948365
View Full Code Here

        for (int pass=0; pass<5; pass++) {
            /*
             * Construct the reference matrix.
             */
            final int dimension = 10;
            final GeneralMatrix matrix = new GeneralMatrix(dimension+1, dimension+1);
            for (int i=0; i<dimension; i++) {
                matrix.setElement(i,i,         400*Math.random()-200);
                matrix.setElement(i,dimension, 400*Math.random()-200);
            }
            assertTrue(matrix.isAffine());
            /*
             * Construct all math transforms.
             */
            final MathTransform[] transforms = new MathTransform[dimension];
            for (int i=1; i<=dimension; i++) {
                final GeneralMatrix sub = new GeneralMatrix(i+1, i+1);
                matrix.copySubMatrix(0, 0, i, i, 0, 0, sub);         // Scale terms
                matrix.copySubMatrix(0, dimension, i, 1, 0, i, sub); // Translation terms
                final MathTransform transform = transforms[i-1] = factory.createAffineTransform(sub);
                assertTrue  (sub.isAffine());
                assertEquals(sub, new GeneralMatrix(((LinearTransform) transform).getMatrix()));
                assertInterfaced(transform);
                assertTrue(i ==  transform.getSourceDimensions());
            }
            /*
             * Check transformations and the inverse transformations.
View Full Code Here

     * such transform are optimized in a special way.
     */
    @Test
    public void testLinear() throws FactoryException, TransformException {
        runTest(mtFactory.createAffineTransform(
                new GeneralMatrix(AffineTransform.getScaleInstance(4, 2))));
    }
View Full Code Here

        public void testLSM() {
            // fill Matrix by calculateLSM()
            this.calculateLSM();

            GeneralMatrix AT = A.clone();
            AT.transpose();

            GeneralMatrix ATP = new GeneralMatrix(AT.getNumRow(), P.getNumCol());
            GeneralMatrix ATPA = new GeneralMatrix(AT.getNumRow(), A.getNumCol());
            GeneralMatrix ATPX = new GeneralMatrix(AT.getNumRow(), 1);
            GeneralMatrix x = new GeneralMatrix(A.getNumCol(), 1);
            ATP .mul(AT,  P); // ATP
            ATPA.mul(ATP, A); // ATPA
            ATPX.mul(ATP, X); // ATPX

            GeneralMatrix ATPAI = ATPA.clone();
            ATPAI.invert();

            x.mul(ATPAI, ATPX);

            // assert the ATPAx + ATPX should be 0;.
            x.mul(ATPA, x);
View Full Code Here

                matrix[4] = tx.get( "scaleY") != null ? tx.get( "scaleY") : matrix[4];
                matrix[5] = tx.get( "translateY") != null ? tx.get( "translateY") : matrix[5];
                matrix[8] = 1.0;
               
                MathTransform gridToCRS = new DefaultMathTransformFactory()
                    .createAffineTransform( new GeneralMatrix(3,3,matrix));
                coverage.setGrid( new GridGeometry2D(range,gridToCRS,crs) );
            }
            else {
                coverage.setGrid( new GridGeometry2D( range, gridEnvelope ) );
            }
View Full Code Here

TOP

Related Classes of org.geotools.referencing.operation.matrix.GeneralMatrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.