public final class Spherical extends Object implements IEquatable<Spherical>, IEquatableEpsilon<Spherical>, ImmutableValueType
Constructor and Description |
---|
Spherical()
Initializes a new instance.
|
Spherical(AzimuthElevationRange coordinates)
Initializes a set of
Spherical coordinates from the provided set of
AzimuthElevationRange coordinates. |
Spherical(Cartesian coordinates)
|
Spherical(Cylindrical coordinates)
Initializes a set of
Spherical coordinates from the provided set of Cylindrical coordinates. |
Spherical(double[] elements)
Initializes a set of
Spherical coordinates from the first 3 consecutive elements in the provided array. |
Spherical(double[] elements,
int startIndex)
Initializes a set of
Spherical coordinates from the provided array. |
Spherical(double clock,
double cone,
double magnitude)
Initializes a set of
Spherical coordinates from the provided clock angle, cone angle, and magnitude. |
Spherical(LongitudeLatitudeRadius coordinates)
Initializes a set of
Spherical coordinates from the provided set of
LongitudeLatitudeRadius coordinates. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
static boolean |
equals(Spherical left,
Spherical right)
Returns
true if the two instances are exactly equal. |
boolean |
equalsEpsilon(Spherical 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(Spherical other)
Indicates whether another instance of this type is exactly equal to this instance.
|
double |
get(int index)
|
double |
getClock()
Gets the angular coordinate lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
|
double |
getCone()
Gets the angular coordinate measured from the positive z-axis and toward the negative z-axis.
|
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.
|
double |
getMagnitude()
Gets the linear coordinate measured from the origin.
|
static Spherical |
getUndefined()
Gets a set of
Spherical coordinates with values of Double.NaN . |
static Spherical |
getZero()
Gets a set of
Spherical 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.
|
UnitSpherical |
normalize()
Forms a set of
UnitSpherical coordinates from this instance. |
static boolean |
notEquals(Spherical left,
Spherical right)
Returns
true if the two instances are not exactly equal. |
String |
toString()
Returns the string representation of the value of this instance.
|
public Spherical()
public Spherical(double clock, double cone, double magnitude)
Spherical
coordinates from the provided clock angle, cone angle, and magnitude.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.magnitude
- The linear coordinate measured from the origin.public Spherical(@Nonnull Cylindrical coordinates)
Spherical
coordinates from the provided set of Cylindrical
coordinates.coordinates
- The set of Cylindrical
coordinates.public Spherical(@Nonnull Cartesian coordinates)
Spherical
coordinates from the provided set of Cartesian
coordinates.
The radius and magnitude for spherical coordinates are computed using the standard methods. Note that if a component of the cartesian components underflows upon squaring the resulting spherical coordinates may not be correct.
coordinates
- The set of Cartesian coordinates.public Spherical(@Nonnull AzimuthElevationRange coordinates)
Spherical
coordinates from the provided set of
AzimuthElevationRange
coordinates.coordinates
- The set of AzimuthElevationRange
coordinates.public Spherical(@Nonnull LongitudeLatitudeRadius coordinates)
Spherical
coordinates from the provided set of
LongitudeLatitudeRadius
coordinates.coordinates
- The set of LongitudeLatitudeRadius
coordinates.public Spherical(@Nonnull double[] elements)
Spherical
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 Spherical(@Nonnull double[] elements, int startIndex)
Spherical
coordinates from 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
.@Nonnull public static Spherical getZero()
Spherical
coordinates with values of zero.@Nonnull public static Spherical getUndefined()
Spherical
coordinates with values of Double.NaN
.
Use IsUndefined
(get
) to test whether a Spherical
instance
is undefined since it will return true
if any of the coordinate values
are Double.NaN
.
public final double getClock()
public final double getCone()
public final double getMagnitude()
@Nonnull public final UnitSpherical normalize()
UnitSpherical
coordinates from this instance.UnitSpherical
coordinates.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
Clock
(get
), Cone
(get
), and Magnitude
(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 Spherical other)
equalsType
in interface IEquatable<Spherical>
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 Spherical other, double epsilon)
equalsEpsilon
in interface IEquatableEpsilon<Spherical>
other
- The set of Spherical
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 Spherical left, @Nonnull Spherical 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 Spherical left, @Nonnull Spherical 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
.