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 theTransform
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 theTransform
interface. For example, if arbitrary scaling is allowed, the point0.5pi
could be scaled by 4 to2pi
, which is equivalent to0pi
. However, if the inverse scaling of1/4
is applied to0pi
, the result is0pi
and not0.5pi
. This breaks theTransform
requirement that transforms be inversible.Instances of this class are guaranteed to be immutable.
-
-
Field Summary
Fields Modifier and Type Field Description private static Transform1S
IDENTITY
Static instance representing the identity transform.private static Transform1S
NEGATION
Static instance that negates azimuth values.private double
rotate
Value to rotate the point azimuth by.private double
scale
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Point1S
apply(Point1S pt)
static Transform1S
createNegation()
Return a transform instance that negates azimuth values.static Transform1S
createRotation(double angle)
Return a transform instance that performs a rotation with the given angle.boolean
equals(java.lang.Object obj)
Return true if the given object is an instance ofTransform1S
and all transform element values are exactly equal.double
getRotation()
Get the rotation value applied by this instance, in radians.int
hashCode()
static Transform1S
identity()
Return a transform instance representing the identity transform.Transform1S
inverse()
Get an instance representing the inverse transform.boolean
isNegation()
Return true if the transform negates the azimuth values of transformed points, regardless of any rotation applied subsequently.Transform1S
multiply(Transform1S other)
Multiply the underlying matrix of this instance by that of the argument, eg,other * this
.private static Transform1S
multiply(Transform1S a, Transform1S b)
Multiply two transforms together as matrices.Transform1S
negate()
Return a new transform created by pre-multiplying this instance by a transform that negates azimuth values.Transform1S
premultiply(Transform1S other)
Multiply the underlying matrix of the argument by that of this instance, eg,this * other
.boolean
preservesOrientation()
Return true if the transform preserves the orientation of the space.Transform1S
rotate(double angle)
Return a new transform created by pre-multiplying this instance by a transform producing a rotation with the given angle.java.lang.String
toString()
-
-
-
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:
preservesOrientation
in 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 ofother
followed 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 ofthis
followed 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Return true if the given object is an instance ofTransform1S
and all transform element values are exactly equal.- Overrides:
equals
in 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:
toString
in 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
-
-