Examples of XMatrix


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

         * as affine transforms. All remaining parameters must be identical.
         */
        if (source.parameters == null || target.parameters == null) {
            return null;
        }
        XMatrix sourceScale = source.normalizedToProjection();
        XMatrix targetScale = target.normalizedToProjection();
        if (!parameterValuesEqual(source.parameters, target.parameters, errorTolerance)) {
            return null;
        }
        /*
         * Creates the matrix (including axis order changes and unit conversions),
         * and apply the scale and translation inferred from the  "false_easting"
         * parameter and its friends. We perform the conversion in three conceptual
         * steps (in the end, everything is bundle in a single matrix):
         *
         *   1) remove the old false northing/easting
         *   2) apply the scales
         *   3) add the new false northing/easting
         */
        targetScale = target.applyProjectedScale(targetScale);
        sourceScale = source.applyProjectedScale(sourceScale);
        sourceScale.invert();
        targetScale.multiply(sourceScale);
        if (targetScale.isIdentity(errorTolerance)) {
            targetScale.setIdentity();
        }
        return targetScale;
    }
View Full Code Here

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

         * Creates the matrix to be used as a filter,       [x']     [1  0  0  0] [x]
         * and concatenates it to the transform. The        [z']  [0  0  1  0] [y]
         * matrix will contains only a 1 for the output     [1 ]     [0  0  0  1] [z]
         * dimension to keep, as in the following example:                        [1]
         */
        final XMatrix matrix = MatrixFactory.create(dimOutput+1, dimStep+1);
        matrix.setZero();
        for (int j=0; j<dimOutput; j++) {
            int i = targetDimensions[j];
            if (i >= dimPass) {
                i += dimDiff;
            }
            matrix.setElement(j, i, 1);
        }
        // Affine transform has one more row/column than dimension.
        matrix.setElement(dimOutput, dimStep, 1);
        MathTransform filtered = factory.createAffineTransform(matrix);
        if (transform != null) {
            filtered = factory.createConcatenatedTransform(transform, filtered);
        }
        return filtered;
View Full Code Here

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

            final BursaWolfParameters[] bursaWolf = ((DefaultGeodeticDatum) target).bursaWolf;
            if (bursaWolf != null) {
                for (int i=0; i<bursaWolf.length; i++) {
                    final BursaWolfParameters transformation = bursaWolf[i];
                    if (equals(source, transformation.targetDatum, false)) {
                        final XMatrix matrix = transformation.getAffineTransform();
                        matrix.invert();
                        return matrix;
                    }
                }
            }
        }
        /*
         * No direct tranformation found. Search for a path through some intermediate datum.
         * First, search if there is some BursaWolfParameters for the same target in both
         * 'source' and 'target' datum. If such an intermediate is found, ask for a path
         * as below:
         *
         *    source   -->   [common datum]   -->   target
         */
        if (source instanceof DefaultGeodeticDatum && target instanceof DefaultGeodeticDatum) {
            final BursaWolfParameters[] sourceParam = ((DefaultGeodeticDatum) source).bursaWolf;
            final BursaWolfParameters[] targetParam = ((DefaultGeodeticDatum) target).bursaWolf;
            if (sourceParam!=null && targetParam!=null) {
                GeodeticDatum sourceStep;
                GeodeticDatum targetStep;
                for (int i=0; i<sourceParam.length; i++) {
                    sourceStep = sourceParam[i].targetDatum;
                    for (int j=0; j<targetParam.length; j++) {
                        targetStep = targetParam[j].targetDatum;
                        if (equals(sourceStep, targetStep, false)) {
                            final XMatrix step1, step2;
                            if (exclusion == null) {
                                exclusion = new HashSet<GeodeticDatum>();
                            }
                            if (exclusion.add(source)) {
                                if (exclusion.add(target)) {
View Full Code Here

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

     * Make sure that linear transformation preserve NaN values.
     * This is required for {@link org.geotools.coverage.Category}.
     */
    @Test
    public void testNaN() throws FactoryException, TransformException {
        final XMatrix matrix = MatrixFactory.create(2);
        matrix.setElement(0,0,0);
        for (int i=0; i<200; i++) {
            final int rawBits = 0x7FC00000 + random.nextInt(100);
            final float value = Float.intBitsToFloat(rawBits);
            assertTrue("isNaN", Float.isNaN(value));
            matrix.setElement(0,1, value);
            final MathTransform1D tr = (MathTransform1D) factory.createAffineTransform(matrix);
            assertTrue("ConstantTransform1D", tr instanceof ConstantTransform1D);
            final float compare = (float) tr.transform(0);
            assertEquals("rawBits", rawBits, Float.floatToRawIntBits(compare));
        }
View Full Code Here

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

     *
     * @param dimSource Number of dimension for input points.
     * @param dimTarget Number of dimension for outout points.
     */
    private Matrix getRandomMatrix(final int dimSource, final int dimTarget) {
        final XMatrix matrix = MatrixFactory.create(dimTarget+1, dimSource+1);
        for (int j=0; j<dimTarget; j++) { // Don't touch to the last row!
            for (int i=0; i<=dimSource; i++) {
                matrix.setElement(j,i, 10*random.nextDouble()-5);
            }
            if (j <= dimSource) {
                matrix.setElement(j,j, 40*random.nextDouble()+10);
            }
            matrix.setElement(j,dimSource, 80*random.nextDouble()-40);
        }
        if (dimSource == dimTarget) {
            assertTrue("Affine", matrix.isAffine());
        }
        return matrix;
    }
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.