Class Transform2S

  • All Implemented Interfaces:
    java.util.function.Function<Point2S,​Point2S>, java.util.function.UnaryOperator<Point2S>, Transform<Point2S>

    public final class Transform2S
    extends java.lang.Object
    implements Transform<Point2S>
    Implementation of the Transform interface for spherical 2D points.

    This class uses an AffineTransformMatrix3D to perform spherical point transforms in Euclidean 3D space.

    Instances of this class are guaranteed to be immutable.

    • Field Detail

      • IDENTITY

        private static final Transform2S IDENTITY
        Static instance representing the identity transform.
      • XY_PLANE_REFLECTION

        private static final AffineTransformMatrix3D XY_PLANE_REFLECTION
        Static transform instance that reflects across the x-y plane.
      • euclideanTransform

        private final AffineTransformMatrix3D euclideanTransform
        Euclidean transform matrix underlying the spherical transform.
    • Constructor Detail

      • Transform2S

        private Transform2S​(AffineTransformMatrix3D euclideanTransform)
        Construct a new instance from its underlying Euclidean transform.
        Parameters:
        euclideanTransform - underlying Euclidean transform
    • Method Detail

      • getEuclideanTransform

        public AffineTransformMatrix3D getEuclideanTransform()
        Get the Euclidean transform matrix underlying the spherical transform.
        Returns:
        the Euclidean transform matrix underlying the spherical transform
      • 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<Point2S>
        Returns:
        true if the transform preserves the orientation of the space
        See Also:
        Orientation
      • inverse

        public Transform2S inverse()
        Get an instance representing the inverse transform.
        Specified by:
        inverse in interface Transform<Point2S>
        Returns:
        an instance representing the inverse transform
      • rotate

        public Transform2S rotate​(Point2S pt,
                                  double angle)
        Apply a rotation of angle radians around the given point to this instance.
        Parameters:
        pt - point to rotate around
        angle - rotation angle in radians
        Returns:
        transform resulting from applying the specified rotation to this instance
      • rotate

        public Transform2S rotate​(Vector3D axis,
                                  double angle)
        Apply a rotation of angle radians around the given 3D axis to this instance.
        Parameters:
        axis - 3D axis of rotation
        angle - rotation angle in radians
        Returns:
        transform resulting from applying the specified rotation to this instance
      • rotate

        public Transform2S rotate​(QuaternionRotation quaternion)
        Apply the given quaternion rotation to this instance.
        Parameters:
        quaternion - quaternion rotation to apply
        Returns:
        transform resulting from applying the specified rotation to this instance
      • reflect

        public Transform2S reflect​(Point2S pole)
        Apply a reflection across the equatorial plane defined by the given pole point to this instance.
        Parameters:
        pole - pole point defining the equatorial reflection plane
        Returns:
        transform resulting from applying the specified reflection to this instance
      • reflect

        public Transform2S reflect​(Vector3D poleVector)
        Apply a reflection across the equatorial plane defined by the given pole vector to this instance.
        Parameters:
        poleVector - pole vector defining the equatorial reflection plane
        Returns:
        transform resulting from applying the specified reflection to this instance
      • multiply

        public Transform2S multiply​(Transform2S other)
        Multiply the underlying Euclidean transform 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
        See Also:
        AffineTransformMatrix3D.multiply(AffineTransformMatrix3D)
      • premultiply

        public Transform2S premultiply​(Transform2S other)
        Multiply the underlying Euclidean transform 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
        See Also:
        AffineTransformMatrix3D.premultiply(AffineTransformMatrix3D)
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Return true if the given object is an instance of Transform2S and the underlying Euclidean transform matrices are exactly equal.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - object to test for equality with the current instance
        Returns:
        true if the underlying transform matrices are exactly equal
      • toString

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

        public static Transform2S identity()
        Return an instance representing the identity transform. This transform is guaranteed to return an equivalent (ie, co-located) point for any input point. However, the points are not guaranteed to contain exactly equal coordinates. For example, at the poles, an infinite number of points exist that vary only in the azimuth coordinate. When one of these points is transformed by this identity transform, the returned point may contain a different azimuth value from the input, but it will still represent the same location in space.
        Returns:
        an instance representing the identity transform
      • createRotation

        public static Transform2S createRotation​(Point2S pt,
                                                 double angle)
        Create a transform that rotates the given angle around pt.
        Parameters:
        pt - point to rotate around
        angle - angle of rotation in radians
        Returns:
        a transform that rotates the given angle around pt
      • createRotation

        public static Transform2S createRotation​(Vector3D axis,
                                                 double angle)
        Create a transform that rotates the given angle around axis.
        Parameters:
        axis - 3D axis of rotation
        angle - angle of rotation in radians
        Returns:
        a transform that rotates the given angle axis
      • createRotation

        public static Transform2S createRotation​(QuaternionRotation quaternion)
        Create a transform that performs the given 3D rotation.
        Parameters:
        quaternion - quaternion instance representing the 3D rotation
        Returns:
        a transform that performs the given 3D rotation
      • createReflection

        public static Transform2S createReflection​(Point2S pole)
        Create a transform that performs a reflection across the equatorial plane defined by the given pole point.
        Parameters:
        pole - pole point defining the equatorial reflection plane
        Returns:
        a transform that performs a reflection across the equatorial plane defined by the given pole point
      • createReflection

        public static Transform2S createReflection​(Vector3D poleVector)
        Create a transform that performs a reflection across the equatorial plane defined by the given pole point.
        Parameters:
        poleVector - pole vector defining the equatorial reflection plane
        Returns:
        a transform that performs a reflection across the equatorial plane defined by the given pole point
      • multiply

        private static Transform2S multiply​(Transform2S a,
                                            Transform2S b)
        Multiply the Euclidean transform matrices of the arguments together.
        Parameters:
        a - first transform
        b - second transform
        Returns:
        the transform computed as a x b