public final class UnitCartesian extends Object implements IEquatable<UnitCartesian>, IEquatableEpsilon<UnitCartesian>, ImmutableValueType
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.
The corresponding 2-dimensional coordinates are UnitRectangular
coordinates.
Constructor and Description |
---|
UnitCartesian()
Initializes a new instance.
|
UnitCartesian(Cartesian coordinates)
Initializes a set of
UnitCartesian coordinates from the provided set of Cartesian coordinates. |
UnitCartesian(Cartesian coordinates,
double[] magnitude)
Initializes a set of
UnitCartesian coordinates from the provided set of Cartesian coordinates. |
UnitCartesian(double[] elements)
Initializes a set of
UnitCartesian coordinates from the first 3 consecutive elements in the provided array. |
UnitCartesian(double[] elements,
int startIndex)
Initializes a set of
UnitCartesian coordinates from 3 consecutive elements in the provided array. |
UnitCartesian(double clock,
double cone)
Initializes a set of
UnitCartesian coordinates from the provided spherical coordinates. |
UnitCartesian(double x,
double y,
double z)
Initializes a set of
UnitCartesian coordinates from the provided values. |
UnitCartesian(double x,
double y,
double z,
double[] magnitude)
Initializes a set of
UnitCartesian coordinates from the provided values. |
UnitCartesian(UnitRectangular unit)
Initializes a set of
UnitCartesian coordinates from the provided set of UnitRectangular coordinates. |
UnitCartesian(UnitSpherical unitSpherical)
Initializes a set of
UnitCartesian coordinates from the provided set of
UnitSpherical 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,
UnitCartesian right)
Adds a specified set of
UnitCartesian coordinates to a specified set of Cartesian coordinates. |
Cartesian |
add(UnitCartesian other)
Adds the specified set of
UnitCartesian coordinates to this instance. |
static Cartesian |
add(UnitCartesian left,
Cartesian right)
Adds a specified set of
Cartesian coordinates to a specified set of UnitCartesian coordinates. |
static Cartesian |
add(UnitCartesian left,
UnitCartesian right)
Adds a specified set of
UnitCartesian coordinates to another specified set of UnitCartesian coordinates. |
double |
angleBetween(UnitCartesian other)
Determines the angle in radians between the specified set of
UnitCartesian coordinates and this instance. |
static Motion2<UnitCartesian,Cartesian> |
convertMotion(Motion1<Cartesian> motion,
int order)
Converts the motion given in terms of a set of
Cartesian coordinates to motion
of the corresponding set of UnitCartesian coordinates. |
Cartesian |
cross(Cartesian other)
Forms the cross product of the specified set of
Cartesian coordinates with this instance. |
Cartesian |
cross(UnitCartesian other)
Forms the cross product of the specified set of
UnitCartesian coordinates with this instance. |
static Motion1<Double> |
dihedralAngle(Motion2<UnitCartesian,Cartesian> motFrom,
Motion2<UnitCartesian,Cartesian> motTo,
Motion2<UnitCartesian,Cartesian> motAxis,
int order)
Calculates the scalar dihedral angle (and derivatives) of the three given values with
Cartesian derivative information.
|
static double |
dihedralAngle(UnitCartesian cartFrom,
UnitCartesian cartTo,
UnitCartesian cartAxis)
Calculates the scalar dihedral angle of the three given values.
|
Cartesian |
divide(double scalar)
Divides this instance by a scalar.
|
static Cartesian |
divide(UnitCartesian left,
double right)
Divides a specified set of
UnitCartesian coordinates by a scalar. |
double |
dot(Cartesian other)
Forms the dot product of the specified set of
Cartesian coordinates with this instance. |
double |
dot(UnitCartesian other)
Forms the dot product of the specified set of
UnitCartesian coordinates with this instance. |
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
static boolean |
equals(UnitCartesian left,
UnitCartesian right)
Returns
true if the two instances are exactly equal. |
boolean |
equalsEpsilon(UnitCartesian 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(UnitCartesian other)
Indicates whether another instance of this type is exactly equal to this instance.
|
double |
get(int index)
|
boolean |
getIsUndefined()
Gets a value indicating whether any of the coordinates for this instance have the value
Double.NaN . |
int |
getLength()
Gets the number of elements in this set of coordinates.
|
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 UnitCartesian |
getUndefined()
Gets a set of
UnitCartesian coordinates with values of Double.NaN . |
static UnitCartesian |
getUnitX()
Gets a set of
UnitCartesian coordinates representing the x-axis. |
static UnitCartesian |
getUnitY()
Gets a set of
UnitCartesian coordinates representing the y-axis. |
static UnitCartesian |
getUnitZ()
Gets a set of
UnitCartesian coordinates representing the z-axis. |
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.
|
int |
hashCode()
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
UnitCartesian |
invert()
Inverts this instance.
|
Cartesian |
multiply(double scalar)
Multiplies this instance by a scalar.
|
static Cartesian |
multiply(double left,
UnitCartesian right)
Multiplies a scalar by a specified set of
UnitCartesian coordinates. |
static Cartesian |
multiply(UnitCartesian left,
double right)
Multiplies a specified set of
UnitCartesian coordinates by a scalar. |
static UnitCartesian |
negate(UnitCartesian coordinates)
Negates the specified
UnitCartesian , yielding a new UnitCartesian . |
static boolean |
notEquals(UnitCartesian left,
UnitCartesian right)
Returns
true if the two instances are not exactly equal. |
UnitCartesian |
rotate(ElementaryRotation rotation)
Produces a set of
UnitCartesian coordinates representing this instance, which results from rotating
the original axes used to represent this instance by the provided ElementaryRotation rotation. |
UnitCartesian |
rotate(Matrix3By3 rotation)
Produces a set of
UnitCartesian coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided Matrix3By3 rotation. |
UnitCartesian |
rotate(UnitQuaternion rotation)
Produces a set of
UnitCartesian 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,
UnitCartesian right)
Subtracts a specified set of
UnitCartesian coordinates from a specified set of Cartesian coordinates. |
Cartesian |
subtract(UnitCartesian other)
Subtracts the specified set of
UnitCartesian coordinates from this instance. |
static Cartesian |
subtract(UnitCartesian left,
Cartesian right)
Subtracts a specified set of
Cartesian coordinates from a specified set of UnitCartesian coordinates. |
static Cartesian |
subtract(UnitCartesian left,
UnitCartesian right)
Subtracts a specified set of
UnitCartesian coordinates from another specified set of UnitCartesian coordinates. |
String |
toString()
Returns the string representation of the value of this instance.
|
public UnitCartesian()
public UnitCartesian(double x, double y, double z)
UnitCartesian
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.ArithmeticException
- The magnitude of the provided coordinates must not be zero.NotFiniteNumberException
- The magnitude of the provided coordinates must not be infinite.public UnitCartesian(double x, double y, double z, @Nonnull double[] magnitude)
UnitCartesian
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.magnitude
- On input, an array with one element. On return, the array is populated with
the magnitude of the original set of coordinates.ArithmeticException
- The magnitude of the provided coordinates must not be zero.NotFiniteNumberException
- The magnitude of the provided coordinates must not be infinite.public UnitCartesian(@Nonnull Cartesian coordinates)
UnitCartesian
coordinates from the provided set of Cartesian
coordinates.coordinates
- The set of Cartesian
coordinates.ArithmeticException
- The magnitude of the provided coordinates must not be zero.NotFiniteNumberException
- The magnitude of the provided coordinates must not be infinite.public UnitCartesian(@Nonnull Cartesian coordinates, @Nonnull double[] magnitude)
UnitCartesian
coordinates from the provided set of Cartesian
coordinates.coordinates
- The set of Cartesian
coordinates.magnitude
- On input, an array with one element. On return, the array is populated with
the magnitude of the original set of coordinates.ArithmeticException
- The magnitude of the provided coordinates must not be zero.NotFiniteNumberException
- The magnitude of the provided coordinates must not be infinite.public UnitCartesian(double clock, double cone)
UnitCartesian
coordinates from the provided spherical coordinates.clock
- The angular coordinate lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.cone
- The angular coordinate measured from the positive z-axis and toward the negative z-axis.public UnitCartesian(@Nonnull UnitRectangular unit)
UnitCartesian
coordinates from the provided set of UnitRectangular
coordinates.unit
- The set of UnitRectangular
coordinates.public UnitCartesian(@Nonnull UnitSpherical unitSpherical)
UnitCartesian
coordinates from the provided set of
UnitSpherical
coordinates.unitSpherical
- The set of UnitSpherical
coordinates.public UnitCartesian(@Nonnull double[] elements)
UnitCartesian
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
.ArithmeticException
- The magnitude of the provided coordinates must not be zero.NotFiniteNumberException
- The magnitude of the provided coordinates must not be infinite.public UnitCartesian(@Nonnull double[] elements, int startIndex)
UnitCartesian
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 elements
is null
.ArgumentOutOfRangeException
- Thrown when an object of this type is constructed from an array with less than 3 elements
.ArithmeticException
- Thrown when the magnitude of the provided coordinates are zero.NotFiniteNumberException
- Thrown when the magnitude of the provided coordinates is infinite.@Nonnull public static UnitCartesian getUndefined()
UnitCartesian
coordinates with values of Double.NaN
.
Use IsUndefined
(get
) to test whether a UnitCartesian
instance
is undefined since it will return true
if any of the coordinate values
are Double.NaN
.
@Nonnull public static UnitCartesian getUnitX()
UnitCartesian
coordinates representing the x-axis.@Nonnull public static UnitCartesian getUnitY()
UnitCartesian
coordinates representing the y-axis.@Nonnull public static UnitCartesian getUnitZ()
UnitCartesian
coordinates representing the z-axis.@Nonnull public static Motion2<UnitCartesian,Cartesian> convertMotion(@Nonnull Motion1<Cartesian> motion, int order)
Cartesian
coordinates to motion
of the corresponding set of UnitCartesian
coordinates.motion
- The Cartesian motion.order
- The order of the highest derivative to convert.public final double getX()
public final double getY()
public final double getZ()
@Nonnull public final UnitCartesian invert()
UnitCartesian
coordinates that represents the inverse of this instance.@Nonnull public final Cartesian multiply(double scalar)
scalar
- The multiplier, or value by which to multiply this instance.Cartesian
coordinates that represents the result of the multiplication.@Nonnull public final Cartesian divide(double scalar)
scalar
- The divisor, or value by which 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 add(@Nonnull UnitCartesian other)
UnitCartesian
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 subtract(@Nonnull UnitCartesian other)
UnitCartesian
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.@Nonnull public final Cartesian cross(@Nonnull UnitCartesian other)
UnitCartesian
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.public final double dot(@Nonnull UnitCartesian other)
UnitCartesian
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 UnitCartesian left, double right)
UnitCartesian
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 UnitCartesian right)
UnitCartesian
coordinates.left
- The multiplicand, or value to be multiplied by right
.right
- The multiplier, or value which by which left
is to be multiplied.Cartesian
coordinates that represents the result of the multiplication.@Nonnull public static Cartesian divide(@Nonnull UnitCartesian left, double right)
UnitCartesian
coordinates by a scalar.left
- The dividend, or value to be divided by right
.right
- The divisor, or value by which left
is to be divided.Cartesian
coordinates that represents the result of the division.@Nonnull public static Cartesian add(@Nonnull UnitCartesian left, @Nonnull UnitCartesian right)
UnitCartesian
coordinates to another specified set of UnitCartesian
coordinates.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 add(@Nonnull UnitCartesian left, @Nonnull Cartesian right)
Cartesian
coordinates to a specified set of UnitCartesian
coordinates.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 add(@Nonnull Cartesian left, @Nonnull UnitCartesian right)
UnitCartesian
coordinates to a specified set of Cartesian
coordinates.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 UnitCartesian left, @Nonnull UnitCartesian right)
UnitCartesian
coordinates from another specified set of UnitCartesian
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 subtract(@Nonnull UnitCartesian left, @Nonnull Cartesian right)
Cartesian
coordinates from a specified set of UnitCartesian
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 subtract(@Nonnull Cartesian left, @Nonnull UnitCartesian right)
UnitCartesian
coordinates from a 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 UnitCartesian negate(@Nonnull UnitCartesian coordinates)
UnitCartesian
, yielding a new UnitCartesian
.coordinates
- The set of coordinates.UnitCartesian
.@Nonnull public final UnitCartesian rotate(@Nonnull ElementaryRotation rotation)
UnitCartesian
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".
rotation
- The ElementaryRotation
.UnitCartesian
coordinates which is the result of the rotation.UnsupportedCaseException
- Thrown if the Axis
(get
) property of rotation
is
not AxisIndicator.FIRST
, AxisIndicator.SECOND
, or
AxisIndicator.THIRD
.@Nonnull public final UnitCartesian rotate(@Nonnull Matrix3By3 rotation)
UnitCartesian
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".
rotation
- The Matrix3By3
rotation.UnitCartesian
coordinates which is the result of the rotation.@Nonnull public final UnitCartesian rotate(@Nonnull UnitQuaternion rotation)
UnitCartesian
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".
rotation
- The UnitQuaternion
rotation.UnitCartesian
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 UnitCartesian other)
equalsType
in interface IEquatable<UnitCartesian>
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 UnitCartesian other, double epsilon)
equalsEpsilon
in interface IEquatableEpsilon<UnitCartesian>
other
- The set of UnitCartesian
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 UnitCartesian left, @Nonnull UnitCartesian 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 UnitCartesian left, @Nonnull UnitCartesian 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 angleBetween(@Nonnull UnitCartesian other)
UnitCartesian
coordinates and this instance.other
- The set of UnitCartesian
coordinates to evaluate.double
that represents the angle in radians between the two instances.public static double dihedralAngle(@Nonnull UnitCartesian cartFrom, @Nonnull UnitCartesian cartTo, @Nonnull UnitCartesian cartAxis)
cartFrom
- Cartesian to measure the angle from.cartTo
- Cartesian to measure the angle to.cartAxis
- The axis about which to measure the angle.@Nonnull public static Motion1<Double> dihedralAngle(@Nonnull Motion2<UnitCartesian,Cartesian> motFrom, @Nonnull Motion2<UnitCartesian,Cartesian> motTo, @Nonnull Motion2<UnitCartesian,Cartesian> motAxis, int order)
motFrom
- Cartesian (with possible derivative data) to measure the angle from.motTo
- Cartesian (with possible derivative data) to measure the angle to.motAxis
- The axis about which to measure the angle (with possible derivative data).order
- The order of the desired response, from 0 to 2.Motion<double>
representing the ScalarDihedralAngle of the three given values, and (optionally) its 1st and 2nd derivatives.