Serializable, Point<Euclidean3D>, Vector<Euclidean3D>public class Cartesian3D extends Vector3D implements Serializable, Point<Euclidean3D>
An instance of Cartesian3D represents the point with the corresponding coordinates.
An instance of Cartesian3D also represents the vector which begins at the origin and ends at the point corresponding to the coordinates.
Instance of this class are guaranteed to be immutable.
| Modifier and Type | Field | Description |
|---|---|---|
static Cartesian3D |
MINUS_I |
Opposite of the first canonical vector (coordinates: -1, 0, 0).
|
static Cartesian3D |
MINUS_J |
Opposite of the second canonical vector (coordinates: 0, -1, 0).
|
static Cartesian3D |
MINUS_K |
Opposite of the third canonical vector (coordinates: 0, 0, -1).
|
static Cartesian3D |
NaN |
A vector with all coordinates set to NaN.
|
static Cartesian3D |
NEGATIVE_INFINITY |
A vector with all coordinates set to negative infinity.
|
static Cartesian3D |
PLUS_I |
First canonical vector (coordinates: 1, 0, 0).
|
static Cartesian3D |
PLUS_J |
Second canonical vector (coordinates: 0, 1, 0).
|
static Cartesian3D |
PLUS_K |
Third canonical vector (coordinates: 0, 0, 1).
|
static Cartesian3D |
POSITIVE_INFINITY |
A vector with all coordinates set to positive infinity.
|
static Cartesian3D |
ZERO |
Null vector (coordinates: 0, 0, 0).
|
| Constructor | Description |
|---|---|
Cartesian3D(double[] v) |
Simple constructor.
|
Cartesian3D(double alpha,
double delta) |
Simple constructor.
|
Cartesian3D(double x,
double y,
double z) |
Simple constructor.
|
Cartesian3D(double a,
Cartesian3D u) |
Multiplicative constructor
Build a vector from another one and a scale factor.
|
Cartesian3D(double a1,
Cartesian3D u1,
double a2,
Cartesian3D u2) |
Linear constructor
Build a vector from two other ones and corresponding scale factors.
|
Cartesian3D(double a1,
Cartesian3D u1,
double a2,
Cartesian3D u2,
double a3,
Cartesian3D u3) |
Linear constructor
Build a vector from three other ones and corresponding scale factors.
|
Cartesian3D(double a1,
Cartesian3D u1,
double a2,
Cartesian3D u2,
double a3,
Cartesian3D u3,
double a4,
Cartesian3D u4) |
Linear constructor
Build a vector from four other ones and corresponding scale factors.
|
| Modifier and Type | Method | Description |
|---|---|---|
Cartesian3D |
add(double factor,
Vector<Euclidean3D> v) |
Add a scaled vector to the instance.
|
Cartesian3D |
add(Vector<Euclidean3D> v) |
Add a vector to the instance.
|
static double |
angle(Cartesian3D v1,
Cartesian3D v2) |
Compute the angular separation between two vectors.
|
static Cartesian3D |
crossProduct(Cartesian3D v1,
Cartesian3D v2) |
Compute the cross-product of two vectors.
|
Cartesian3D |
crossProduct(Vector<Euclidean3D> v) |
Compute the cross-product of the instance with another vector.
|
double |
distance(Cartesian3D c) |
Compute the distance between the instance and other coordinates.
|
static double |
distance(Cartesian3D v1,
Cartesian3D v2) |
Compute the distance between two vectors according to the L2 norm.
|
double |
distance(Point<Euclidean3D> p) |
Compute the distance between the instance and another point.
|
double |
distance(Vector<Euclidean3D> v) |
Compute the distance between the instance and another vector.
|
static double |
distance1(Cartesian3D v1,
Cartesian3D v2) |
Compute the distance between two vectors according to the L1 norm.
|
double |
distance1(Vector<Euclidean3D> v) |
Compute the distance between the instance and another vector according to the L1 norm.
|
static double |
distanceInf(Cartesian3D v1,
Cartesian3D v2) |
Compute the distance between two vectors according to the L∞ norm.
|
double |
distanceInf(Vector<Euclidean3D> v) |
Compute the distance between the instance and another vector according to the L∞ norm.
|
static double |
distanceSq(Cartesian3D v1,
Cartesian3D v2) |
Compute the square of the distance between two vectors.
|
double |
distanceSq(Vector<Euclidean3D> v) |
Compute the square of the distance between the instance and another vector.
|
static double |
dotProduct(Cartesian3D v1,
Cartesian3D v2) |
Compute the dot-product of two vectors.
|
double |
dotProduct(Vector<Euclidean3D> v) |
Compute the dot-product of the instance and another vector.
|
boolean |
equals(Object other) |
Test for the equality of two 3D vectors.
|
double |
getAlpha() |
Get the azimuth of the vector.
|
double |
getDelta() |
Get the elevation of the vector.
|
double |
getNorm() |
Get the L2 norm for the vector.
|
double |
getNorm1() |
Get the L1 norm for the vector.
|
double |
getNormInf() |
Get the L∞ norm for the vector.
|
double |
getNormSq() |
Get the square of the norm for the vector.
|
Space |
getSpace() |
Get the space to which the point belongs.
|
double |
getX() |
Get the abscissa of the vector.
|
double |
getY() |
Get the ordinate of the vector.
|
double |
getZ() |
Get the height of the vector.
|
Cartesian3D |
getZero() |
Get the null vector of the vectorial space or origin point of the affine space.
|
int |
hashCode() |
Get a hashCode for the 3D vector.
|
boolean |
isInfinite() |
Returns true if any coordinate of this vector is infinite and none are NaN;
false otherwise
|
boolean |
isNaN() |
Returns true if any coordinate of this point is NaN; false otherwise
|
Cartesian3D |
negate() |
Get the opposite of the instance.
|
Cartesian3D |
normalize() |
Get a normalized vector aligned with the instance.
|
Cartesian3D |
orthogonal() |
Get a vector orthogonal to the instance.
|
Cartesian3D |
scalarMultiply(double a) |
Multiply the instance by a scalar.
|
Cartesian3D |
subtract(double factor,
Vector<Euclidean3D> v) |
Subtract a scaled vector from the instance.
|
Cartesian3D |
subtract(Vector<Euclidean3D> v) |
Subtract a vector from the instance.
|
double[] |
toArray() |
Get the vector coordinates as a dimension 3 array.
|
String |
toString() |
Get a string representation of this vector.
|
String |
toString(NumberFormat format) |
Get a string representation of this vector.
|
public static final Cartesian3D ZERO
public static final Cartesian3D PLUS_I
public static final Cartesian3D MINUS_I
public static final Cartesian3D PLUS_J
public static final Cartesian3D MINUS_J
public static final Cartesian3D PLUS_K
public static final Cartesian3D MINUS_K
public static final Cartesian3D NaN
public static final Cartesian3D POSITIVE_INFINITY
public static final Cartesian3D NEGATIVE_INFINITY
public Cartesian3D(double x,
double y,
double z)
public Cartesian3D(double[] v)
throws DimensionMismatchException
v - coordinates arrayDimensionMismatchException - if array does not have 3 elementstoArray()public Cartesian3D(double alpha,
double delta)
alpha - azimuth (α) around Z
(0 is +X, π/2 is +Y, π is -X and 3π/2 is -Y)delta - elevation (δ) above (XY) plane, from -π/2 to +π/2getAlpha(),
getDelta()public Cartesian3D(double a,
Cartesian3D u)
a - scale factoru - base (unscaled) vectorpublic Cartesian3D(double a1,
Cartesian3D u1,
double a2,
Cartesian3D u2)
a1 - first scale factoru1 - first base (unscaled) vectora2 - second scale factoru2 - second base (unscaled) vectorpublic Cartesian3D(double a1,
Cartesian3D u1,
double a2,
Cartesian3D u2,
double a3,
Cartesian3D u3)
a1 - first scale factoru1 - first base (unscaled) vectora2 - second scale factoru2 - second base (unscaled) vectora3 - third scale factoru3 - third base (unscaled) vectorpublic Cartesian3D(double a1,
Cartesian3D u1,
double a2,
Cartesian3D u2,
double a3,
Cartesian3D u3,
double a4,
Cartesian3D u4)
a1 - first scale factoru1 - first base (unscaled) vectora2 - second scale factoru2 - second base (unscaled) vectora3 - third scale factoru3 - third base (unscaled) vectora4 - fourth scale factoru4 - fourth base (unscaled) vectorpublic double getX()
getX in class Vector3DCartesian3D(double, double, double)public double getY()
getY in class Vector3DCartesian3D(double, double, double)public double getZ()
getZ in class Vector3DCartesian3D(double, double, double)public double[] toArray()
Cartesian3D(double[])public Space getSpace()
getSpace in interface Point<Euclidean3D>getSpace in interface Vector<Euclidean3D>public Cartesian3D getZero()
getZero in interface Vector<Euclidean3D>public double getNorm1()
getNorm1 in interface Vector<Euclidean3D>public double getNorm()
getNorm in interface Vector<Euclidean3D>public double getNormSq()
getNormSq in interface Vector<Euclidean3D>public double getNormInf()
getNormInf in interface Vector<Euclidean3D>public double getAlpha()
Cartesian3D(double, double)public double getDelta()
Cartesian3D(double, double)public Cartesian3D add(Vector<Euclidean3D> v)
add in interface Vector<Euclidean3D>v - vector to addpublic Cartesian3D add(double factor, Vector<Euclidean3D> v)
add in interface Vector<Euclidean3D>factor - scale factor to apply to v before adding itv - vector to addpublic Cartesian3D subtract(Vector<Euclidean3D> v)
subtract in interface Vector<Euclidean3D>v - vector to subtractpublic Cartesian3D subtract(double factor, Vector<Euclidean3D> v)
subtract in interface Vector<Euclidean3D>factor - scale factor to apply to v before subtracting itv - vector to subtractpublic Cartesian3D normalize() throws MathArithmeticException
normalize in interface Vector<Euclidean3D>MathArithmeticException - if the norm is zeropublic Cartesian3D orthogonal() throws MathArithmeticException
There are an infinite number of normalized vectors orthogonal to the instance. This method picks up one of them almost arbitrarily. It is useful when one needs to compute a reference frame with one of the axes in a predefined direction. The following example shows how to build a frame having the k axis aligned with the known vector u :
Cartesian3D k = u.normalize();
Cartesian3D i = k.orthogonal();
Cartesian3D j = Cartesian3D.crossProduct(k, i);
MathArithmeticException - if the norm of the instance is nullpublic static double angle(Cartesian3D v1, Cartesian3D v2) throws MathArithmeticException
This method computes the angular separation between two vectors using the dot product for well separated vectors and the cross product for almost aligned vectors. This allows to have a good accuracy in all cases, even for vectors very close to each other.
v1 - first vectorv2 - second vectorMathArithmeticException - if either vector has a null normpublic Cartesian3D negate()
negate in interface Vector<Euclidean3D>public Cartesian3D scalarMultiply(double a)
scalarMultiply in interface Vector<Euclidean3D>a - scalarpublic boolean isNaN()
isNaN in interface Point<Euclidean3D>isNaN in interface Vector<Euclidean3D>public boolean isInfinite()
isInfinite in interface Vector<Euclidean3D>public boolean equals(Object other)
If all coordinates of two 3D vectors are exactly the same, and none are
Double.NaN, the two 3D vectors are considered to be equal.
NaN coordinates are considered to affect globally the vector
and be equals to each other - i.e, if either (or all) coordinates of the
3D vector are equal to Double.NaN, the 3D vector is equal to
NaN.
public int hashCode()
All NaN values have the same hash code.
public double dotProduct(Vector<Euclidean3D> v)
The implementation uses specific multiplication and addition algorithms to preserve accuracy and reduce cancellation effects. It should be very accurate even for nearly orthogonal vectors.
dotProduct in interface Vector<Euclidean3D>v - second vectorLinearCombination.value(double, double, double, double, double, double)public Cartesian3D crossProduct(Vector<Euclidean3D> v)
v - other vectorpublic double distance1(Vector<Euclidean3D> v)
Calling this method is equivalent to calling:
q.subtract(p).getNorm1() except that no intermediate
vector is built
distance1 in interface Vector<Euclidean3D>v - second vectorpublic double distance(Point<Euclidean3D> p)
distance in interface Point<Euclidean3D>p - second pointpublic double distance(Vector<Euclidean3D> v)
distance in interface Vector<Euclidean3D>v - second vectorpublic double distance(Cartesian3D c)
c - other coordinatespublic double distanceInf(Vector<Euclidean3D> v)
Calling this method is equivalent to calling:
q.subtract(p).getNormInf() except that no intermediate
vector is built
distanceInf in interface Vector<Euclidean3D>v - second vectorpublic double distanceSq(Vector<Euclidean3D> v)
Calling this method is equivalent to calling:
q.subtract(p).getNormSq() except that no intermediate
vector is built
distanceSq in interface Vector<Euclidean3D>v - second vectorpublic static double dotProduct(Cartesian3D v1, Cartesian3D v2)
v1 - first vectorv2 - second vectorpublic static Cartesian3D crossProduct(Cartesian3D v1, Cartesian3D v2)
v1 - first vectorv2 - second vectorpublic static double distance1(Cartesian3D v1, Cartesian3D v2)
Calling this method is equivalent to calling:
v1.subtract(v2).getNorm1() except that no intermediate
vector is built
v1 - first vectorv2 - second vectorpublic static double distance(Cartesian3D v1, Cartesian3D v2)
Calling this method is equivalent to calling:
v1.subtract(v2).getNorm() except that no intermediate
vector is built
v1 - first vectorv2 - second vectorpublic static double distanceInf(Cartesian3D v1, Cartesian3D v2)
Calling this method is equivalent to calling:
v1.subtract(v2).getNormInf() except that no intermediate
vector is built
v1 - first vectorv2 - second vectorpublic static double distanceSq(Cartesian3D v1, Cartesian3D v2)
Calling this method is equivalent to calling:
v1.subtract(v2).getNormSq() except that no intermediate
vector is built
v1 - first vectorv2 - second vectorpublic String toString()
public String toString(NumberFormat format)
toString in interface Vector<Euclidean3D>format - the custom format for componentsCopyright © 2003–2017 The Apache Software Foundation. All rights reserved.