Top Description Fields Constructors Methods
org.apache.commons.math3.geometry.euclidean.threed

public Class Vector3D

extends Object
implements Serializable, Vector<Euclidean3D>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.geometry.Vector, org.apache.commons.math3.geometry.Point, java.io.Serializable
Imports
java.io.Serializable, java.text.NumberFormat, org.apache.commons.math3.exception.DimensionMismatchException, .MathArithmeticException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.geometry.Point, .Space, .Vector, org.apache.commons.math3.util.FastMath, .MathArrays, .MathUtils

This class implements vectors in a three-dimensional space.

Instance of this class are guaranteed to be immutable.

Since
1.2

Field Summary

Modifier and TypeField and Description
public static final Vector3D
MINUS_I

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

public static final Vector3D
MINUS_J

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

public static final Vector3D
MINUS_K

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

public static final Vector3D
NaN

A vector with all coordinates set to NaN.

public static final Vector3D
NEGATIVE_INFINITY

A vector with all coordinates set to negative infinity.

public static final Vector3D
PLUS_I

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

public static final Vector3D
PLUS_J

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

public static final Vector3D
PLUS_K

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

public static final Vector3D
POSITIVE_INFINITY

A vector with all coordinates set to positive infinity.

private static final long
serialVersionUID

Serializable version identifier.

private final double
x

Abscissa.

private final double
y

Ordinate.

private final double
z

Height.

public static final Vector3D
ZERO

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

Constructor Summary

AccessConstructor and Description
public
Vector3D(double
abscissa
x
,
double
ordinate
y
,
double
height
z
)

Simple constructor.

public
Vector3D(double[]
coordinates array
v
)

Simple constructor.

public
Vector3D(double
azimuth (α) around Z (0 is +X, π/2 is +Y, π is -X and 3π/2 is -Y)
alpha
,
double
elevation (δ) above (XY) plane, from -π/2 to +π/2
delta
)

Simple constructor.

public
Vector3D(double
scale factor
a
,
Vector3D
base (unscaled) vector
u
)

Multiplicative constructor Build a vector from another one and a scale factor.

public
Vector3D(double
first scale factor
a1
,
Vector3D
first base (unscaled) vector
u1
,
double
second scale factor
a2
,
Vector3D
second base (unscaled) vector
u2
)

Linear constructor Build a vector from two other ones and corresponding scale factors.

public
Vector3D(double
first scale factor
a1
,
Vector3D
first base (unscaled) vector
u1
,
double
second scale factor
a2
,
Vector3D
second base (unscaled) vector
u2
,
double
third scale factor
a3
,
Vector3D
third base (unscaled) vector
u3
)

Linear constructor Build a vector from three other ones and corresponding scale factors.

public
Vector3D(double
first scale factor
a1
,
Vector3D
first base (unscaled) vector
u1
,
double
second scale factor
a2
,
Vector3D
second base (unscaled) vector
u2
,
double
third scale factor
a3
,
Vector3D
third base (unscaled) vector
u3
,
double
fourth scale factor
a4
,
Vector3D
fourth base (unscaled) vector
u4
)

Linear constructor Build a vector from four other ones and corresponding scale factors.

Method Summary

Modifier and TypeMethod and Description
public Vector3D
add(final Vector<Euclidean3D>
vector to add
v
)

Implements org.apache.commons.math3.geometry.Vector.add.

Add a vector to the instance.

public Vector3D
add(double
scale factor to apply to v before adding it
factor
,
final Vector<Euclidean3D>
vector to add
v
)

Implements org.apache.commons.math3.geometry.Vector.add.

Add a scaled vector to the instance.

public static double

Returns:

angular separation between v1 and v2
angle
(Vector3D
first vector
v1
,
Vector3D
second vector
v2
)

Compute the angular separation between two vectors.

public Vector3D

Returns:

the cross product this ^ v as a new Vector3D
crossProduct
(final Vector<Euclidean3D>
other vector
v
)

Compute the cross-product of the instance with another vector.

public static Vector3D

Returns:

the cross product v1 ^ v2 as a new Vector
crossProduct
(final Vector3D
first vector
v1
,
final Vector3D
second vector
v2
)

Compute the cross-product of two vectors.

public double
distance(Vector<Euclidean3D>
second vector
v
)

Implements org.apache.commons.math3.geometry.Vector.distance.

Compute the distance between the instance and another vector according to the L2 norm.

public double
distance(Point<Euclidean3D>
second point
v
)

Implements org.apache.commons.math3.geometry.Point.distance.

Compute the distance between the instance and another point.

public static double

Returns:

the distance between v1 and v2 according to the L2 norm
distance
(Vector3D
first vector
v1
,
Vector3D
second vector
v2
)

Compute the distance between two vectors according to the L2 norm.

public double
distance1(Vector<Euclidean3D>
second vector
v
)

Implements org.apache.commons.math3.geometry.Vector.distance1.

Compute the distance between the instance and another vector according to the L1 norm.

public static double

Returns:

the distance between v1 and v2 according to the L1 norm
distance1
(Vector3D
first vector
v1
,
Vector3D
second vector
v2
)

Compute the distance between two vectors according to the L1 norm.

public double
distanceInf(Vector<Euclidean3D>
second vector
v
)

Implements org.apache.commons.math3.geometry.Vector.distanceInf.

Compute the distance between the instance and another vector according to the L∞ norm.

public static double

Returns:

the distance between v1 and v2 according to the L∞ norm
distanceInf
(Vector3D
first vector
v1
,
Vector3D
second vector
v2
)

Compute the distance between two vectors according to the L∞ norm.

public double
distanceSq(Vector<Euclidean3D>
second vector
v
)

Implements org.apache.commons.math3.geometry.Vector.distanceSq.

Compute the square of the distance between the instance and another vector.

public static double

Returns:

the square of the distance between v1 and v2
distanceSq
(Vector3D
first vector
v1
,
Vector3D
second vector
v2
)

Compute the square of the distance between two vectors.

public double
dotProduct(final Vector<Euclidean3D>
second vector
v
)

Implements org.apache.commons.math3.geometry.Vector.dotProduct.

Compute the dot-product of the instance and another vector.

public static double

Returns:

the dot product v1.v2
dotProduct
(Vector3D
first vector
v1
,
Vector3D
second vector
v2
)

Compute the dot-product of two vectors.

public boolean

Returns:

true if two 3D vector objects are equal, false if object is null, not an instance of Vector3D, or not equal to this Vector3D instance
equals
(Object
Object to test for equality to this
other
)

Overrides java.lang.Object.equals.

Test for the equality of two 3D vectors.

public double

Returns:

azimuth (α) of the vector, between -π and +π
getAlpha
()

Get the azimuth of the vector.

public double

Returns:

elevation (δ) of the vector, between -π/2 and +π/2
getDelta
()

Get the elevation of the vector.

public double
getNorm()

Implements org.apache.commons.math3.geometry.Vector.getNorm.

Get the L2 norm for the vector.

public double
getNorm1()

Implements org.apache.commons.math3.geometry.Vector.getNorm1.

Get the L1 norm for the vector.

public double
getNormInf()

Implements org.apache.commons.math3.geometry.Vector.getNormInf.

Get the L∞ norm for the vector.

public double
getNormSq()

Implements org.apache.commons.math3.geometry.Vector.getNormSq.

Get the square of the norm for the vector.

public Space
getSpace()

Implements org.apache.commons.math3.geometry.Point.getSpace.

Get the space to which the point belongs.

public double

Returns:

abscissa of the vector
getX
()

Get the abscissa of the vector.

public double

Returns:

ordinate of the vector
getY
()

Get the ordinate of the vector.

public double

Returns:

height of the vector
getZ
()

Get the height of the vector.

public Vector3D
getZero()

Implements org.apache.commons.math3.geometry.Vector.getZero.

Get the null vector of the vectorial space or origin point of the affine space.

public int

Returns:

a hash code value for this object
hashCode
()

Overrides java.lang.Object.hashCode.

Get a hashCode for the 3D vector.

public boolean
isInfinite()

Implements org.apache.commons.math3.geometry.Vector.isInfinite.

Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise

public boolean
isNaN()

Implements org.apache.commons.math3.geometry.Point.isNaN.

Returns true if any coordinate of this point is NaN; false otherwise

public Vector3D
negate()

Implements org.apache.commons.math3.geometry.Vector.negate.

Get the opposite of the instance.

public Vector3D
normalize()

Implements org.apache.commons.math3.geometry.Vector.normalize.

Get a normalized vector aligned with the instance.

public Vector3D

Returns:

a new normalized vector orthogonal to the instance
orthogonal
()

Get a vector orthogonal to the instance.

public Vector3D
scalarMultiply(double
scalar
a
)

Implements org.apache.commons.math3.geometry.Vector.scalarMultiply.

Multiply the instance by a scalar.

public Vector3D
subtract(final Vector<Euclidean3D>
vector to subtract
v
)

Implements org.apache.commons.math3.geometry.Vector.subtract.

Subtract a vector from the instance.

public Vector3D
subtract(final double
scale factor to apply to v before subtracting it
factor
,
final Vector<Euclidean3D>
vector to subtract
v
)

Implements org.apache.commons.math3.geometry.Vector.subtract.

Subtract a scaled vector from the instance.

public double[]

Returns:

vector coordinates
toArray
()

Get the vector coordinates as a dimension 3 array.

public String

Returns:

a string representation of this vector
toString
()

Overrides java.lang.Object.toString.

Get a string representation of this vector.

public String
toString(final NumberFormat
the custom format for components
format
)

Implements org.apache.commons.math3.geometry.Vector.toString.

Get a string representation of this vector.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

MINUS_Iback to summary
public static final Vector3D MINUS_I

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

MINUS_Jback to summary
public static final Vector3D MINUS_J

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

MINUS_Kback to summary
public static final Vector3D MINUS_K

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

NaNback to summary
public static final Vector3D NaN

A vector with all coordinates set to NaN.

NEGATIVE_INFINITYback to summary
public static final Vector3D NEGATIVE_INFINITY

A vector with all coordinates set to negative infinity.

PLUS_Iback to summary
public static final Vector3D PLUS_I

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

PLUS_Jback to summary
public static final Vector3D PLUS_J

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

PLUS_Kback to summary
public static final Vector3D PLUS_K

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

POSITIVE_INFINITYback to summary
public static final Vector3D POSITIVE_INFINITY

A vector with all coordinates set to positive infinity.

serialVersionUIDback to summary
private static final long serialVersionUID

Serializable version identifier.

xback to summary
private final double x

Abscissa.

yback to summary
private final double y

Ordinate.

zback to summary
private final double z

Height.

ZEROback to summary
public static final Vector3D ZERO

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

Constructor Detail

Vector3Dback to summary
public Vector3D(double x, double y, double z)

Simple constructor. Build a vector from its coordinates

Parameters
x:double

abscissa

y:double

ordinate

z:double

height

See Also
getX(), getY(), getZ()
Vector3Dback to summary
public Vector3D(double[] v) throws DimensionMismatchException

Simple constructor. Build a vector from its coordinates

Parameters
v:double[]

coordinates array

Exceptions
DimensionMismatchException:
if array does not have 3 elements
See Also
toArray()
Vector3Dback to summary
public Vector3D(double alpha, double delta)

Simple constructor. Build a vector from its azimuthal coordinates

Parameters
alpha:double

azimuth (α) around Z (0 is +X, π/2 is +Y, π is -X and 3π/2 is -Y)

delta:double

elevation (δ) above (XY) plane, from -π/2 to +π/2

See Also
getAlpha(), getDelta()
Vector3Dback to summary
public Vector3D(double a, Vector3D u)

Multiplicative constructor Build a vector from another one and a scale factor. The vector built will be a * u

Parameters
a:double

scale factor

u:Vector3D

base (unscaled) vector

Vector3Dback to summary
public Vector3D(double a1, Vector3D u1, double a2, 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
a1:double

first scale factor

u1:Vector3D

first base (unscaled) vector

a2:double

second scale factor

u2:Vector3D

second base (unscaled) vector

Vector3Dback to summary
public Vector3D(double a1, Vector3D u1, double a2, Vector3D u2, double a3, 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
a1:double

first scale factor

u1:Vector3D

first base (unscaled) vector

a2:double

second scale factor

u2:Vector3D

second base (unscaled) vector

a3:double

third scale factor

u3:Vector3D

third base (unscaled) vector

Vector3Dback to summary
public Vector3D(double a1, Vector3D u1, double a2, Vector3D u2, double a3, Vector3D u3, double a4, 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
a1:double

first scale factor

u1:Vector3D

first base (unscaled) vector

a2:double

second scale factor

u2:Vector3D

second base (unscaled) vector

a3:double

third scale factor

u3:Vector3D

third base (unscaled) vector

a4:double

fourth scale factor

u4:Vector3D

fourth base (unscaled) vector

Method Detail

addback to summary
public Vector3D add(final Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.add.

Doc from org.apache.commons.math3.geometry.Vector.add.

Add a vector to the instance.

Parameters
v:Vector<Euclidean3D>

vector to add

Returns:Vector3D

a new vector

addback to summary
public Vector3D add(double factor, final Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.add.

Doc from org.apache.commons.math3.geometry.Vector.add.

Add a scaled vector to the instance.

Parameters
factor:double

scale factor to apply to v before adding it

v:Vector<Euclidean3D>

vector to add

Returns:Vector3D

a new vector

angleback to summary
public static double angle(Vector3D v1, Vector3D v2) throws MathArithmeticException

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 allows to have a good accuracy in all cases, even for vectors very close to each other.

Parameters
v1:Vector3D

first vector

v2:Vector3D

second vector

Returns:double

angular separation between v1 and v2

Exceptions
MathArithmeticException:
if either vector has a null norm
crossProductback to summary
public Vector3D crossProduct(final Vector<Euclidean3D> v)

Compute the cross-product of the instance with another vector.

Parameters
v:Vector<Euclidean3D>

other vector

Returns:Vector3D

the cross product this ^ v as a new Vector3D

crossProductback to summary
public static Vector3D crossProduct(final Vector3D v1, final Vector3D v2)

Compute the cross-product of two vectors.

Parameters
v1:Vector3D

first vector

v2:Vector3D

second vector

Returns:Vector3D

the cross product v1 ^ v2 as a new Vector

distanceback to summary
public double distance(Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.distance.

Doc from org.apache.commons.math3.geometry.Vector.distance.

Compute the distance between the instance and another vector according to the L2 norm.

Calling this method is equivalent to calling: q.subtract(p).getNorm() except that no intermediate vector is built

Parameters
v:Vector<Euclidean3D>

second vector

Returns:double

the distance between the instance and p according to the L2 norm

distanceback to summary
public double distance(Point<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Point.distance.

Doc from org.apache.commons.math3.geometry.Point.distance.

Compute the distance between the instance and another point.

Parameters
v:Point<Euclidean3D>

second point

Returns:double

the distance between the instance and p

distanceback to summary
public static double distance(Vector3D v1, Vector3D v2)

Compute the distance between two vectors according to the L2 norm.

Calling this method is equivalent to calling: v1.subtract(v2).getNorm() except that no intermediate vector is built

Parameters
v1:Vector3D

first vector

v2:Vector3D

second vector

Returns:double

the distance between v1 and v2 according to the L2 norm

distance1back to summary
public double distance1(Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.distance1.

Doc from org.apache.commons.math3.geometry.Vector.distance1.

Compute the distance between the instance and another vector according to the L1 norm.

Calling this method is equivalent to calling: q.subtract(p).getNorm1() except that no intermediate vector is built

Parameters
v:Vector<Euclidean3D>

second vector

Returns:double

the distance between the instance and p according to the L1 norm

distance1back to summary
public static double distance1(Vector3D v1, Vector3D v2)

Compute the distance between two vectors according to the L1 norm.

Calling this method is equivalent to calling: v1.subtract(v2).getNorm1() except that no intermediate vector is built

Parameters
v1:Vector3D

first vector

v2:Vector3D

second vector

Returns:double

the distance between v1 and v2 according to the L1 norm

distanceInfback to summary
public double distanceInf(Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.distanceInf.

Doc from org.apache.commons.math3.geometry.Vector.distanceInf.

Compute the distance between the instance and another vector according to the L∞ norm.

Calling this method is equivalent to calling: q.subtract(p).getNormInf() except that no intermediate vector is built

Parameters
v:Vector<Euclidean3D>

second vector

Returns:double

the distance between the instance and p according to the L∞ norm

distanceInfback to summary
public static double distanceInf(Vector3D v1, Vector3D v2)

Compute the distance between two vectors according to the L∞ norm.

Calling this method is equivalent to calling: v1.subtract(v2).getNormInf() except that no intermediate vector is built

Parameters
v1:Vector3D

first vector

v2:Vector3D

second vector

Returns:double

the distance between v1 and v2 according to the L∞ norm

distanceSqback to summary
public double distanceSq(Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.distanceSq.

Doc from org.apache.commons.math3.geometry.Vector.distanceSq.

Compute the square of the distance between the instance and another vector.

Calling this method is equivalent to calling: q.subtract(p).getNormSq() except that no intermediate vector is built

Parameters
v:Vector<Euclidean3D>

second vector

Returns:double

the square of the distance between the instance and p

distanceSqback to summary
public static double distanceSq(Vector3D v1, Vector3D v2)

Compute the square of the distance between two vectors.

Calling this method is equivalent to calling: v1.subtract(v2).getNormSq() except that no intermediate vector is built

Parameters
v1:Vector3D

first vector

v2:Vector3D

second vector

Returns:double

the square of the distance between v1 and v2

dotProductback to summary
public double dotProduct(final Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.dotProduct.

Doc from org.apache.commons.math3.geometry.Vector.dotProduct.

Compute the dot-product of the instance and another vector.

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.

Parameters
v:Vector<Euclidean3D>

second vector

Returns:double

the dot product this.v

See Also
MathArrays#linearCombination(double, double, double, double, double, double)
dotProductback to summary
public static double dotProduct(Vector3D v1, Vector3D v2)

Compute the dot-product of two vectors.

Parameters
v1:Vector3D

first vector

v2:Vector3D

second vector

Returns:double

the dot product v1.v2

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Test for the equality of two 3D vectors.

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.

Parameters
other:Object

Object to test for equality to this

Returns:boolean

true if two 3D vector objects are equal, false if object is null, not an instance of Vector3D, or not equal to this Vector3D instance

Annotations
@Override
getAlphaback to summary
public double getAlpha()

Get the azimuth of the vector.

Returns:double

azimuth (α) of the vector, between -π and +π

See Also
Vector3D(double, double)
getDeltaback to summary
public double getDelta()

Get the elevation of the vector.

Returns:double

elevation (δ) of the vector, between -π/2 and +π/2

See Also
Vector3D(double, double)
getNormback to summary
public double getNorm()

Implements org.apache.commons.math3.geometry.Vector.getNorm.

Doc from org.apache.commons.math3.geometry.Vector.getNorm.

Get the L2 norm for the vector.

Returns:double

Euclidean norm for the vector

getNorm1back to summary
public double getNorm1()

Implements org.apache.commons.math3.geometry.Vector.getNorm1.

Doc from org.apache.commons.math3.geometry.Vector.getNorm1.

Get the L1 norm for the vector.

Returns:double

L1 norm for the vector

getNormInfback to summary
public double getNormInf()

Implements org.apache.commons.math3.geometry.Vector.getNormInf.

Doc from org.apache.commons.math3.geometry.Vector.getNormInf.

Get the L∞ norm for the vector.

Returns:double

L∞ norm for the vector

getNormSqback to summary
public double getNormSq()

Implements org.apache.commons.math3.geometry.Vector.getNormSq.

Doc from org.apache.commons.math3.geometry.Vector.getNormSq.

Get the square of the norm for the vector.

Returns:double

square of the Euclidean norm for the vector

getSpaceback to summary
public Space getSpace()

Implements org.apache.commons.math3.geometry.Point.getSpace.

Doc from org.apache.commons.math3.geometry.Point.getSpace.

Get the space to which the point belongs.

Returns:Space

containing space

getXback to summary
public double getX()

Get the abscissa of the vector.

Returns:double

abscissa of the vector

See Also
Vector3D(double, double, double)
getYback to summary
public double getY()

Get the ordinate of the vector.

Returns:double

ordinate of the vector

See Also
Vector3D(double, double, double)
getZback to summary
public double getZ()

Get the height of the vector.

Returns:double

height of the vector

See Also
Vector3D(double, double, double)
getZeroback to summary
public Vector3D getZero()

Implements org.apache.commons.math3.geometry.Vector.getZero.

Doc from org.apache.commons.math3.geometry.Vector.getZero.

Get the null vector of the vectorial space or origin point of the affine space.

Returns:Vector3D

null vector of the vectorial space or origin point of the affine space

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Get a hashCode for the 3D vector.

All NaN values have the same hash code.

Returns:int

a hash code value for this object

Annotations
@Override
isInfiniteback to summary
public boolean isInfinite()

Implements org.apache.commons.math3.geometry.Vector.isInfinite.

Doc from org.apache.commons.math3.geometry.Vector.isInfinite.

Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise

Returns:boolean

true if any coordinate of this vector is infinite and none are NaN; false otherwise

isNaNback to summary
public boolean isNaN()

Implements org.apache.commons.math3.geometry.Point.isNaN.

Doc from org.apache.commons.math3.geometry.Point.isNaN.

Returns true if any coordinate of this point is NaN; false otherwise

Returns:boolean

true if any coordinate of this point is NaN; false otherwise

negateback to summary
public Vector3D negate()

Implements org.apache.commons.math3.geometry.Vector.negate.

Doc from org.apache.commons.math3.geometry.Vector.negate.

Get the opposite of the instance.

Returns:Vector3D

a new vector which is opposite to the instance

normalizeback to summary
public Vector3D normalize() throws MathArithmeticException

Implements org.apache.commons.math3.geometry.Vector.normalize.

Doc from org.apache.commons.math3.geometry.Vector.normalize.

Get a normalized vector aligned with the instance.

Returns:Vector3D

a new normalized vector

Exceptions
MathArithmeticException:
if the norm is zero
orthogonalback to summary
public Vector3D orthogonal() throws MathArithmeticException

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 :


  Vector3D k = u.normalize();
  Vector3D i = k.orthogonal();
  Vector3D j = Vector3D.crossProduct(k, i);

Returns:Vector3D

a new normalized vector orthogonal to the instance

Exceptions
MathArithmeticException:
if the norm of the instance is null
scalarMultiplyback to summary
public Vector3D scalarMultiply(double a)

Implements org.apache.commons.math3.geometry.Vector.scalarMultiply.

Doc from org.apache.commons.math3.geometry.Vector.scalarMultiply.

Multiply the instance by a scalar.

Parameters
a:double

scalar

Returns:Vector3D

a new vector

subtractback to summary
public Vector3D subtract(final Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.subtract.

Doc from org.apache.commons.math3.geometry.Vector.subtract.

Subtract a vector from the instance.

Parameters
v:Vector<Euclidean3D>

vector to subtract

Returns:Vector3D

a new vector

subtractback to summary
public Vector3D subtract(final double factor, final Vector<Euclidean3D> v)

Implements org.apache.commons.math3.geometry.Vector.subtract.

Doc from org.apache.commons.math3.geometry.Vector.subtract.

Subtract a scaled vector from the instance.

Parameters
factor:double

scale factor to apply to v before subtracting it

v:Vector<Euclidean3D>

vector to subtract

Returns:Vector3D

a new vector

toArrayback to summary
public double[] toArray()

Get the vector coordinates as a dimension 3 array.

Returns:double[]

vector coordinates

See Also
Vector3D(double[])
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Get a string representation of this vector.

Returns:String

a string representation of this vector

Annotations
@Override
toStringback to summary
public String toString(final NumberFormat format)

Implements org.apache.commons.math3.geometry.Vector.toString.

Doc from org.apache.commons.math3.geometry.Vector.toString.

Get a string representation of this vector.

Parameters
format:NumberFormat

the custom format for components

Returns:String

a string representation of this vector