Class Transform1S

java.lang.Object
org.apache.commons.geometry.spherical.oned.Transform1S
All Implemented Interfaces:
Function<Point1S,Point1S>, UnaryOperator<Point1S>, Transform<Point1S>

public final class Transform1S extends Object implements Transform<Point1S>
Implementation of the Transform interface for spherical 1D points.

Similar to the Euclidean 1D AffineTransformMatrix1D, this class performs transformations using an internal 1D affine transformation matrix. In the Euclidean case, the matrix contains a scale factor and a translation. Here, the matrix contains a scale/negation factor that takes the values -1 or +1, and a rotation value. This restriction on the allowed values in the matrix is required in order to fulfill the geometric requirements of the Transform interface. For example, if arbitrary scaling is allowed, the point 0.5pi could be scaled by 4 to 2pi, which is equivalent to 0pi. However, if the inverse scaling of 1/4 is applied to 0pi, the result is 0pi and not 0.5pi. This breaks the Transform requirement that transforms be inversible.

Instances of this class are guaranteed to be immutable.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Transform1S
    Static instance representing the identity transform.
    private static final Transform1S
    Static instance that negates azimuth values.
    private final double
    Value to rotate the point azimuth by.
    private final double
    Value to scale the point azimuth by.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Transform1S(double scale, double rotate)
    Construct a new instance from its transform components.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return a transform instance that negates azimuth values.
    createRotation(double angle)
    Return a transform instance that performs a rotation with the given angle.
    boolean
    Return true if the given object is an instance of Transform1S and all transform element values are exactly equal.
    double
    Get the rotation value applied by this instance, in radians.
    int
    Return a transform instance representing the identity transform.
    Get an instance representing the inverse transform.
    boolean
    Return true if the transform negates the azimuth values of transformed points, regardless of any rotation applied subsequently.
    Multiply the underlying matrix of this instance by that of the argument, eg, other * this.
    private static Transform1S
    Multiply two transforms together as matrices.
    Return a new transform created by pre-multiplying this instance by a transform that negates azimuth values.
    Multiply the underlying matrix of the argument by that of this instance, eg, this * other.
    boolean
    Return true if the transform preserves the orientation of the space.
    rotate(double angle)
    Return a new transform created by pre-multiplying this instance by a transform producing a rotation with the given angle.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Field Details

    • IDENTITY

      private static final Transform1S IDENTITY
      Static instance representing the identity transform.
    • NEGATION

      private static final Transform1S NEGATION
      Static instance that negates azimuth values.
    • scale

      private final double scale
      Value to scale the point azimuth by. This will only be +1/-1.
    • rotate

      private final double rotate
      Value to rotate the point azimuth by.
  • Constructor Details

    • Transform1S

      private Transform1S(double scale, double rotate)
      Construct a new instance from its transform components.
      Parameters:
      scale - scale value for the transform; must only be +1 or -1
      rotate - rotation value
  • Method Details

    • isNegation

      public boolean isNegation()
      Return true if the transform negates the azimuth values of transformed points, regardless of any rotation applied subsequently.
      Returns:
      true if the transform negates the azimuth values of transformed points
      See Also:
    • getRotation

      public double getRotation()
      Get the rotation value applied by this instance, in radians.
      Returns:
      the rotation value applied by this instance, in radians.
    • apply

      public Point1S apply(Point1S pt)
      Specified by:
      apply in interface Function<Point1S,Point1S>
    • preservesOrientation

      public boolean preservesOrientation()
      Return true if the transform preserves the orientation of the space. For example, in Euclidean 2D space, this will be true for translations, rotations, and scalings but will be false for reflections.
      Specified by:
      preservesOrientation in interface Transform<Point1S>
      Returns:
      true if the transform preserves the orientation of the space
      See Also:
    • rotate

      public Transform1S rotate(double angle)
      Return a new transform created by pre-multiplying this instance by a transform producing a rotation with the given angle.
      Parameters:
      angle - angle to rotate, in radians
      Returns:
      a new transform created by pre-multiplying this instance by a transform producing a rotation with the given angle
      See Also:
    • negate

      public Transform1S negate()
      Return a new transform created by pre-multiplying this instance by a transform that negates azimuth values.
      Returns:
      a new transform created by pre-multiplying this instance by a transform that negates azimuth values
    • multiply

      public Transform1S multiply(Transform1S other)
      Multiply the underlying matrix of this instance by that of the argument, eg, other * this. The returned transform performs the equivalent of other followed by this.
      Parameters:
      other - transform to multiply with
      Returns:
      a new transform computed by multiplying the matrix of this instance by that of the argument
    • premultiply

      public Transform1S premultiply(Transform1S other)
      Multiply the underlying matrix of the argument by that of this instance, eg, this * other. The returned transform performs the equivalent of this followed by other.
      Parameters:
      other - transform to multiply with
      Returns:
      a new transform computed by multiplying the matrix of the argument by that of this instance
    • inverse

      public Transform1S inverse()
      Get an instance representing the inverse transform.
      Specified by:
      inverse in interface Transform<Point1S>
      Returns:
      an instance representing the inverse transform
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Return true if the given object is an instance of Transform1S and all transform element values are exactly equal.
      Overrides:
      equals in class Object
      Parameters:
      obj - object to test for equality with the current instance
      Returns:
      true if all transform elements are exactly equal; otherwise false
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • identity

      public static Transform1S identity()
      Return a transform instance representing the identity transform.
      Returns:
      a transform instance representing the identity transform
    • createNegation

      public static Transform1S createNegation()
      Return a transform instance that negates azimuth values.
      Returns:
      a transform instance that negates azimuth values.
    • createRotation

      public static Transform1S createRotation(double angle)
      Return a transform instance that performs a rotation with the given angle.
      Parameters:
      angle - angle of the rotation, in radians
      Returns:
      a transform instance that performs a rotation with the given angle
    • multiply

      private static Transform1S multiply(Transform1S a, Transform1S b)
      Multiply two transforms together as matrices.
      Parameters:
      a - first transform
      b - second transform
      Returns:
      the transform computed as a x b