Interface Vector3d
- All Known Subinterfaces:
MVector3d
public interface Vector3d
Read-only interface for 3-dimensional vectors.
- Since:
- 9.10.2
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Vector3d
The vector (-1, 0, 0).static final Vector3d
The vector (0, -1, 0).static final Vector3d
The vector (0, 0, -1).static final Vector3d
The vector (1, 0, 0).static final Vector3d
The vector (0, 1, 0).static final Vector3d
The vector (0, 0, 1).static final Vector3d
The vector (0, 0, 0). -
Method Summary
Modifier and TypeMethodDescriptionReturns the sum of this vector and the given vector.double
Returns the angle in radians between this vector and the given vector.static MVector3d
centroidOf
(Collection<? extends Vector3d> vectors) Returns the centroid (the average vector) of the given collection of vectors.static Vector3d
create
(double x, double y, double z) Returns a new vector with the given component values.static Vector3d
Returns a new vector with the component values of the given vector.crossProduct
(Vector3d vector) Returns the cross product of this vector and the given vector.double
Returns the distance between this vector and the given vector.double
distanceSquared
(Vector3d vector) Returns the squared distance between this vector and the given vector.double
dotProduct
(Vector3d vector) Returns the dot product of this vector and the given vector.boolean
equalsWithTolerance
(Vector3d vector, double tolerance) Returns true if this vector is within tolerance of the given vector.double
Returns the length of this vector.double
Returns the squared length of this vector.double
getX()
Returns the X component of this vector.double
getY()
Returns the Y component of this vector.double
getZ()
Returns the Z component of this vector.interpolate
(Vector3d vector, double alpha) Interpolates linearly between this vector and the given vector and returns the resulting vector.negate()
Returns a negated copy of this vector.Returns a normalized copy of this vector.Returns an orthogonal projection of this vector on the given vector if it exists.scale
(double scalar) Returns a copy of this vector scaled by the given scalar.Returns the difference between this vector and the given vector.Returns this vector projected onto the XY-plane.
-
Field Details
-
ZERO
The vector (0, 0, 0).- Since:
- 9.10.2
-
UNIT_X
The vector (1, 0, 0).- Since:
- 9.10.2
-
NEG_UNIT_X
The vector (-1, 0, 0).- Since:
- 9.10.2
-
UNIT_Y
The vector (0, 1, 0).- Since:
- 9.10.2
-
NEG_UNIT_Y
The vector (0, -1, 0).- Since:
- 9.10.2
-
UNIT_Z
The vector (0, 0, 1).- Since:
- 9.10.2
-
NEG_UNIT_Z
The vector (0, 0, -1).- Since:
- 9.10.2
-
-
Method Details
-
create
Returns a new vector with the component values of the given vector.- Parameters:
vector
- the vector whose component values are set to the new vector- Returns:
- a new vector with the component values of the given vector
- Since:
- 9.10.2
-
create
Returns a new vector with the given component values.- Parameters:
x
- the x component valuey
- the y component valuez
- the z component value- Returns:
- a new vector with the given component values
- Since:
- 9.10.2
-
centroidOf
Returns the centroid (the average vector) of the given collection of vectors.- Parameters:
vectors
- the vectors for which the centroid is computed- Returns:
- the centroid of the given collection of vectors
- Since:
- 9.10.2
-
angle
Returns the angle in radians between this vector and the given vector. The return value is constrained to the range [0,PI].- Parameters:
vector
- the vector to which the angle is computed- Returns:
- the the angle in radians between this vector and the given vector in the range [0,PI]
- Since:
- 9.10.2
-
distance
Returns the distance between this vector and the given vector.- Parameters:
vector
- the vector to which the distance is computed- Returns:
- the distance between this vector and the given vector
- Since:
- 9.10.2
-
distanceSquared
Returns the squared distance between this vector and the given vector.- Parameters:
vector
- the vector to which the squared distance is computed- Returns:
- the squared distance between this vector and the given vector
- Since:
- 9.10.2
-
dotProduct
Returns the dot product of this vector and the given vector.- Parameters:
vector
- the vector with which the dot product is computed- Returns:
- the dot product of this vector and the given vector
- Since:
- 9.10.2
-
equalsWithTolerance
Returns true if this vector is within tolerance of the given vector.- Parameters:
vector
- the vector with which this vector is compared for approximate equalitytolerance
- the allowed deviation between this vector and the given vector- Returns:
- true if this vector is within tolerance of the given vector
- Since:
- 9.10.2
-
getX
double getX()Returns the X component of this vector.- Returns:
- the X component of this
- Since:
- 9.10.2
-
getY
double getY()Returns the Y component of this vector.- Returns:
- the Y component of this
- Since:
- 9.10.2
-
getZ
double getZ()Returns the Z component of this vector.- Returns:
- the Z component of this
- Since:
- 9.10.2
-
getLengthSquared
double getLengthSquared()Returns the squared length of this vector.- Returns:
- the squared length of this vector
- Since:
- 9.10.2
-
getLength
double getLength()Returns the length of this vector.- Returns:
- the length of this vector
- Since:
- 9.10.2
-
crossProduct
Returns the cross product of this vector and the given vector.- Parameters:
vector
- the vector with which the cross product is computed- Returns:
- the cross product of this vector and the given vector
- Since:
- 9.10.2
-
subtract
Returns the difference between this vector and the given vector.- Parameters:
vector
- the vector on the right side of the difference- Returns:
- the difference between this vector and the given vector
- Since:
- 9.10.2
-
scale
Returns a copy of this vector scaled by the given scalar.- Parameters:
scalar
- the scalar by which the returned vector is scaled- Returns:
- a copy of this vector scaled by the given scalar
- Since:
- 9.10.2
-
add
Returns the sum of this vector and the given vector.- Parameters:
vector
- the vector that is added to this to create the returned vector- Returns:
- the sum of this vector and the given vector
- Since:
- 9.10.2
-
to2dVector
MVector2d to2dVector()Returns this vector projected onto the XY-plane.- Returns:
- this vector projected onto the XY-plane
- Since:
- 9.10.2
-
normalize
MVector3d normalize()Returns a normalized copy of this vector. If this vector is of zero length, then returns a vector with all components set to NaN.- Returns:
- a normalized copy of this vector
- Since:
- 9.10.2
-
negate
MVector3d negate()Returns a negated copy of this vector.- Returns:
- a negated copy of this vector
- Since:
- 9.10.2
-
interpolate
Interpolates linearly between this vector and the given vector and returns the resulting vector. If the alpha value is greater than 1 it is set to 1 and if the alpha value is smaller than 0 it is set to 0. Example: If this vector and the given vector represent two points, the result of the interpolation is a point on the segment from this point to the given point which divides the segment with a ratios alpha, (1 - alpha), respectively.- Parameters:
vector
- the vector with which this is interpolatedalpha
- the interpolation factor- Returns:
- a vector that is the interpolation between this vector and the given vector
- Since:
- 9.10.2
-
project
Returns an orthogonal projection of this vector on the given vector if it exists.- Parameters:
vector
- the vector onto which this vector is to be projected orthogonally- Returns:
- a vector that is the orthogonal projection of this vector onto the given vector; empty, if given vector is zero vector
- Since:
- 9.10.2
-