Class Transform2S
- java.lang.Object
-
- org.apache.commons.geometry.spherical.twod.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 theTransforminterface for spherical 2D points.This class uses an
AffineTransformMatrix3Dto perform spherical point transforms in Euclidean 3D space.Instances of this class are guaranteed to be immutable.
-
-
Field Summary
Fields Modifier and Type Field Description private AffineTransformMatrix3DeuclideanTransformEuclidean transform matrix underlying the spherical transform.private static Transform2SIDENTITYStatic instance representing the identity transform.private static AffineTransformMatrix3DXY_PLANE_REFLECTIONStatic transform instance that reflects across the x-y plane.
-
Constructor Summary
Constructors Modifier Constructor Description privateTransform2S(AffineTransformMatrix3D euclideanTransform)Construct a new instance from its underlying Euclidean transform.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Point2Sapply(Point2S pt)static Transform2ScreateReflection(Vector3D poleVector)Create a transform that performs a reflection across the equatorial plane defined by the given pole point.static Transform2ScreateReflection(Point2S pole)Create a transform that performs a reflection across the equatorial plane defined by the given pole point.static Transform2ScreateRotation(QuaternionRotation quaternion)Create a transform that performs the given 3D rotation.static Transform2ScreateRotation(Vector3D axis, double angle)Create a transform that rotates the given angle aroundaxis.static Transform2ScreateRotation(Point2S pt, double angle)Create a transform that rotates the given angle aroundpt.booleanequals(java.lang.Object obj)Return true if the given object is an instance ofTransform2Sand the underlying Euclidean transform matrices are exactly equal.AffineTransformMatrix3DgetEuclideanTransform()Get the Euclidean transform matrix underlying the spherical transform.inthashCode()static Transform2Sidentity()Return an instance representing the identity transform.Transform2Sinverse()Get an instance representing the inverse transform.Transform2Smultiply(Transform2S other)Multiply the underlying Euclidean transform of this instance by that of the argument, eg,other * this.private static Transform2Smultiply(Transform2S a, Transform2S b)Multiply the Euclidean transform matrices of the arguments together.Transform2Spremultiply(Transform2S other)Multiply the underlying Euclidean transform matrix of the argument by that of this instance, eg,this * other.booleanpreservesOrientation()Return true if the transform preserves the orientation of the space.Transform2Sreflect(Vector3D poleVector)Apply a reflection across the equatorial plane defined by the given pole vector to this instance.Transform2Sreflect(Point2S pole)Apply a reflection across the equatorial plane defined by the given pole point to this instance.Transform2Srotate(QuaternionRotation quaternion)Apply the given quaternion rotation to this instance.Transform2Srotate(Vector3D axis, double angle)Apply a rotation ofangleradians around the given 3D axis to this instance.Transform2Srotate(Point2S pt, double angle)Apply a rotation ofangleradians around the given point to this instance.java.lang.StringtoString()
-
-
-
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:
preservesOrientationin interfaceTransform<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.
-
rotate
public Transform2S rotate(Point2S pt, double angle)
Apply a rotation ofangleradians around the given point to this instance.- Parameters:
pt- point to rotate aroundangle- 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 ofangleradians around the given 3D axis to this instance.- Parameters:
axis- 3D axis of rotationangle- 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 ofotherfollowed bythis.- 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 ofthisfollowed byother.- 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Return true if the given object is an instance ofTransform2Sand the underlying Euclidean transform matrices are exactly equal.- Overrides:
equalsin classjava.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:
toStringin classjava.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 aroundpt.- Parameters:
pt- point to rotate aroundangle- 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 aroundaxis.- Parameters:
axis- 3D axis of rotationangle- 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 transformb- second transform- Returns:
- the transform computed as
a x b
-
-