public final class Rectangular extends Object implements IEquatable<Rectangular>, IEquatableEpsilon<Rectangular>, ImmutableValueType
The corresponding 3-dimensional coordinates are Cartesian
coordinates.
Constructor and Description |
---|
Rectangular()
Initializes a new instance.
|
Rectangular(double[] elements)
Initializes a set of
Rectangular coordinates from the first 2 consecutive elements in the provided array. |
Rectangular(double[] elements,
int startIndex)
Initializes a set of
Rectangular coordinates from 2 consecutive elements in the provided array. |
Rectangular(double x,
double y)
Initializes a set of
Rectangular coordinates from the provided values. |
Rectangular(Polar coordinates)
Initializes a set of
Rectangular coordinates from the provided set of Polar coordinates. |
Modifier and Type | Method and Description |
---|---|
Rectangular |
add(Rectangular other)
Adds the specified set of
Rectangular coordinates to this instance. |
static Rectangular |
add(Rectangular left,
Rectangular right)
Adds a specified set of
Rectangular coordinates to another specified set of Cartesian coordinates. |
double |
cross(Rectangular other)
Forms the cross product of the specified set of
Rectangular coordinates with this instance. |
Rectangular |
divide(double scalar)
Divides this instance by a scalar.
|
static Rectangular |
divide(Rectangular left,
double right)
Divides a specified set of
Rectangular coordinates by a scalar. |
double |
dot(Rectangular other)
Forms the dot product of the specified set of
Rectangular coordinates with this instance. |
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
static boolean |
equals(Rectangular left,
Rectangular right)
Returns
true if the two instances are exactly equal. |
boolean |
equalsEpsilon(Rectangular 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(Rectangular 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. |
static Rectangular |
getUndefined()
Gets a set of
Rectangular 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.
|
static Rectangular |
getZero()
Gets a set of
Rectangular 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.
|
Rectangular |
invert()
Inverts this instance.
|
Rectangular |
multiply(double scalar)
Multiplies this instance by a scalar.
|
static Rectangular |
multiply(double left,
Rectangular right)
Multiplies a scalar by a specified set of
Rectangular coordinates. |
static Rectangular |
multiply(Rectangular left,
double right)
Multiplies a specified set of
Rectangular coordinates by a scalar. |
static Rectangular |
negate(Rectangular coordinates)
Negates the specified set of
Rectangular coordinates, yielding a new set of Rectangular coordinates. |
UnitRectangular |
normalize()
Forms a set of
UnitRectangular coordinates from this instance. |
UnitRectangular |
normalize(double[] magnitude)
Forms a set of
UnitRectangular coordinates from this instance
and returns the Magnitude (get ) of the original instance in the provided parameter. |
static boolean |
notEquals(Rectangular left,
Rectangular right)
Returns
true if the two instances are not exactly equal. |
Rectangular |
rotate(double angle)
Produces a set of
Rectangular coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided angle. |
Rectangular |
subtract(Rectangular other)
Subtracts the specified set of
Rectangular coordinates from this instance. |
static Rectangular |
subtract(Rectangular left,
Rectangular right)
Subtracts a specified set of
Rectangular coordinates from another specified set of Rectangular coordinates. |
static Rectangular |
toRectangular(UnitRectangular coordinates)
Converts a set of
UnitRectangular coordinates to a set of Rectangular coordinates. |
String |
toString()
Returns the string representation of the value of this instance.
|
public Rectangular()
public Rectangular(double x, double y)
Rectangular
coordinates from the provided values.x
- The linear coordinate along the positive x-axis.y
- The linear coordinate along the positive y-axis.public Rectangular(@Nonnull Polar coordinates)
Rectangular
coordinates from the provided set of Polar
coordinates.coordinates
- The set of Polar
coordinates.public Rectangular(@Nonnull double[] elements)
Rectangular
coordinates from the first 2 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 2 elements
.public Rectangular(@Nonnull double[] elements, int startIndex)
Rectangular
coordinates from 2 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 2 elements
.@Nonnull public static Rectangular getZero()
Rectangular
coordinates with values of zero.@Nonnull public static Rectangular getUndefined()
Rectangular
coordinates with values of Double.NaN
.
Use IsUndefined
(get
) to test whether a Rectangular
instance
is undefined since it will return true
if any of the coordinate values
are Double.NaN
.
public final double getX()
public final double getY()
@Nonnull public final Rectangular invert()
Rectangular
coordinates that represents the inverse of this instance.@Nonnull public final Rectangular multiply(double scalar)
scalar
- The multiplier, or value which is to multiply this instance.Rectangular
coordinates that represents the result of the multiplication.@Nonnull public final Rectangular divide(double scalar)
scalar
- The divisor, or value which is to divide this instance.Rectangular
coordinates that represents the result of the division.@Nonnull public final Rectangular add(@Nonnull Rectangular other)
Rectangular
coordinates to this instance.other
- The addend, or value which is to be added to this instance.Rectangular
coordinates that represents the result of the addition.@Nonnull public final Rectangular subtract(@Nonnull Rectangular other)
Rectangular
coordinates from this instance.other
- The subtrahend, or value which is to be subtracted from this instance.Rectangular
coordinates that represents the result of the subtraction.public final double dot(@Nonnull Rectangular other)
Rectangular
coordinates with this instance.other
- The set of Rectangular
coordinates to dot with this instance.double
that represents the result of the product.public final double cross(@Nonnull Rectangular other)
Rectangular
coordinates with this instance.other
- The set of Rectangular
coordinates to cross with this instance.double
that represents the result of the product.@Nonnull public static Rectangular multiply(@Nonnull Rectangular left, double right)
Rectangular
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
.Rectangular
coordinates that represents the result of the multiplication.@Nonnull public static Rectangular multiply(double left, @Nonnull Rectangular right)
Rectangular
coordinates.left
- The multiplicand, or value which is to be multiplied by right
.right
- The multiplier, or value which is to multiply left
.Rectangular
coordinates that represents the result of the multiplication.@Nonnull public static Rectangular divide(@Nonnull Rectangular left, double right)
Rectangular
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
.Rectangular
coordinates that represents the result of the division.@Nonnull public static Rectangular add(@Nonnull Rectangular left, @Nonnull Rectangular right)
Rectangular
coordinates to another 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
.Rectangular
coordinates that represents the result of the addition.@Nonnull public static Rectangular subtract(@Nonnull Rectangular left, @Nonnull Rectangular right)
Rectangular
coordinates from another specified set of Rectangular
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
.Rectangular
coordinates that represents the result of the subtraction.@Nonnull public static Rectangular negate(@Nonnull Rectangular coordinates)
Rectangular
coordinates, yielding a new set of Rectangular
coordinates.coordinates
- The set of coordinates.Rectangular
coordinates.@Nonnull public final Rectangular rotate(double angle)
Rectangular
coordinates representing this instance which results from rotating
the original axes used to represent this instance by the provided angle.
This type of rotation is sometimes referred to as an "alias rotation".
angle
- The angle of rotation.Rectangular
coordinates which is the result of the rotation.public final int getLength()
public final double get(int index)
index
of 0 and 1 corresponding to the coordinates
X
(get
), and Y
(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 Rectangular other)
equalsType
in interface IEquatable<Rectangular>
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 Rectangular other, double epsilon)
equalsEpsilon
in interface IEquatableEpsilon<Rectangular>
other
- The set of Rectangular
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 Rectangular left, @Nonnull Rectangular 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 Rectangular left, @Nonnull Rectangular 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.public final boolean getIsUndefined()
Double.NaN
.@Nonnull public final UnitRectangular normalize()
UnitRectangular
coordinates from this instance.
The normalization of the rectilinear coordinate pair 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.
UnitRectangular
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 UnitRectangular normalize(@Nonnull double[] magnitude)
UnitRectangular
coordinates from this instance
and returns the Magnitude
(get
) of the original instance in the provided parameter.
The normalization of the rectilinear coordinate pair 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 Rectangular
coordinates.UnitRectangular
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 Rectangular toRectangular(@Nonnull UnitRectangular coordinates)
UnitRectangular
coordinates to a set of Rectangular
coordinates.coordinates
- The set of UnitRectangular
coordinates.Rectangular
coordinates.