Interface Vector3d
-
- All Known Subinterfaces:
MVector3d
public interface Vector3dRead-only interface for 3-dimensional vectors.- Since:
- 9.10.2
-
-
Field Summary
Fields Modifier and Type Field Description static Vector3dNEG_UNIT_XThe vector (-1, 0, 0).static Vector3dNEG_UNIT_YThe vector (0, -1, 0).static Vector3dNEG_UNIT_ZThe vector (0, 0, -1).static Vector3dUNIT_XThe vector (1, 0, 0).static Vector3dUNIT_YThe vector (0, 1, 0).static Vector3dUNIT_ZThe vector (0, 0, 1).static Vector3dZEROThe vector (0, 0, 0).
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description MVector3dadd(Vector3d vector)Returns the sum of this vector and the given vector.doubleangle(Vector3d vector)Returns the angle in radians between this vector and the given vector.static MVector3dcentroidOf(Collection<? extends Vector3d> vectors)Returns the centroid (the average vector) of the given collection of vectors.static Vector3dcreate(double x, double y, double z)Returns a new vector with the given component values.static Vector3dcreate(Vector3d vector)Returns a new vector with the component values of the given vector.MVector3dcrossProduct(Vector3d vector)Returns the cross product of this vector and the given vector.doubledistance(Vector3d vector)Returns the distance between this vector and the given vector.doubledistanceSquared(Vector3d vector)Returns the squared distance between this vector and the given vector.doubledotProduct(Vector3d vector)Returns the dot product of this vector and the given vector.booleanequalsWithTolerance(Vector3d vector, double tolerance)Returns true if this vector is within tolerance of the given vector.doublegetLength()Returns the length of this vector.doublegetLengthSquared()Returns the squared length of this vector.doublegetX()Returns the X component of this vector.doublegetY()Returns the Y component of this vector.doublegetZ()Returns the Z component of this vector.MVector3dinterpolate(Vector3d vector, double alpha)Interpolates linearly between this vector and the given vector and returns the resulting vector.MVector3dnegate()Returns a negated copy of this vector.MVector3dnormalize()Returns a normalized copy of this vector.Optional<Vector3d>project(Vector3d vector)Returns an orthogonal projection of this vector on the given vector if it exists.MVector3dscale(double scalar)Returns a copy of this vector scaled by the given scalar.MVector3dsubtract(Vector3d vector)Returns the difference between this vector and the given vector.MVector2dto2dVector()Returns this vector projected onto the XY-plane.
-
-
-
Field Detail
-
ZERO
static final Vector3d ZERO
The vector (0, 0, 0).- Since:
- 9.10.2
-
UNIT_X
static final Vector3d UNIT_X
The vector (1, 0, 0).- Since:
- 9.10.2
-
NEG_UNIT_X
static final Vector3d NEG_UNIT_X
The vector (-1, 0, 0).- Since:
- 9.10.2
-
UNIT_Y
static final Vector3d UNIT_Y
The vector (0, 1, 0).- Since:
- 9.10.2
-
NEG_UNIT_Y
static final Vector3d NEG_UNIT_Y
The vector (0, -1, 0).- Since:
- 9.10.2
-
UNIT_Z
static final Vector3d UNIT_Z
The vector (0, 0, 1).- Since:
- 9.10.2
-
NEG_UNIT_Z
static final Vector3d NEG_UNIT_Z
The vector (0, 0, -1).- Since:
- 9.10.2
-
-
Method Detail
-
create
static Vector3d create(Vector3d vector)
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
static Vector3d create(double x, double y, double z)
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
static MVector3d centroidOf(Collection<? extends Vector3d> vectors)
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
double angle(Vector3d vector)
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
double distance(Vector3d vector)
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
double distanceSquared(Vector3d vector)
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
double dotProduct(Vector3d vector)
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
boolean equalsWithTolerance(Vector3d vector, double tolerance)
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
MVector3d crossProduct(Vector3d vector)
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
MVector3d subtract(Vector3d vector)
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
MVector3d scale(double scalar)
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
MVector3d add(Vector3d vector)
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
MVector3d interpolate(Vector3d vector, double alpha)
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
Optional<Vector3d> project(Vector3d vector)
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
-
-