Class Vector3D.Unit
java.lang.Object
org.apache.commons.geometry.euclidean.EuclideanVector<Vector3D>
org.apache.commons.geometry.euclidean.MultiDimensionalEuclideanVector<Vector3D>
org.apache.commons.geometry.euclidean.threed.Vector3D
org.apache.commons.geometry.euclidean.threed.Vector3D.Unit
- Enclosing class:
Vector3D
Represents unit vectors.
This allows optimizations for certain operations.
-
Nested Class Summary
Nested classes/interfaces inherited from class Vector3D
Vector3D.Sum, Vector3D.Unit -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Vector3D.UnitNegation of unit vector (coordinates: -1, 0, 0).static final Vector3D.UnitNegation of unit vector (coordinates: 0, -1, 0).static final Vector3D.UnitNegation of unit vector (coordinates: 0, 0, -1).static final Vector3D.UnitUnit vector (coordinates: 1, 0, 0).static final Vector3D.UnitUnit vector (coordinates: 0, 1, 0).static final Vector3D.UnitUnit vector (coordinates: 0, 0, 1).Fields inherited from class Vector3D
COORDINATE_ASCENDING_ORDER, NaN, NEGATIVE_INFINITY, POSITIVE_INFINITY, ZERO -
Method Summary
Modifier and TypeMethodDescriptionstatic Vector3D.Unitfrom(double x, double y, double z) Create a normalized vector.static Vector3D.UnitCreate a normalized vector.negate()Get the negation of the instance.doublenorm()Get the L2 norm (commonly known as the Euclidean norm) for the vector.Get a normalized vector aligned with the instance.Attempt to compute a normalized vector aligned with the instance, returning null if such a vector cannot be computed.doublenormSq()Get the square of the L2 norm (also known as the Euclidean norm) for the vector.withNorm(double mag) Returns a vector with the same direction but with the given norm.Methods inherited from class Vector3D
add, add, angle, centroid, centroid, cross, directionTo, distance, distanceSq, dot, eq, equals, getDimension, getX, getY, getZ, getZero, hashCode, isFinite, isInfinite, isNaN, lerp, max, max, min, min, multiply, of, of, orthogonal, orthogonal, parse, project, reject, subtract, subtract, toArray, toString, transform, vectorToMethods inherited from class EuclideanVector
getCheckedNorm, isZero
-
Field Details
-
PLUS_X
Unit vector (coordinates: 1, 0, 0). -
MINUS_X
Negation of unit vector (coordinates: -1, 0, 0). -
PLUS_Y
Unit vector (coordinates: 0, 1, 0). -
MINUS_Y
Negation of unit vector (coordinates: 0, -1, 0). -
PLUS_Z
Unit vector (coordinates: 0, 0, 1). -
MINUS_Z
Negation of unit vector (coordinates: 0, 0, -1).
-
-
Method Details
-
norm
Get the L2 norm (commonly known as the Euclidean norm) for the vector. This corresponds to the common notion of vector magnitude or length and is defined as the square root of the sum of the squares of all vector components. -
normSq
Get the square of the L2 norm (also known as the Euclidean norm) for the vector. This is equal to the sum of the squares of all vector components. -
normalize
-
normalizeOrNull
Attempt to compute a normalized vector aligned with the instance, returning null if such a vector cannot be computed. This method is equivalent toVector.normalize()but returns null instead of throwing an exception on failure.- Specified by:
normalizeOrNullin interfaceVector<Vector3D>- Overrides:
normalizeOrNullin classVector3D- Returns:
- normalized vector or null if such a vector cannot be computed, i.e. if the norm is zero, NaN, or infinite
- See Also:
-
withNorm
Returns a vector with the same direction but with the given norm. This is equivalent to callingvec.normalize().scalarMultiply(mag)but without the intermediate vector. -
negate
-
from
Create a normalized vector.- Parameters:
x- Vector coordinate.y- Vector coordinate.z- Vector coordinate.- Returns:
- a vector whose norm is 1.
- Throws:
IllegalArgumentException- if the norm of the given value is zero, NaN, or infinite
-
from
Create a normalized vector.- Parameters:
v- Vector.- Returns:
- a vector whose norm is 1.
- Throws:
IllegalArgumentException- if the norm of the given value is zero, NaN, or infinite
-