Search in sources :

Example 6 with Matrix2

use of org.apache.sis.referencing.operation.matrix.Matrix2 in project sis by apache.

the class Mercator method transform.

/**
 * Converts the specified (λ,φ) coordinate (units in radians) and stores the result in {@code dstPts}
 * (linear distance on a unit sphere). In addition, opportunistically computes the projection derivative
 * if {@code derivate} is {@code true}.
 *
 * @return the matrix of the projection derivative at the given source position,
 *         or {@code null} if the {@code derivate} argument is {@code false}.
 * @throws ProjectionException if the coordinate can not be converted.
 */
@Override
public Matrix transform(final double[] srcPts, final int srcOff, final double[] dstPts, final int dstOff, final boolean derivate) throws ProjectionException {
    final double φ = srcPts[srcOff + 1];
    final double sinφ = sin(φ);
    if (dstPts != null) {
        /*
             * Projection of zero is zero. However the formulas below have a slight rounding error
             * which produce values close to 1E-10, so we will avoid them when y=0. In addition of
             * avoiding rounding error, this also preserve the sign (positive vs negative zero).
             */
        final double y;
        if (φ == 0) {
            y = φ;
        } else {
            /*
                 * See the javadoc of the Spherical inner class for a note
                 * about why we perform explicit checks for the pole cases.
                 */
            final double a = abs(φ);
            if (a < PI / 2) {
                // Snyder (7-7)
                y = log(expOfNorthing(φ, eccentricity * sinφ));
            } else if (a <= (PI / 2 + ANGULAR_TOLERANCE)) {
                y = copySign(POSITIVE_INFINITY, φ);
            } else {
                y = NaN;
            }
        }
        // Scale will be applied by the denormalization matrix.
        dstPts[dstOff] = srcPts[srcOff];
        dstPts[dstOff + 1] = y;
    }
    /*
         * End of map projection. Now compute the derivative, if requested.
         */
    return derivate ? new Matrix2(1, 0, 0, dy_dφ(sinφ, cos(φ))) : null;
}
Also used : Matrix2(org.apache.sis.referencing.operation.matrix.Matrix2)

Example 7 with Matrix2

use of org.apache.sis.referencing.operation.matrix.Matrix2 in project sis by apache.

the class CylindricalEqualArea method transform.

/**
 * Converts the specified (λ,φ) coordinate (units in radians) and stores the result in {@code dstPts}
 * (linear distance on a unit sphere). In addition, opportunistically computes the projection derivative
 * if {@code derivate} is {@code true}.
 *
 * @return the matrix of the projection derivative at the given source position,
 *         or {@code null} if the {@code derivate} argument is {@code false}.
 * @throws ProjectionException if the coordinate can not be converted.
 */
@Override
public Matrix transform(final double[] srcPts, final int srcOff, final double[] dstPts, final int dstOff, final boolean derivate) throws ProjectionException {
    final double φ = srcPts[srcOff + 1];
    final double sinφ = sin(φ);
    if (dstPts != null) {
        // Multiplication by k₀ will be applied by the denormalization matrix.
        dstPts[dstOff] = srcPts[srcOff];
        // Multiplication by (1-ℯ²)/(2k₀) will be applied by the denormalization matrix.
        dstPts[dstOff + 1] = qm_ellipsoid(sinφ);
    }
    /*
         * End of map projection. Now compute the derivative, if requested.
         */
    return derivate ? new Matrix2(1, 0, 0, dqm_dφ(sinφ, cos(φ))) : null;
}
Also used : Matrix2(org.apache.sis.referencing.operation.matrix.Matrix2)

Aggregations

Matrix2 (org.apache.sis.referencing.operation.matrix.Matrix2)7 Test (org.junit.Test)4 MathTransform (org.opengis.referencing.operation.MathTransform)3 Matrix3 (org.apache.sis.referencing.operation.matrix.Matrix3)2 Parameters (org.apache.sis.parameter.Parameters)1 Matrix4 (org.apache.sis.referencing.operation.matrix.Matrix4)1 MathTransform1D (org.opengis.referencing.operation.MathTransform1D)1