Shapes 3D
3.0
|
Public Member Functions | |
Vector3D () | |
Vector3D (final double x, final double y, final double z) | |
Vector3D (final double alpha, final double delta) | |
Vector3D (final double a, final Vector3D u) | |
Vector3D (final double a1, final Vector3D u1, final double a2, final Vector3D u2) | |
Vector3D (final double a1, final Vector3D u1, final double a2, final Vector3D u2, final double a3, final Vector3D u3) | |
Vector3D (final double a1, final Vector3D u1, final double a2, final Vector3D u2, final double a3, final Vector3D u3, final double a4, final Vector3D u4) | |
double | getX () |
double | getY () |
double | getZ () |
double | getNorm () |
double | getAlpha () |
double | getDelta () |
Vector3D | add (final Vector3D v) |
Vector3D | add (final double factor, final Vector3D v) |
Vector3D | subtract (final Vector3D v) |
Vector3D | subtract (final double factor, final Vector3D v) |
Vector3D | normalize () |
Vector3D | orthogonal () |
Vector3D | negate () |
Vector3D | scalarMultiply (final double a) |
Static Public Member Functions | |
static double | angle (final Vector3D v1, final Vector3D v2) |
static double | dotProduct (final Vector3D v1, final Vector3D v2) |
static Vector3D | crossProduct (final Vector3D v1, final Vector3D v2) |
Static Public Attributes | |
static final Vector3D | plusI = new Vector3D(1, 0, 0) |
static final Vector3D | minusI = new Vector3D(-1, 0, 0) |
static final Vector3D | plusJ = new Vector3D(0, 1, 0) |
static final Vector3D | minusJ = new Vector3D(0, -1, 0) |
static final Vector3D | plusK = new Vector3D(0, 0, 1) |
static final Vector3D | minusK = new Vector3D(0, 0, -1) |
static final Vector3D | zero = new Vector3D(0, 0, 0) |
This class implements vectors in a three-dimensional space.
Instance of this class are guaranteed to be immutable.
$Date: 2008-02-15 03:24:50 -0700 (Fri, 15 Feb 2008) $
shapes3d.org.apache.commons.math.geometry.Vector3D.Vector3D | ( | ) |
Simple constructor. Build a null vector.
shapes3d.org.apache.commons.math.geometry.Vector3D.Vector3D | ( | final double | x, |
final double | y, | ||
final double | z | ||
) |
shapes3d.org.apache.commons.math.geometry.Vector3D.Vector3D | ( | final double | alpha, |
final double | delta | ||
) |
Simple constructor. Build a vector from its azimuthal coordinates
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 +π/2 |
shapes3d.org.apache.commons.math.geometry.Vector3D.Vector3D | ( | final double | a, |
final Vector3D | u | ||
) |
Multiplicative constructor Build a vector from another one and a scale factor. The vector built will be a * u
a | scale factor |
u | base (unscaled) vector |
shapes3d.org.apache.commons.math.geometry.Vector3D.Vector3D | ( | final double | a1, |
final Vector3D | u1, | ||
final double | a2, | ||
final Vector3D | u2 | ||
) |
Linear constructor Build a vector from two other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2
a1 | first scale factor |
u1 | first base (unscaled) vector |
a2 | second scale factor |
u2 | second base (unscaled) vector |
shapes3d.org.apache.commons.math.geometry.Vector3D.Vector3D | ( | final double | a1, |
final Vector3D | u1, | ||
final double | a2, | ||
final Vector3D | u2, | ||
final double | a3, | ||
final Vector3D | u3 | ||
) |
Linear constructor Build a vector from three other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2 + a3 * u3
a1 | first scale factor |
u1 | first base (unscaled) vector |
a2 | second scale factor |
u2 | second base (unscaled) vector |
a3 | third scale factor |
u3 | third base (unscaled) vector |
shapes3d.org.apache.commons.math.geometry.Vector3D.Vector3D | ( | final double | a1, |
final Vector3D | u1, | ||
final double | a2, | ||
final Vector3D | u2, | ||
final double | a3, | ||
final Vector3D | u3, | ||
final double | a4, | ||
final Vector3D | u4 | ||
) |
Linear constructor Build a vector from four other ones and corresponding scale factors. The vector built will be a1 * u1 + a2 * u2 + a3 * u3 + a4
a1 | first scale factor |
u1 | first base (unscaled) vector |
a2 | second scale factor |
u2 | second base (unscaled) vector |
a3 | third scale factor |
u3 | third base (unscaled) vector |
a4 | fourth scale factor |
u4 | fourth base (unscaled) vector |
Add a vector to the instance.
v | vector to add |
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.add | ( | final double | factor, |
final Vector3D | v | ||
) |
Add a scaled vector to the instance.
factor | scale factor to apply to v before adding it |
v | vector to add |
|
static |
Compute the angular separation between two vectors.
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 allow to have a good accuracy in all cases, even for vectors very close to each other.
v1 | first vector |
v2 | second vector |
ArithmeticException | if either vector has a null norm |
|
static |
Compute the cross-product of two vectors.
v1 | first vector |
v2 | second vector |
|
static |
Compute the dot-product of two vectors.
v1 | first vector |
v2 | second vector |
double shapes3d.org.apache.commons.math.geometry.Vector3D.getAlpha | ( | ) |
Get the azimuth of the vector.
double shapes3d.org.apache.commons.math.geometry.Vector3D.getDelta | ( | ) |
Get the elevation of the vector.
double shapes3d.org.apache.commons.math.geometry.Vector3D.getNorm | ( | ) |
Get the norm for the vector.
double shapes3d.org.apache.commons.math.geometry.Vector3D.getX | ( | ) |
Get the abscissa of the vector.
double shapes3d.org.apache.commons.math.geometry.Vector3D.getY | ( | ) |
Get the ordinate of the vector.
double shapes3d.org.apache.commons.math.geometry.Vector3D.getZ | ( | ) |
Get the height of the vector.
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.negate | ( | ) |
Get the opposite of the instance.
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.normalize | ( | ) |
Get a normalized vector aligned with the instance.
ArithmeticException | if the norm is zero |
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.orthogonal | ( | ) |
Get a vector orthogonal to the instance.
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 :
<code> Vector3D k = u.normalize(); Vector3D i = k.orthogonal(); Vector3D j = Vector3D.crossProduct(k, i); </code>
ArithmeticException | if the norm of the instance is null |
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.scalarMultiply | ( | final double | a | ) |
Multiply the instance by a scalar
a | scalar |
Subtract a vector from the instance.
v | vector to subtract |
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.subtract | ( | final double | factor, |
final Vector3D | v | ||
) |
Subtract a scaled vector from the instance.
factor | scale factor to apply to v before subtracting it |
v | vector to subtract |
|
static |
Opposite of the first canonical vector (coordinates: -1, 0, 0).
|
static |
Opposite of the second canonical vector (coordinates: 0, -1, 0).
|
static |
Opposite of the third canonical vector (coordinates: 0, 0, -1).
|
static |
First canonical vector (coordinates: 1, 0, 0).
|
static |
Second canonical vector (coordinates: 0, 1, 0).
|
static |
Third canonical vector (coordinates: 0, 0, 1).
|
static |
Null vector (coordinates: 0, 0, 0).