Tuple3DReadOnly
Vector3DBasics
Vector3D
, Vector3D32
public interface Vector3DReadOnly extends Tuple3DReadOnly
A 3D vector represents a physical quantity with a magnitude and a direction. For instance, it can be used to represent a 3D velocity, force, or translation from one 3D point to another.
Although a point and vector hold onto the same type of information, the distinction is made between them as they represent different geometry objects and are typically not handled the same way:
Modifier and Type | Method | Description |
---|---|---|
default double |
angle(Vector3DReadOnly other) |
Calculates and returns the angle in radians from this vector to
other . |
default double |
dot(Vector3DReadOnly other) |
Calculates and returns the value of the dot product of this vector with
other . |
default boolean |
geometricallyEquals(Vector3DReadOnly other,
double epsilon) |
Tests if
this and other represent the same vector 3D to an epsilon . |
default double |
length() |
Calculates and returns the magnitude of this vector.
|
default double |
lengthSquared() |
Calculates and returns the square of the magnitude of this vector.
|
containsNaN, epsilonEquals, equals, get, get, get, get, get, get, get, getElement, getElement32, getX, getX32, getY, getY32, getZ, getZ32
default double length()
length = √(x2 + y2 + z2)
default double lengthSquared()
length2 = x2 + y2 + z2
This method is usually preferred over length()
when calculation speed matters and
knowledge of the actual magnitude does not, i.e. when comparing several vectors by theirs
magnitude.
default double dot(Vector3DReadOnly other)
other
.
For instance, the dot product of two vectors p and q is defined as:
p . q = ∑i=1:3(pi * qi)
other
- the other vector used for the dot product. Not modified.default double angle(Vector3DReadOnly other)
other
.
The computed angle is in the range [0; pi].
other
- the other vector used to compute the angle. Not modified.other
.default boolean geometricallyEquals(Vector3DReadOnly other, double epsilon)
this
and other
represent the same vector 3D to an epsilon
.
Two vectors are considered geometrically equal if the length of their difference is less than
or equal to epsilon
.
Note that this.geometricallyEquals(other, epsilon) == true
does not necessarily imply
this.epsilonEquals(other, epsilon)
and vice versa.
other
- the other vector 3D to compare against this. Not modified.epsilon
- the maximum length of the difference vector can be for the two vectors to be
considered equal.true
if the two vectors represent the same geometry, false
otherwise.