Class Transform1S
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
FieldsModifier and TypeFieldDescriptionprivate 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
ConstructorsModifierConstructorDescriptionprivate
Transform1S
(double scale, double rotate) Construct a new instance from its transform components. -
Method Summary
Modifier and TypeMethodDescriptionstatic Transform1S
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
Return true if the given object is an instance ofTransform1S
and all transform element values are exactly equal.double
Get the rotation value applied by this instance, in radians.int
hashCode()
static Transform1S
identity()
Return a transform instance representing the identity transform.inverse()
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
(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.negate()
Return a new transform created by pre-multiplying this instance by a transform that negates azimuth values.premultiply
(Transform1S other) 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.toString()
-
Field Details
-
IDENTITY
Static instance representing the identity transform. -
NEGATION
Static instance that negates azimuth values. -
scale
private final double scaleValue to scale the point azimuth by. This will only be +1/-1. -
rotate
private final double rotateValue 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 -1rotate
- 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
-
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:
-
rotate
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
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
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
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
Get an instance representing the inverse transform. -
hashCode
public int hashCode() -
equals
Return true if the given object is an instance ofTransform1S
and all transform element values are exactly equal. -
toString
-
identity
Return a transform instance representing the identity transform.- Returns:
- a transform instance representing the identity transform
-
createNegation
Return a transform instance that negates azimuth values.- Returns:
- a transform instance that negates azimuth values.
-
createRotation
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
Multiply two transforms together as matrices.- Parameters:
a
- first transformb
- second transform- Returns:
- the transform computed as
a x b
-