Examples of GeneralMatrix


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

     */
    public static LinearTransform createScale(final int dimension, final double scale) {
        if (scale == 1) {
            return IdentityTransform.create(dimension);
        }
        final Matrix matrix = new GeneralMatrix(dimension + 1);
        for (int i=0; i<dimension; i++) {
            matrix.setElement(i, i, scale);
        }
        return create(matrix);
    }
View Full Code Here

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

     */
    public static LinearTransform createTranslation(final int dimension, final double offset) {
        if (offset == 0) {
            return IdentityTransform.create(dimension);
        }
        final Matrix matrix = new GeneralMatrix(dimension + 1);
        for (int i=0; i<dimension; i++) {
            matrix.setElement(i, dimension, offset);
        }
        return create(matrix);
    }
View Full Code Here

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

     * For a matrix transform, the derivative is the
     * same everywhere.
     */
    @Override
    public Matrix derivative(final DirectPosition point) {
        final GeneralMatrix matrix = getGeneralMatrix();
        matrix.setSize(numRow-1, numCol-1);
        return matrix;
    }
View Full Code Here

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

    /**
     * Returns a copy of the matrix.
     */
    private GeneralMatrix getGeneralMatrix() {
        return new GeneralMatrix(numRow, numCol, elt);
    }
View Full Code Here

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

                final XMatrix matrix;
                if (numCol == matrix2.getNumCol()) {
                    matrix = matrix2;
                    matrix2.multiply(matrix1);
                } else {
                    final GeneralMatrix m = new GeneralMatrix(numRow, numCol);
                    m.mul(toGMatrix(matrix2), toGMatrix(matrix1));
                    matrix = m;
                }
                if (matrix.isIdentity(EPSILON)) {
                    matrix.setIdentity();
                }
View Full Code Here

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

        final XMatrix matrix;
        if (numCol == matrix2.getNumCol()) {
            matrix = toXMatrix(matrix2);
            matrix.multiply(matrix1);
        } else {
            final GeneralMatrix m = new GeneralMatrix(numRow, numCol);
            m.mul(toGMatrix(matrix2), toGMatrix(matrix1));
            matrix = m;
        }
        return matrix;
    }
View Full Code Here

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

         * @see org.geotools.coverage.grid.GridGeometry2D#getGridToCRS2D
         */
        protected RenderContext createRenderContext(final Rectangle2D gridBounds,
                                                    final RenderingHints hints)
        {
            final GeneralMatrix matrix;
            final GeneralEnvelope srcEnvelope = new GeneralEnvelope(bounds);
            final GeneralEnvelope dstEnvelope = new GeneralEnvelope(gridBounds);
            if (crs != null) {
                final CoordinateSystem cs = crs.getCoordinateSystem();
                final AxisDirection[] axis = new AxisDirection[] {
                        cs.getAxis(xAxis).getDirection(),
                        cs.getAxis(yAxis).getDirection()
                };
                final AxisDirection[] normalized = axis.clone();
                if (false) {
                    // Normalize axis: Is it really a good idea?
                    // We should provide a rendering hint for configuring that.
                    Arrays.sort(normalized);
                    for (int i = normalized.length; --i >= 0;) {
                        normalized[i] = normalized[i].absolute();
                    }
                }
                normalized[1] = normalized[1].opposite(); // Image's Y axis is downward.
                matrix = new GeneralMatrix(srcEnvelope, axis, dstEnvelope, normalized);
            } else {
                matrix = new GeneralMatrix(srcEnvelope, dstEnvelope);
            }
            return new RenderContext(matrix.toAffineTransform2D(), hints);
        }
View Full Code Here

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

                }
                rows[nRows++] = row;
            }
            rows = XArray.resize(rows, nRows);
            if (hasLastRow) {
                return factory.createAffineTransform(new GeneralMatrix(rows));
            }
            // In an affine transform,  the last row is not supposed to have dependency
            // to any input dimension. But in this particuler case, our matrix has such
            // dependencies. TODO: is there anything we could do about that?
        }
View Full Code Here

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

     * each transformation parameter (sx, sy, sxy, phi, tx,ty). The rows are derivations of fx and fy.
     *
     * @return A matrix
     */
    protected GeneralMatrix getA() {
        GeneralMatrix A = new GeneralMatrix(2 * this.getMappedPositions().size(), 6);

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

        /**
         * Each row is calculated with values of proper GCPs
         */
        for (int j = 0; j < (A.getNumRow() / 2); j++) {
            double x = getSourcePoints()[j].getOrdinate(0);
            double y = getSourcePoints()[j].getOrdinate(1);

            /*************************
             *
             * Derivation X
             *
             **************************/
            double dxsx = cosphix*x;
                      
            double dxsy = - sinphiy * y;
                
            double dxphix = -sx*sinphix* x;
           
            double dxphiy = -sy*cosphiy* y ;
           
            double dxtx = 1;
           
            double dxty = 0;

            /*************************
             *
             * Derivation Y
             *
             ***********************/
            double dysx = sinphix * x;
                      
            double dysy = cosphiy * y;
                
            double dyphix =  sx*cosphix*x;
           
            double dyphiy = -sy*sinphiy* y ;
           
            double dytx = 0;
           
            double dyty = 1;
        
            A.setRow(j,                   new double[] { dxsx, dxsy, dxphix, dxphiy, dxtx, dxty });
            A.setRow(A.getNumRow()/2 + j, new double[] { dysx, dysy, dyphix, dyphiy, dytx, dyty });
        }

        return A;
    }
View Full Code Here

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
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.