Package org.geotools.referencing.operation.matrix

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


     * @return Matrix, that represents partial derivation of rotation Matrix
     *         with respect to  beta.
     */
    protected GeneralMatrix getDRbeta() {
        //GeneralMatrix dRbeta = new GeneralMatrix(3 * sourcePoints.size(), 1);
        GeneralMatrix dRb = new GeneralMatrix(3, 3);
        double[] m0 = { -Math.sin(beta), 0, -Math.cos(beta) };
        double[] m1 = { 0, 0, 0 };
        double[] m2 = { Math.cos(beta), 0, -Math.sin(beta) };
        dRb.setRow(0, m0);
        dRb.setRow(1, m1);
        dRb.setRow(2, m2);

        dRb.mul(getRalfa(), dRb);
        dRb.mul(dRb, getRgamma());

        return specialMul(dRb, x);
    }
View Full Code Here


     * @return Matrix, that represents partial derivation of rotation Matrix
     *         with respect to  gamma.
     */
    protected GeneralMatrix getDRgamma() {
        //  GeneralMatrix dRgamma = new GeneralMatrix(3 * sourcePoints.size(), 1);
        GeneralMatrix dRg = new GeneralMatrix(3, 3);
        GeneralMatrix pom = new GeneralMatrix(3, 3);
        double[] m0 = { -Math.sin(gamma), Math.cos(gamma), 0 };
        double[] m1 = { -Math.cos(gamma), -Math.sin(gamma), 0 };
        double[] m2 = { 0, 0, 0 };
        dRg.setRow(0, m0);
        dRg.setRow(1, m1);
        dRg.setRow(2, m2);

        pom.mul(getRalfa(), getRbeta());
        dRg.mul(pom, dRg);

        return specialMul(dRg, x);
    }
View Full Code Here

     *
     * @return rotation Matrix.
     */
    protected GeneralMatrix getDq() {
        //  GeneralMatrix Dq = new GeneralMatrix(3 * sourcePoints.size(), 1);
        GeneralMatrix R = new GeneralMatrix(3, 3);
        R.mul(getRalfa(), getRbeta());
        R.mul(R, getRgamma());

        return specialMul(R, x);
    }
View Full Code Here

     * prameters.
     *
     * @return the l matrix.
     */
    protected GeneralMatrix getl() {
        GeneralMatrix l = new GeneralMatrix(3 * getMappedPositions().size(), 1);
        GeneralMatrix R = new GeneralMatrix(3, 3);
        GeneralMatrix T = new GeneralMatrix(3, 1, new double[] { -dx, -dy, -dz });
        GeneralMatrix qMatrix = new GeneralMatrix(1, 1, new double[] { q });
        GeneralMatrix qx = new GeneralMatrix(X.getNumRow(), X.getNumCol());
        qx.mul(x, qMatrix);
        R.mul(getRalfa(), getRbeta());
        R.mul(getRgamma());

        l.sub(specialMul(R, qx), X);
        l = specialSub(T, l);
View Full Code Here

     * @param x matrix
     *
     * @return matrix
     */
    protected GeneralMatrix specialMul(GeneralMatrix R, GeneralMatrix x) {
        GeneralMatrix dRx = new GeneralMatrix(3 * getMappedPositions().size(), 1);

        for (int i = 0; i < x.getNumRow(); i = i + 3) {
            GeneralMatrix subMatrix = new GeneralMatrix(3, 1);
            x.copySubMatrix(i, 0, 3, 1, 0, 0, subMatrix);
            subMatrix.mul(R, subMatrix);
            subMatrix.copySubMatrix(0, 0, 3, 1, i, 0, dRx);
        }

        return dRx;
    }
View Full Code Here

     * @param x matrix
     *
     * @return matrix
     */
    private GeneralMatrix specialSub(GeneralMatrix R, GeneralMatrix x) {
        GeneralMatrix dRx = new GeneralMatrix(3 * getMappedPositions().size(), 1);

        for (int i = 0; i < x.getNumRow(); i = i + 3) {
            GeneralMatrix subMatrix = new GeneralMatrix(3, 1);
            x.copySubMatrix(i, 0, 3, 1, 0, 0, subMatrix);
            subMatrix.sub(R, subMatrix);
            subMatrix.copySubMatrix(0, 0, 3, 1, i, 0, dRx);
        }

        return dRx;
    }
View Full Code Here

     *
     * @return A mtarix
     */
    protected GeneralMatrix getA() {
        final int size = getMappedPositions().size();
        GeneralMatrix A = new GeneralMatrix(3 * size, 7);
        GeneralMatrix DT = new GeneralMatrix(3, 3);

        // the partial derivative with respect to dx,dy,dz.
        double[] m0 = { 1, 0, 0 };
        double[] m1 = { 0, 1, 0 };
        double[] m2 = { 0, 0, 1 };
        DT.setRow(0, m0);
        DT.setRow(1, m1);
        DT.setRow(2, m2);

        for (int i = 0; i < A.getNumRow(); i = i + 3) {
            DT.copySubMatrix(0, 0, 3, 3, i, 0, A);
        }

        getDRalfa().copySubMatrix(0, 0, 3 * size, 1, 0, 3, A);
        getDRbeta().copySubMatrix(0, 0, 3 * size, 1, 0, 4, A);
        getDRgamma().copySubMatrix(0, 0, 3 * size, 1, 0, 5, A);
View Full Code Here

     *
     * @return GeneralMatrix of calculated parameters.
     */
    private GeneralMatrix getDxMatrix(double tolerance, int maxSteps) {
        // Matriix of new calculated coefficeients
        GeneralMatrix xNew = new GeneralMatrix(7, 1);

        // Matrix of coefficients claculated in previous iteration
        GeneralMatrix xOld = new GeneralMatrix(7, 1);

        // diference between each steps of old iteration
        GeneralMatrix dxMatrix = new GeneralMatrix(7, 1);

        GeneralMatrix zero = new GeneralMatrix(7, 1);
        zero.setZero();

        // i is a number of iterations
        int i = 0;

        // cicle for iteration
        do {
            xOld.set(new double[] { dx, dy, dz, alfa, beta, gamma, q });

            GeneralMatrix A = getA();
            GeneralMatrix l = getl();

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

            GeneralMatrix ATA = new GeneralMatrix(7, 7);
            GeneralMatrix ATl = new GeneralMatrix(7, 1);

            // dx = A^T * A  * A^T * l
            ATA.mul(AT, A);
            ATA.invert();
            ATl.mul(AT, l);

            dxMatrix.mul(ATA, ATl);

            // New values of x = dx + previous values
            xOld.negate();
View Full Code Here

        }
        mt = opFactory.createOperation(crs0, crs1).getMathTransform();
        assertFalse(mt.isIdentity());
        assertTrue(mt instanceof LinearTransform);
        matrix = ((LinearTransform) mt).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            {0, 1, 0},
            {1, 0, 0},
            {0, 0, 1}}), new GeneralMatrix(matrix));
        /*
         * Tests a WGS84 geographic CRS (3D) with (NORTH, EAST, UP) axis directions.
         * Because this CRS uses sexagesimal units, conversions are not supported and
         * will not be tested.
         */
        code = "4329";
        crs0 = factory0.createCoordinateReferenceSystem(code);
        crs1 = factory1.createCoordinateReferenceSystem(code);
        assertNotSame(crs0, crs1);
        assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
        assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
        assertFalse(crs0.getIdentifiers().isEmpty());
        if (METADATA_ERASED) {
            assertTrue(crs1.getIdentifiers().isEmpty());
        } else {
            assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
        }
        /*
         * Tests a WGS84 geographic CRS (3D) with (NORTH, EAST, UP) axis directions.
         * The factory should reorder the axis with no more operation than an axis swap.
         */
        code = "63266413";
        crs0 = factory0.createCoordinateReferenceSystem(code);
        crs1 = factory1.createCoordinateReferenceSystem(code);
        assertNotSame(crs0, crs1);
        assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
        assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
        assertFalse(crs0.getIdentifiers().isEmpty());
        if (METADATA_ERASED) {
            assertTrue(crs1.getIdentifiers().isEmpty());
        } else {
            assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
        }
        mt = opFactory.createOperation(crs0, crs1).getMathTransform();
        assertFalse(mt.isIdentity());
        assertTrue(mt instanceof LinearTransform);
        matrix = ((LinearTransform) mt).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            {0, 1, 0, 0},
            {1, 0, 0, 0},
            {0, 0, 1, 0},
            {0, 0, 0, 1}}), new GeneralMatrix(matrix));
        /*
         * Tests a projected CRS with (EAST, NORTH) axis orientation. No axis reordering is needed,
         * which means that their coordinate systems are identical and the math transform should be
         * the identity one. Note that while no axis swap is needed, the base GeographicCRS are not
         * the same since an axis reordering has been done there.
         */
        code = "2027";
        crs0 = factory0.createCoordinateReferenceSystem(code);
        crs1 = factory1.createCoordinateReferenceSystem(code);
        assertNotSame(crs0, crs1);
        assertSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
        assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
        assertNotSame(((ProjectedCRS) crs0).getBaseCRS(), ((ProjectedCRS) crs1).getBaseCRS());
        assertFalse(crs0.getIdentifiers().isEmpty());
        if (METADATA_ERASED) {
            assertTrue(crs1.getIdentifiers().isEmpty());
        } else {
            assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
        }
        mt = opFactory.createOperation(crs0, crs1).getMathTransform();
        assertTrue(mt.isIdentity());
        /*
         * Tests a projected CRS with (WEST, SOUTH) axis orientation.
         * The factory should arrange the axis with no more operation than a direction change.
         * While the end result is a matrix like the GeographicCRS case, the path that lead to
         * this result is much more complex.
         */
        code = "22275";
        crs0 = factory0.createCoordinateReferenceSystem(code);
        crs1 = factory1.createCoordinateReferenceSystem(code);
        assertNotSame(crs0, crs1);
        assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
        assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
        assertFalse(crs0.getIdentifiers().isEmpty());
        if (METADATA_ERASED) {
            assertTrue(crs1.getIdentifiers().isEmpty());
        } else {
            assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
        }
        mt = opFactory.createOperation(crs0, crs1).getMathTransform();
        assertFalse(mt.isIdentity());
        assertTrue(mt instanceof LinearTransform);
        matrix = ((LinearTransform) mt).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            {-100},
            { 0, -10},
            { 001}}), new GeneralMatrix(matrix));
        /*
         * Tests the cache.
         */
        assertSame(cacheTest, factory1.createCoordinateReferenceSystem("4326"));
    }
View Full Code Here

        assertEquals("Expected a left-handed CS.",  -90, getAngle(standard), EPS);
        assertEquals("Expected a right-handed CS.", +90, getAngle(modified), EPS);
        final MathTransform transform = CRS.findMathTransform(standard, modified);
        assertTrue(transform instanceof LinearTransform);
        final Matrix matrix = ((LinearTransform) transform).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            { 010},
            { 100},
            { 001}}), new GeneralMatrix(matrix));
    }
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.