Package org.geotools.referencing.operation.matrix

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


    /**
     * Fill matrix of derivations of constrains by affine parameters.
     * @return B matrix
     */
    protected GeneralMatrix getB() {
        GeneralMatrix B = new GeneralMatrix(valueConstrain.size(), 6);
        int i = 0;

        if (valueConstrain.containsKey(SX)) {
            B.setRow(i, new double[] { 1, 0, 0, 0, 0, 0 });
            i++;
        }

        if (valueConstrain.containsKey(SY)) {
            B.setRow(i, new double[] { 0, 1, 0, 0, 0, 0 });
            i++;
        }

        if (valueConstrain.containsKey(PHIX)) {
            B.setRow(i, new double[] { 0, 0, 1, 0, 0, 0 });
            i++;
        }

        if (valueConstrain.containsKey(PHIY)) {
            B.setRow(i, new double[] { 0, 0, 0, 1, 0, 0 });
            i++;
        }

        if (valueConstrain.containsKey(TX)) {
            B.setRow(i, new double[] { 0, 0, 0, 0, 1, 0 });
            i++;
        }

        if (valueConstrain.containsKey(TY)) {
            B.setRow(i, new double[] { 0, 0, 0, 0, 0, 1 });
            i++;
        }
        if (valueConstrain.containsKey(SXY)) {
            B.setRow(i, new double[] { 0, 0, -1, 1, 0, 0 });
            i++;
        }

        return B;
    }
View Full Code Here


    /**
     * Fill matrix of constrain values (e.g. for constrain skew = 0 the value is 0)
     * @return U matrix
     */
    protected GeneralMatrix getU() {
        GeneralMatrix U = new GeneralMatrix(valueConstrain.size(), 1);
        int i = 0;

        if (valueConstrain.containsKey(SX)) {
            U.setRow(i, new double[] { -sx + valueConstrain.get(SX) });
            i++;
        }

        if (valueConstrain.containsKey(SY)) {
            U.setRow(i, new double[] { -sy + valueConstrain.get(SY) });
            i++;
        }

        if (valueConstrain.containsKey(PHIX)) {
            U.setRow(i, new double[] { -phix + valueConstrain.get(PHIX)});
            i++;
        }

        if (valueConstrain.containsKey(PHIY)) {
            U.setRow(i, new double[] { -phiy + valueConstrain.get(PHIY) });
            i++;
        }

        if (valueConstrain.containsKey(TX)) {
            U.setRow(i, new double[] { -tx + valueConstrain.get(TX) });
            i++;
        }
        if (valueConstrain.containsKey(SXY)) {
                U.setRow(i, new double[] { (phix-phiy) +  valueConstrain.get(SXY) });
                i++;               
        } else if (valueConstrain.containsKey(TY)) {
            U.setRow(i, new double[] { -ty + valueConstrain.get(TY) });
            i++;
        }

        return U;
    }
View Full Code Here

     * @param ATl
     * @param U
     * @return matrix constructs from ATl and U
     */
    private GeneralMatrix createAU(GeneralMatrix ATl, GeneralMatrix U) {
        GeneralMatrix AU = new GeneralMatrix(ATl.getNumRow() + U.getNumRow(), ATl.getNumCol());

        ATl.copySubMatrix(0, 0, ATl.getNumRow(), ATl.getNumCol(), 0, 0, AU);
        U.copySubMatrix(0, 0, U.getNumRow(), U.getNumCol(), ATl.getNumRow(), 0, AU);

        return AU;
View Full Code Here

     * @param ATA
     * @param B
     * @return matrix constructs from ATA and B
     */
    private GeneralMatrix createAB(GeneralMatrix ATA, GeneralMatrix B) {
        GeneralMatrix BT = B.clone();
        BT.transpose();

        GeneralMatrix AAB = new GeneralMatrix(ATA.getNumRow() + B.getNumRow(),
                ATA.getNumCol() + BT.getNumCol());

        ATA.copySubMatrix(0, 0, ATA.getNumRow(), ATA.getNumCol(), 0, 0, AAB);
        B.copySubMatrix(0, 0, B.getNumRow(), B.getNumCol(), ATA.getNumRow(), 0, AAB);
        BT.copySubMatrix(0, 0, BT.getNumRow(), BT.getNumCol(), 0, ATA.getNumCol(), AAB);

        GeneralMatrix zero = new GeneralMatrix(B.getNumRow(), B.getNumRow());
        zero.setZero();
        zero.copySubMatrix(0, 0, zero.getNumRow(), zero.getNumCol(), B.getNumCol(), B.getNumCol(),
            AAB);

        return AAB;
    }
View Full Code Here

     *
     * @return Projective Matrix
     * @throws FactoryException
     */
    protected GeneralMatrix getProjectiveMatrix() throws FactoryException {
        GeneralMatrix M = new GeneralMatrix(3, 3);

        /**
         * Runs calculation of parameter values
         */
        double[] param = getDxMatrix().getElements()[0];

        /**
         * calcuates matrix coefficients form geometric coefficients
         */
        double a11 =  sx * Math.cos(phix);
        double a12 = -sy * Math.sin(phiy);
        double a21 =  sx*  Math.sin(phix);
        double a22 =  sy * Math.cos(phiy);
             
        /**
         * Fill the metrix
         */
        double[] m0 = { a11, a12, param[4] };
        double[] m1 = { a21, a22, 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

     * Test WKT formatting of transforms backed by matrix.
     */
    @Test
    public void testMatrix() {
        final Formatter  formatter = new Formatter();
        final GeneralMatrix matrix = new GeneralMatrix(4);
        matrix.setElement(0,24);
        matrix.setElement(1,0, -2);
        matrix.setElement(2,37);
        MathTransform transform = ProjectiveTransform.create(matrix);
        assertFalse(transform instanceof AffineTransform);
        formatter.append(transform);
        assertEquals("PARAM_MT[\"Affine\", "          +
                     "PARAMETER[\"num_row\", 4], "    +
                     "PARAMETER[\"num_col\", 4], "    +
                     "PARAMETER[\"elt_0_2\", 4.0], "  +
                     "PARAMETER[\"elt_1_0\", -2.0], " +
                     "PARAMETER[\"elt_2_3\", 7.0]]", formatter.toString());
        matrix.setSize(3,3);
        transform = ProjectiveTransform.create(matrix);
        assertTrue(transform instanceof AffineTransform);
        formatter.clear();
        formatter.append(transform);
        assertEquals("PARAM_MT[\"Affine\", "          +
View Full Code Here

     */
    @Test
    public void testMatrixEdit() {
        final int size = 8;
        final Random random = new Random(47821365);
        final GeneralMatrix matrix = new GeneralMatrix(size);
        for (int j=0; j<size; j++) {
            for (int i=0; i<size; i++) {
                matrix.setElement(j, i, 200*random.nextDouble()-100);
            }
        }
        final MatrixParameterDescriptors descriptor =
                new MatrixParameterDescriptors(Collections.singletonMap("name", "Test"));
        for (int height=2; height<=size; height++) {
            for (int width=2; width<=size; width++) {
                MatrixParameters parameters = (MatrixParameters) descriptor.createValue();
                GeneralMatrix copy = matrix.clone();
                copy.setSize(height, width);
                parameters.setMatrix(copy);
                assertEquals("height", height, ((Parameter) parameters.parameter("num_row")).intValue());
                assertEquals("width",  width,  ((Parameter) parameters.parameter("num_col")).intValue());
                assertTrue  ("equals", copy.equals(parameters.getMatrix(), 0));
                assertEquals("equals", parameters, parameters.clone());
            }
        }
    }
View Full Code Here

     * A<sup>T</sup>Px' equation
     *
     * @throws MissingInfoException if accuracy is not defined.
     */
    protected void fillPMatrix() throws MissingInfoException {
        this.P = new GeneralMatrix(getMappedPositions().size() * 2,
                getMappedPositions().size() * 2);

        for (int i = 0; i < getMappedPositions().size(); i = i + 2) {
            if (Double.compare(
                        (((MappedPosition) getMappedPositions().get(i))
View Full Code Here

     * A<sup>T</sup>Px' equation
     */
    protected void fillAMatrix() {
        final DirectPosition[] sourcePoints = getSourcePoints();
        final DirectPosition[] targetPoints = getTargetPoints();
        A = new GeneralMatrix(2 * sourcePoints.length, 8);

        int numRow = 2 * sourcePoints.length;

        // fill first half of matrix
        for (int j = 0; j < ((2 * sourcePoints.length) / 2); j++) {
View Full Code Here

    /**
     * Fills x' matrix for m = (A<sup>T</sup>PA)<sup>-1</sup>
     * A<sup>T</sup>Px' equation
     */
    protected void fillXMatrix() {
        X = new GeneralMatrix(2 * getTargetPoints().length, 1);

        int numRow = X.getNumRow();

        // Creates X matrix
        for (int j = 0; j < (numRow / 2); j++) {
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.