Package org.apache.sis.referencing.operation.transform

# Class AbstractMathTransform1D

Object
FormattableObject
AbstractMathTransform
AbstractMathTransform1D

All Implemented Interfaces:
  `Parameterized`, `LenientComparable`, `MathTransform`, `MathTransform1D`

public abstract class AbstractMathTransform1D extends AbstractMathTransform implements MathTransform1D
Base class for math transforms that are known to be one-dimensional in all cases. One-dimensional math transforms are not required to extend this class, however doing so may simplify their implementation.

The simplest way to implement this abstract class is to provide an implementation for the following methods only:

- `transform(double)`
- `derivative(double)`

## Immutability and thread safety

All Apache SIS implementations of `MathTransform1D` are immutable and thread-safe. It is highly recommended that third-party implementations be immutable and thread-safe too. This means that unless otherwise noted in the javadoc, `MathTransform1D` instances can be shared by many objects and passed between threads without synchronization.

## Serialization

`MathTransform1D` may or may not be serializable, at implementation choices. Most Apache SIS implementations are serializable, but the serialized objects are not guaranteed to be compatible with future SIS versions. Serialization should be used only for short term storage or RMI between applications running the same SIS version.

Since:
  0.5

Defined in the `sis-referencing` module

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected static class`
  `AbstractMathTransform1D​.Inverse`
  Base class for implementation of inverse math transforms.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `AbstractMathTransform1D()`
  Constructor for subclasses.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract double`
  `derivative(double value)`
  Gets the derivative of this function at a value.
  `Matrix`
  `derivative(DirectPosition point)`
  Gets the derivative of this transform at a point.
  `final int`
  `getSourceDimensions()`
  Returns the dimension of input points, which is always 1.
  `final int`
  `getTargetDimensions()`
  Returns the dimension of output points, which is always 1.
  `MathTransform1D`
  `inverse()`
  Returns the inverse transform of this object.
  `abstract double`
  `transform(double value)`
  Transforms the specified value.
  `Matrix`
  `transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate)`
  Transforms a single point in the given array and opportunistically computes its derivative if requested.

  ### Methods inherited from class AbstractMathTransform

  `computeHashCode, equals, equals, formatTo, getContextualParameters, getParameterDescriptors, getParameterValues, hashCode, isIdentity, transform, transform, transform, transform, transform, tryConcatenate`

  ### Methods inherited from class FormattableObject

  `print, toString, toString, toWKT`

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface MathTransform

  `isIdentity, toWKT, transform, transform, transform, transform, transform`

- ## Constructor Details

  - ### AbstractMathTransform1D

    protected AbstractMathTransform1D()
    Constructor for subclasses.

- ## Method Details

  - ### getSourceDimensions

    public final int getSourceDimensions()
    Returns the dimension of input points, which is always 1.
    Specified by:
      `getSourceDimensions` in interface `MathTransform`
    Specified by:
      `getSourceDimensions` in class `AbstractMathTransform`
    Returns:
      the dimension of input points.
    See Also:
      - `DefaultOperationMethod​.getSourceDimensions()`

  - ### getTargetDimensions

    public final int getTargetDimensions()
    Returns the dimension of output points, which is always 1.
    Specified by:
      `getTargetDimensions` in interface `MathTransform`
    Specified by:
      `getTargetDimensions` in class `AbstractMathTransform`
    Returns:
      the dimension of output points.
    See Also:
      - `DefaultOperationMethod​.getTargetDimensions()`

  - ### transform

    public abstract double transform(double value) throws TransformException
    Transforms the specified value.
    Specified by:
      `transform` in interface `MathTransform1D`
    Parameters:
      `value` - the value to transform.
    Returns:
      the transformed value.
    Throws:
      `TransformException` - if the value can not be transformed.

  - ### transform

    public Matrix transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, boolean derivate) throws TransformException
    Transforms a single point in the given array and opportunistically computes its derivative if requested. The default implementation delegates to `transform(double)` and potentially to `derivative(double)`. Subclasses may override this method for performance reason.
    Specified by:
      `transform` in class `AbstractMathTransform`
    Parameters:
      `srcPts` - the array containing the source coordinate (can not be `null`).
      `srcOff` - the offset to the point to be transformed in the source array.
      `dstPts` - the array into which the transformed coordinate is returned. May be the same than `srcPts`. May be `null` if only the derivative matrix is desired.
      `dstOff` - the offset to the location of the transformed point that is stored in the destination array.
      `derivate` - `true` for computing the derivative, or `false` if not needed.
    Returns:
      the matrix of the transform derivative at the given source position, or `null` if the `derivate` argument is `false`.
    Throws:
      `TransformException` - if the point can not be transformed or if a problem occurred while calculating the derivative.
    See Also:
      - `AbstractMathTransform​.derivative(DirectPosition)`
      - `AbstractMathTransform​.transform(DirectPosition, DirectPosition)`
      - `MathTransforms​.derivativeAndTransform(MathTransform, double[], int, double[], int)`

  - ### derivative

    public abstract double derivative(double value) throws TransformException
    Gets the derivative of this function at a value. The derivative is the 1×1 matrix of the non-translating portion of the approximate affine map at the value.
    Specified by:
      `derivative` in interface `MathTransform1D`
    Parameters:
      `value` - the value where to evaluate the derivative.
    Returns:
      the derivative at the specified point.
    Throws:
      `TransformException` - if the derivative can not be evaluated at the specified point.

  - ### derivative

    public Matrix derivative(DirectPosition point) throws TransformException
    Gets the derivative of this transform at a point. The default implementation ensures that `point` is one-dimensional, then delegates to `derivative(double)`.
    Specified by:
      `derivative` in interface `MathTransform`
    Overrides:
      `derivative` in class `AbstractMathTransform`
    Parameters:
      `point` - the coordinate point where to evaluate the derivative, or `null`.
    Returns:
      the derivative at the specified point (never `null`).
    Throws:
      `MismatchedDimensionException` - if `point` does not have the expected dimension.
      `TransformException` - if the derivative can not be evaluated at the specified point.

  - ### inverse

    public MathTransform1D inverse() throws NoninvertibleTransformException
    Returns the inverse transform of this object. The default implementation returns `this` if this transform is an identity transform, or throws an exception otherwise. Subclasses should override this method.
    Specified by:
      `inverse` in interface `MathTransform`
    Specified by:
      `inverse` in interface `MathTransform1D`
    Overrides:
      `inverse` in class `AbstractMathTransform`
    Throws:
      `NoninvertibleTransformException`