Shapes 3D  3.0
 All Classes Functions Variables Pages
shapes3d.org.apache.commons.math.geometry.Vector3D Class Reference
Inheritance diagram for shapes3d.org.apache.commons.math.geometry.Vector3D:

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)
 

Detailed Description

This class implements vectors in a three-dimensional space.

Instance of this class are guaranteed to be immutable.

Version
Revision:
627998

$Date: 2008-02-15 03:24:50 -0700 (Fri, 15 Feb 2008) $

Since
1.2

Constructor & Destructor Documentation

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 
)

Simple constructor. Build a vector from its coordinates

Parameters
xabscissa
yordinate
zheight
See Also
getX()
getY()
getZ()
shapes3d.org.apache.commons.math.geometry.Vector3D.Vector3D ( final double  alpha,
final double  delta 
)

Simple constructor. Build a vector from its azimuthal coordinates

Parameters
alphaazimuth (α) around Z (0 is +X, π/2 is +Y, π is -X and 3π/2 is -Y)
deltaelevation (δ) above (XY) plane, from -π/2 to +π/2
See Also
getAlpha()
getDelta()
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

Parameters
ascale factor
ubase (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

Parameters
a1first scale factor
u1first base (unscaled) vector
a2second scale factor
u2second 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

Parameters
a1first scale factor
u1first base (unscaled) vector
a2second scale factor
u2second base (unscaled) vector
a3third scale factor
u3third 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

  • u4
Parameters
a1first scale factor
u1first base (unscaled) vector
a2second scale factor
u2second base (unscaled) vector
a3third scale factor
u3third base (unscaled) vector
a4fourth scale factor
u4fourth base (unscaled) vector

Member Function Documentation

Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.add ( final Vector3D  v)

Add a vector to the instance.

Parameters
vvector to add
Returns
a new vector
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.add ( final double  factor,
final Vector3D  v 
)

Add a scaled vector to the instance.

Parameters
factorscale factor to apply to v before adding it
vvector to add
Returns
a new vector
static double shapes3d.org.apache.commons.math.geometry.Vector3D.angle ( final Vector3D  v1,
final Vector3D  v2 
)
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.

Parameters
v1first vector
v2second vector
Returns
angular separation between v1 and v2
Exceptions
ArithmeticExceptionif either vector has a null norm
static Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.crossProduct ( final Vector3D  v1,
final Vector3D  v2 
)
static

Compute the cross-product of two vectors.

Parameters
v1first vector
v2second vector
Returns
the cross product v1 ^ v2 as a new Vector
static double shapes3d.org.apache.commons.math.geometry.Vector3D.dotProduct ( final Vector3D  v1,
final Vector3D  v2 
)
static

Compute the dot-product of two vectors.

Parameters
v1first vector
v2second vector
Returns
the dot product v1.v2
double shapes3d.org.apache.commons.math.geometry.Vector3D.getAlpha ( )

Get the azimuth of the vector.

Returns
azimuth (α) of the vector, between -π and +π
See Also
#Vector3D(double, double)
double shapes3d.org.apache.commons.math.geometry.Vector3D.getDelta ( )

Get the elevation of the vector.

Returns
elevation (δ) of the vector, between -π/2 and +π/2
See Also
#Vector3D(double, double)
double shapes3d.org.apache.commons.math.geometry.Vector3D.getNorm ( )

Get the norm for the vector.

Returns
euclidian norm for the vector
double shapes3d.org.apache.commons.math.geometry.Vector3D.getX ( )

Get the abscissa of the vector.

Returns
abscissa of the vector
See Also
#Vector3D(double, double, double)
double shapes3d.org.apache.commons.math.geometry.Vector3D.getY ( )

Get the ordinate of the vector.

Returns
ordinate of the vector
See Also
#Vector3D(double, double, double)
double shapes3d.org.apache.commons.math.geometry.Vector3D.getZ ( )

Get the height of the vector.

Returns
height of the vector
See Also
#Vector3D(double, double, double)
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.negate ( )

Get the opposite of the instance.

Returns
a new vector which is opposite to the instance
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.normalize ( )

Get a normalized vector aligned with the instance.

Returns
a new normalized vector
Exceptions
ArithmeticExceptionif 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>
Returns
a new normalized vector orthogonal to the instance
Exceptions
ArithmeticExceptionif 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

Parameters
ascalar
Returns
a new vector
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.subtract ( final Vector3D  v)

Subtract a vector from the instance.

Parameters
vvector to subtract
Returns
a new vector
Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.subtract ( final double  factor,
final Vector3D  v 
)

Subtract a scaled vector from the instance.

Parameters
factorscale factor to apply to v before subtracting it
vvector to subtract
Returns
a new vector

Member Data Documentation

final Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.minusI = new Vector3D(-1, 0, 0)
static

Opposite of the first canonical vector (coordinates: -1, 0, 0).

final Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.minusJ = new Vector3D(0, -1, 0)
static

Opposite of the second canonical vector (coordinates: 0, -1, 0).

final Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.minusK = new Vector3D(0, 0, -1)
static

Opposite of the third canonical vector (coordinates: 0, 0, -1).

final Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.plusI = new Vector3D(1, 0, 0)
static

First canonical vector (coordinates: 1, 0, 0).

final Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.plusJ = new Vector3D(0, 1, 0)
static

Second canonical vector (coordinates: 0, 1, 0).

final Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.plusK = new Vector3D(0, 0, 1)
static

Third canonical vector (coordinates: 0, 0, 1).

final Vector3D shapes3d.org.apache.commons.math.geometry.Vector3D.zero = new Vector3D(0, 0, 0)
static

Null vector (coordinates: 0, 0, 0).


The documentation for this class was generated from the following file: