public final class Cartesian extends Object implements IEquatable<Cartesian>, IEquatableEpsilon<Cartesian>, ImmutableValueType
The corresponding 2-dimensional coordinates are Rectangular
coordinates.
Constructor and Description |
---|
Cartesian()
Initializes a new instance.
|
Cartesian(AzimuthElevationRange coordinates)
Initializes a set of
Cartesian coordinates from the provided set of
AzimuthElevationRange coordinates. |
Cartesian(Cylindrical coordinates)
Initializes a set of
Cartesian coordinates from the provided set of Cylindrical coordinates. |
Cartesian(double[] elements)
Initializes a set of
Cartesian coordinates from the first 3 consecutive elements in the provided array. |
Cartesian(double[] elements,
int startIndex)
Initializes a set of
Cartesian coordinates from 3 consecutive elements in the provided array. |
Cartesian(double x,
double y,
double z)
Initializes a set of
Cartesian coordinates from the provided values. |
Cartesian(LongitudeLatitudeRadius coordinates)
Initializes a set of
Cartesian coordinates from the provided set of LongitudeLatitudeRadius coordinates. |
Cartesian(Pyramidal coordinates)
|
Cartesian(Spherical coordinates)
|
Modifier and Type | Method and Description |
---|---|
Cartesian |
add(Cartesian other)
Adds the specified set of
Cartesian coordinates to this instance. |
static Cartesian |
add(Cartesian left,
Cartesian right)
|
static Motion1<Cartesian> |
convertMotion(Motion1<LongitudeLatitudeRadius> motion,
int order)
Converts the motion given in terms of a set of
LongitudeLatitudeRadius coordinates to motion
of the corresponding set of Cartesian coordinates. |
Cartesian |
cross(Cartesian other)
Forms the cross product of the specified set of
Cartesian coordinates with this instance. |
static Cartesian |
divide(Cartesian left,
double right)
Divides a specified set of
Cartesian coordinates by a scalar. |
Cartesian |
divide(double scalar)
Divides this instance by a scalar.
|
double |
dot(Cartesian other)
Forms the dot product of the specified set of
Cartesian coordinates with this instance. |
static boolean |
equals(Cartesian left,
Cartesian right)
Returns
true if the two instances are exactly equal. |
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
boolean |
equalsEpsilon(Cartesian other,
double epsilon)
Indicates whether each coordinate value of another instance of this type
is within the required tolerance of the corresponding coordinate value of this instance.
|
boolean |
equalsType(Cartesian other)
Indicates whether another instance of this type is exactly equal to this instance.
|
double |
get(int index)
|
boolean |
getHasZeroMagnitude()
Gets a value indicating whether the
Magnitude (get ) of this instance is zero. |
boolean |
getIsUndefined()
Gets a value indicating whether or not any of the coordinates for this instance have the value
Double.NaN . |
int |
getLength()
Gets the number of elements in this set of coordinates.
|
double |
getMagnitude()
Gets the magnitude of this instance.
|
double |
getMagnitudeSquared()
Gets the square of the
Magnitude (get ) of this instance. |
UnitCartesian |
getMostOrthogonalAxis()
Gets the axis which is most orthogonal to this instance.
|
UnitCartesian |
getMostParallelAxis()
Gets the axis which is most parallel to this instance.
|
static Cartesian |
getUndefined()
Gets a set of
Cartesian coordinates with values of Double.NaN . |
double |
getX()
Gets the linear coordinate along the positive x-axis.
|
double |
getY()
Gets the linear coordinate along the positive y-axis.
|
double |
getZ()
Gets the linear coordinate along the positive z-axis.
|
static Cartesian |
getZero()
Gets a set of
Cartesian coordinates with values of zero. |
int |
hashCode()
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
Cartesian |
invert()
Inverts this instance.
|
static Cartesian |
multiply(Cartesian left,
double right)
Multiplies a specified set of
Cartesian coordinates by a scalar. |
static Cartesian |
multiply(Cartesian left,
Matrix3By3 right)
Multiplies a specified set of
Cartesian coordinates by a Matrix3By3 . |
Cartesian |
multiply(double scalar)
Multiplies this instance by a scalar.
|
static Cartesian |
multiply(double left,
Cartesian right)
Multiplies a scalar by a specified set of
Cartesian coordinates. |
Cartesian |
multiply(Matrix3By3 matrix)
Multiplies this instance (treated as a row vector) by a
Matrix3By3 . |
static Cartesian |
negate(Cartesian coordinates)
|
UnitCartesian |
normalize()
Forms a set of
UnitCartesian coordinates from this instance. |
UnitCartesian |
normalize(double[] magnitude)
Forms a set of
UnitCartesian coordinates from this instance
and returns the Magnitude (get ) of the original instance in the provided parameter. |
static boolean |
notEquals(Cartesian left,
Cartesian right)
Returns
true if the two instances are not exactly equal. |
Cartesian |
rotate(ElementaryRotation rotation)
Produces a set of
Cartesian coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided ElementaryRotation rotation. |
Cartesian |
rotate(Matrix3By3 rotation)
Produces a set of
Cartesian coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided Matrix3By3 rotation. |
Cartesian |
rotate(UnitQuaternion rotation)
Produces a set of
Cartesian coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided UnitQuaternion rotation. |
Cartesian |
subtract(Cartesian other)
Subtracts the specified set of
Cartesian coordinates from this instance. |
static Cartesian |
subtract(Cartesian left,
Cartesian right)
|
static Cartesian |
toCartesian(UnitCartesian coordinates)
Converts a set of
UnitCartesian coordinates to a set of Cartesian coordinates. |
String |
toString()
Returns the string representation of the value of this instance.
|
public Cartesian()
public Cartesian(double x, double y, double z)
Cartesian
coordinates from the provided values.x
- The linear coordinate along the positive x-axis.y
- The linear coordinate along the positive y-axis.z
- The linear coordinate along the positive z-axis.public Cartesian(@Nonnull Spherical coordinates)
coordinates
- The set of Spherical
coordinates.public Cartesian(@Nonnull LongitudeLatitudeRadius coordinates)
Cartesian
coordinates from the provided set of LongitudeLatitudeRadius
coordinates.coordinates
- The set of LongitudeLatitudeRadius
coordinates.public Cartesian(@Nonnull Cylindrical coordinates)
Cartesian
coordinates from the provided set of Cylindrical
coordinates.coordinates
- The set of Cylindrical
coordinates.public Cartesian(@Nonnull Pyramidal coordinates)
coordinates
- The set of Pyramidal
coordinates.public Cartesian(@Nonnull AzimuthElevationRange coordinates)
Cartesian
coordinates from the provided set of
AzimuthElevationRange
coordinates.coordinates
- The set of AzimuthElevationRange
coordinates.public Cartesian(@Nonnull double[] elements)
Cartesian
coordinates from the first 3 consecutive elements in the provided array.elements
- The array of coordinate values.ArgumentNullException
- Thrown when elements
is null
.ArgumentOutOfRangeException
- An object of this type must be constructed from an array with at least 3 elements
.public Cartesian(@Nonnull double[] elements, int startIndex)
Cartesian
coordinates from 3 consecutive elements in the provided array.elements
- The array of coordinate values.startIndex
- The index of the first element in the array to use.ArgumentNullException
- Thrown when the array of elements
is null
.ArgumentOutOfRangeException
- Thrown when an object of this type is constructed from an array with less than 3 elements
.@Nonnull public static Cartesian getZero()
Cartesian
coordinates with values of zero.@Nonnull public static Cartesian getUndefined()
Cartesian
coordinates with values of Double.NaN
.
Use IsUndefined
(get
) to test whether a Cartesian
instance
is undefined since it will return true
if any of the coordinate values
are Double.NaN
.
@Nonnull public static Motion1<Cartesian> convertMotion(@Nonnull Motion1<LongitudeLatitudeRadius> motion, int order)
LongitudeLatitudeRadius
coordinates to motion
of the corresponding set of Cartesian
coordinates.motion
- The LongitudeLatitudeRadius
motion.order
- The order of the highest derivative to convert.Cartesian
.public final double getX()
public final double getY()
public final double getZ()
@Nonnull public final Cartesian invert()
Cartesian
coordinates that represents the inverse of this instance.@Nonnull public final Cartesian multiply(double scalar)
scalar
- The multiplier, or value which is to multiply this instance.Cartesian
coordinates that represents the result of the multiplication.@Nonnull public final Cartesian multiply(@Nonnull Matrix3By3 matrix)
Matrix3By3
.matrix
- The Matrix3By3
which will be premultiplied by this instance.Cartesian
coordinates that represents the result of the multiplication.@Nonnull public final Cartesian divide(double scalar)
scalar
- The divisor, or value which is to divide this instance.Cartesian
coordinates that represents the result of the division.@Nonnull public final Cartesian add(@Nonnull Cartesian other)
Cartesian
coordinates to this instance.other
- The addend, or value which is to be added to this instance.Cartesian
coordinates that represents the result of the addition.@Nonnull public final Cartesian subtract(@Nonnull Cartesian other)
Cartesian
coordinates from this instance.other
- The subtrahend, or value which is to be subtracted from this instance.Cartesian
coordinates that represents the result of the subtraction.@Nonnull public final Cartesian cross(@Nonnull Cartesian other)
Cartesian
coordinates with this instance.public final double dot(@Nonnull Cartesian other)
Cartesian
coordinates with this instance.other
- The set of Cartesian
coordinates to dot with this instance.double
that represents the result of the product.@Nonnull public static Cartesian multiply(@Nonnull Cartesian left, @Nonnull Matrix3By3 right)
Cartesian
coordinates by a Matrix3By3
.left
- The multiplicand, or value which is to be multiplied by right
.right
- The multiplier, or value which is to multiply left
.Cartesian
coordinates that represents the result of the multiplication.@Nonnull public static Cartesian multiply(@Nonnull Cartesian left, double right)
Cartesian
coordinates by a scalar.left
- The multiplicand, or value which is to be multiplied by right
.right
- The multiplier, or value which is to multiply left
.Cartesian
coordinates that represents the result of the multiplication.@Nonnull public static Cartesian multiply(double left, @Nonnull Cartesian right)
Cartesian
coordinates.left
- The multiplicand, or value which is to be multiplied by right
.right
- The multiplier, or value which is to multiply left
.Cartesian
coordinates that represents the result of the multiplication.@Nonnull public static Cartesian divide(@Nonnull Cartesian left, double right)
Cartesian
coordinates by a scalar.left
- The dividend, or value which is to be divided by right
.right
- The divisor, or value which is to divide left
.Cartesian
coordinates that represents the result of the division.@Nonnull public static Cartesian add(@Nonnull Cartesian left, @Nonnull Cartesian right)
left
- The augend, or value to which right
is to be added.right
- The addend, or value which is to be added to left
.Cartesian
coordinates that represents the result of the addition.@Nonnull public static Cartesian subtract(@Nonnull Cartesian left, @Nonnull Cartesian right)
Cartesian
coordinates from another specified set of Cartesian
coordinates.left
- The minuend, or value from which right
is to be subtracted.right
- The subtrahend, or value which is to be subtracted from left
.Cartesian
coordinates that represents the result of the subtraction.@Nonnull public static Cartesian negate(@Nonnull Cartesian coordinates)
coordinates
- The set of coordinates.Cartesian
coordinates.@Nonnull public final Cartesian rotate(@Nonnull ElementaryRotation rotation)
Cartesian
coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided ElementaryRotation
rotation.
This type of rotation is sometimes referred to as an "alias rotation".
For more information on how quaternions and other coordinates are used to represent rotations, see the Coordinates topic.
rotation
- The ElementaryRotation
.Cartesian
coordinates which is the result of the rotation.UnsupportedCaseException
- Thrown if rotation
's Axis
(get
) property is not an AxisIndicator.FIRST
,
AxisIndicator.SECOND
, or AxisIndicator.THIRD
.@Nonnull public final Cartesian rotate(@Nonnull Matrix3By3 rotation)
Cartesian
coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided Matrix3By3
rotation.
This type of rotation is sometimes referred to as an "alias rotation".
For more information on how quaternions and other coordinates are used to represent rotations, see the Coordinates topic.
rotation
- The Matrix3By3
rotation.Cartesian
coordinates which is the result of the rotation.@Nonnull public final Cartesian rotate(@Nonnull UnitQuaternion rotation)
Cartesian
coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided UnitQuaternion
rotation.
This type of rotation is sometimes referred to as an "alias rotation".
For more information on how quaternions and other coordinates are used to represent rotations, see the Coordinates topic.
rotation
- The UnitQuaternion
rotation.Cartesian
coordinates which is the result of the rotation.@Nonnull public final UnitCartesian getMostOrthogonalAxis()
@Nonnull public final UnitCartesian getMostParallelAxis()
public final boolean getIsUndefined()
Double.NaN
.public final int getLength()
public final double get(int index)
index
of 0, 1, and 2 corresponding to the coordinates
X
(get
), Y
(get
), and Z
(get
).index
- The index to retrieve.index
.ArgumentOutOfRangeException
- Thrown when index
is less than 0 or greater than or equal to Length
(get
).public boolean equals(Object obj)
equals
in class Object
obj
- The object to compare to this instance.true
if obj
is an instance of this type and represents the same value as this instance; otherwise false
.Object.hashCode()
,
HashMap
public final boolean equalsType(@Nonnull Cartesian other)
equalsType
in interface IEquatable<Cartesian>
other
- The instance to compare to this instance.true
if other
represents the same value as this instance; otherwise false
.public final boolean equalsEpsilon(@Nonnull Cartesian other, double epsilon)
equalsEpsilon
in interface IEquatableEpsilon<Cartesian>
other
- The set of Cartesian
coordinates to compare to this instance.epsilon
- The limit at which the absolute differences between the coordinate values will not be considered equal.true
if the absolute differences are less than or equal to epsilon
; otherwise false
.public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
public static boolean equals(@Nonnull Cartesian left, @Nonnull Cartesian right)
true
if the two instances are exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
represents the same value as right
; otherwise false
.public static boolean notEquals(@Nonnull Cartesian left, @Nonnull Cartesian right)
true
if the two instances are not exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
does not represent the same value as right
; otherwise false
.public final double getMagnitude()
public final double getMagnitudeSquared()
Magnitude
(get
) of this instance.public final boolean getHasZeroMagnitude()
Magnitude
(get
) of this instance is zero.@Nonnull public final UnitCartesian normalize()
UnitCartesian
coordinates from this instance.
The normalization of the cartesian components is accomplished in the usual way. It should be noted that this does not guarantee a result whose magnitude will be 1.0 in cases where an individual component underflows upon squaring.
UnitCartesian
coordinates.ArithmeticException
- The magnitude of the provided coordinates must not be zero.NotFiniteNumberException
- The magnitude of the provided coordinates must not be infinite.@Nonnull public final UnitCartesian normalize(@Nonnull double[] magnitude)
UnitCartesian
coordinates from this instance
and returns the Magnitude
(get
) of the original instance in the provided parameter.
The normalization of the cartesian components is accomplished in the usual way. It should be noted that this does not guarantee a result whose magnitude will be 1.0 in cases where an individual component underflows upon squaring.
magnitude
- On input, an array with one element. On return, the array is populated with
the magnitude of the original set of Cartesian
coordinates.UnitCartesian
coordinates.ArithmeticException
- The magnitude of the provided coordinates must not be zero.NotFiniteNumberException
- The magnitude of the provided coordinates must not be infinite.@Nonnull public static Cartesian toCartesian(@Nonnull UnitCartesian coordinates)
UnitCartesian
coordinates to a set of Cartesian
coordinates.coordinates
- The set of UnitCartesian
coordinates.Cartesian
coordinates.