Class Transform1S
- java.lang.Object
-
- org.apache.commons.geometry.spherical.oned.Transform1S
-
- All Implemented Interfaces:
java.util.function.Function<Point1S,Point1S>,java.util.function.UnaryOperator<Point1S>,Transform<Point1S>
public final class Transform1S extends java.lang.Object implements Transform<Point1S>
Implementation of theTransforminterface 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 theTransforminterface. For example, if arbitrary scaling is allowed, the point0.5picould be scaled by 4 to2pi, which is equivalent to0pi. However, if the inverse scaling of1/4is applied to0pi, the result is0piand not0.5pi. This breaks theTransformrequirement that transforms be inversible.Instances of this class are guaranteed to be immutable.
-
-
Field Summary
Fields Modifier and Type Field Description private static Transform1SIDENTITYStatic instance representing the identity transform.private static Transform1SNEGATIONStatic instance that negates azimuth values.private doublerotateValue to rotate the point azimuth by.private doublescaleValue to scale the point azimuth by.
-
Constructor Summary
Constructors Modifier Constructor Description privateTransform1S(double scale, double rotate)Construct a new instance from its transform components.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Point1Sapply(Point1S pt)static Transform1ScreateNegation()Return a transform instance that negates azimuth values.static Transform1ScreateRotation(double angle)Return a transform instance that performs a rotation with the given angle.booleanequals(java.lang.Object obj)Return true if the given object is an instance ofTransform1Sand all transform element values are exactly equal.doublegetRotation()Get the rotation value applied by this instance, in radians.inthashCode()static Transform1Sidentity()Return a transform instance representing the identity transform.Transform1Sinverse()Get an instance representing the inverse transform.booleanisNegation()Return true if the transform negates the azimuth values of transformed points, regardless of any rotation applied subsequently.Transform1Smultiply(Transform1S other)Multiply the underlying matrix of this instance by that of the argument, eg,other * this.private static Transform1Smultiply(Transform1S a, Transform1S b)Multiply two transforms together as matrices.Transform1Snegate()Return a new transform created by pre-multiplying this instance by a transform that negates azimuth values.Transform1Spremultiply(Transform1S other)Multiply the underlying matrix of the argument by that of this instance, eg,this * other.booleanpreservesOrientation()Return true if the transform preserves the orientation of the space.Transform1Srotate(double angle)Return a new transform created by pre-multiplying this instance by a transform producing a rotation with the given angle.java.lang.StringtoString()
-
-
-
Field Detail
-
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.
-
-
Method Detail
-
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:
preservesOrientation()
-
getRotation
public double getRotation()
Get the rotation value applied by this instance, in radians.- Returns:
- the rotation value applied by this instance, in radians.
-
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<Point1S>- Returns:
- true if the transform preserves the orientation of the space
- See Also:
- Orientation
-
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:
createRotation(double)
-
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 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
-
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 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
-
inverse
public Transform1S inverse()
Get an instance representing the inverse transform.
-
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 ofTransform1Sand all transform element values are exactly equal.- Overrides:
equalsin classjava.lang.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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.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 transformb- second transform- Returns:
- the transform computed as
a x b
-
-