Examples of GeneralMatrix


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

     * Fill L matrix. This matrix contains differences between expected value and value
     * calculated from affine parameters
     * @return l matrix
     */
    protected GeneralMatrix getL() {
        GeneralMatrix l = new GeneralMatrix(2 * this.getMappedPositions().size(), 1);

        double cosphix = Math.cos(phix);
        double sinphix = Math.sin(phix);
        double cosphiy = Math.cos(phiy);
        double sinphiy = Math.sin(phiy);

        for (int j = 0; j < (l.getNumRow() / 2); j++) {
            double x = getSourcePoints()[j].getOrdinate(0);
            double y = getSourcePoints()[j].getOrdinate(1);

            /* a1 is target value - transfomed value*/
            double dx = getTargetPoints()[j].getOrdinate(0)
                - (sx*cosphix*x -  sy*sinphiy*y + tx);               
            double dy = getTargetPoints()[j].getOrdinate(1)
                - (sx*sinphix*x + sy*cosphiy*y + ty);           
       
            l.setElement(j, 0, dx);
            l.setElement((l.getNumRow() / 2) + j, 0, dy);
        }

        return l;
    }
View Full Code Here

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

    private GeneralMatrix getDxMatrix(double tolerance, int maxSteps)
        throws FactoryException {
        /**
         * Matrix of new calculated coefficients
         */
        GeneralMatrix xNew = new GeneralMatrix(6, 1);

        /**
         * Matrix of coefficients calculated in previous iteration
         */
        GeneralMatrix xOld = new GeneralMatrix(6, 1);

        /**
         * Difference between each steps of iteration
         */
        GeneralMatrix dxMatrix = new GeneralMatrix(6, 1);

        /**
         * Zero matrix
         */
        GeneralMatrix zero = new GeneralMatrix(6, 1);
        zero.setZero();

        /**
         * Result
         */
        GeneralMatrix xk = new GeneralMatrix(6 + valueConstrain.size(), 1);

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

        // iteration
        do {
            xOld.set(new double[] { sx, sy, phix, phiy, tx, ty });

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

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

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

            ATA.mul(AT, A);
            ATl.mul(AT, l);

            /**constrains**/
            GeneralMatrix AB = createAB(ATA, getB());

            AB.invert();
            AB.negate();

            GeneralMatrix AU = createAU(ATl, getU());
            xk.mul(AB, AU);

            xk.copySubMatrix(0, 0, 6, xk.getNumCol(), 0, 0, dxMatrix);
            dxMatrix.negate();

View Full Code Here

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

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

    /**
     * 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

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

     * @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

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

     * @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

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

     *
     * @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

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

   
    private final GeneralMatrix result;

    public TPSInterpolation(HashMap positions) {
      super(positions);
        L = new GeneralMatrix(number + 3, number + 3);

          fillKsubMatrix();
          fillPsubMatrix();
          fillOsubMatrix();

          L.invert();

          GeneralMatrix V = fillVMatrix(0);
          result = new GeneralMatrix(number + 3, 1);
          result.mul(L, V);
       
    }
View Full Code Here

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

    }*/
   
   public TPSInterpolation(Map<DirectPosition, Float> positions, int xNumOfCells, int yNumOfCells, Envelope envelope) {
       super(positions, xNumOfCells, yNumOfCells, envelope);

    L = new GeneralMatrix(number + 3, number + 3);

    fillKsubMatrix();
    fillPsubMatrix();
    fillOsubMatrix();

    L.invert();

    GeneralMatrix V = fillVMatrix(0);
    result = new GeneralMatrix(number + 3, 1);
    result.mul(L, V);
    }
View Full Code Here

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

     * Fill V matrix (matrix of target values)
     * @param dim 0 for dx, 1 for dy.
     * @return V Matrix
     */
    private GeneralMatrix fillVMatrix(int dim) {
        V = new GeneralMatrix(number + 3, 1);

        Iterator<DirectPosition> iter = getPositions().keySet().iterator();

        for (int i = 0; i < number; i++) {          
            V.setElement(i, 0, getPositions().get(iter.next()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.