Interface Vector2d
- All Known Subinterfaces:
- MVector2d
public interface Vector2d
Read-only interface for handling vectors in the XY-plane.
- Since:
- 9.10.2
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionReturns the sum of this vector and the given vector.doubleReturns the minimum angle between this vector and the given vector.static Vector2dcreate(double x, double y) Returns a 2-dimensional vector with the given component values.static Vector2dReturns a 2-dimensional vector with the X and Y values set to those of the given vector.doubleReturns the distance between this vector and the other vector in the XY-plane.doubledistanceSquared(Vector2d other) Returns the square of the distance between this vector and the other vector in the XY-plane.doubledotProduct(Vector2d vector) Returns the dot product between this vector and the given vector.booleanequalsWithTolerance(Vector2d other, double tolerance) Returns true if this vector is within distance of tolerance to other.doubleThis method retrieves the clockwise angle from the positive x-axis to the vector in radians.doubleReturns the length of this vector.doubleReturns the squared length of this vector.doublegetX()Returns the X component of this vector.doublegetY()Returns the Y component of this vector.interpolate(Vector2d vector, double alpha) Returns a vector that is the interpolation between this vector and the given vector so that the weight of the given vector is alpha (result is (1 - alpha) * this + alpha * vector).negate()Returns a negated copy of this vector.Returns a normalized copy of this vector.scale(double scalar) Returns a copy of this vector scaled by the given scalar.Returns the difference of this vector and the given vector.to2dVectors(List<? extends Vector3d> vectors) Returns the vectors in the given list projected to the XY-plane.Returns a new 3-dimensional vector with the X and Y components of this vector and the Z-component set to 0.
- 
Field Details- 
ZEROThe vector (0, 0).- Since:
- 9.10.2
 
- 
UNIT_XThe vector (1, 0).- Since:
- 9.10.2
 
- 
NEG_UNIT_XThe vector (-1, 0).- Since:
- 9.10.2
 
- 
UNIT_YThe vector (0, 1).- Since:
- 9.10.2
 
- 
NEG_UNIT_YThe vector (0, -1).- Since:
- 9.10.2
 
 
- 
- 
Method Details- 
createReturns a 2-dimensional vector with the given component values.- Parameters:
- x- the value of the X component
- y- the value of the Y component
- Returns:
- a 2-dimensional vector with the given component values
- Since:
- 9.10.2
 
- 
createReturns a 2-dimensional vector with the X and Y values set to those of the given vector.- Parameters:
- vec- the vector used for setting the values of the created vector
- Returns:
- a 2-dimensional vector with the values set to those of the given vector
- Since:
- 9.10.2
 
- 
to2dVectorsReturns the vectors in the given list projected to the XY-plane. The order of the vectors is preserved.- Parameters:
- vectors- vectors that are projected to the XY-plane
- Returns:
- the vectors in the given list projected to the XY-plane
- Since:
- 9.10.2
 
- 
subtractReturns the difference of this vector and the given vector.- Parameters:
- vector- the vector on the right side of the difference
- Returns:
- the difference of this vector and the given vector
- Since:
- 9.10.2
 
- 
addReturns the sum of this vector and the given vector.- Parameters:
- vector- the vector that is added to this to get the returned vector
- Returns:
- the sum of this vector and the given vector
- Since:
- 9.10.2
 
- 
angleReturns the minimum angle between this vector and the given vector.- Parameters:
- vector- the vector between which the angle is computed
- Returns:
- the angle between this vector and the given vector
- Since:
- 9.10.2
 
- 
dotProductReturns the dot product between this vector and the given vector.- Parameters:
- vector- the vector with which the dot product is computed
- Returns:
- the dot product between this vector and the given vector
- Since:
- 9.10.2
 
- 
equalsWithToleranceReturns true if this vector is within distance of tolerance to other.- Parameters:
- other- the point that is compared for near equality in the XY-plane
- tolerance- the allowed distance between this vector and other
- Returns:
- true if this vector is within tolerance of other in the XY-plane
- Since:
- 9.10.2
 
- 
distanceReturns the distance between this vector and the other vector in the XY-plane.- Parameters:
- other- the vector to which the distance is computed in the XY-plane.
- Returns:
- the distance between this vector and other in the XY-plane.
- Since:
- 9.10.2
 
- 
distanceSquaredReturns the square of the distance between this vector and the other vector in the XY-plane.- Parameters:
- other- the vector to which the squared distance is computed in the XY-plane.
- Returns:
- the square of the distance between this vector and other in the XY-plane.
- Since:
- 9.10.2
 
- 
getLengthdouble getLength()Returns the length of this vector.- Returns:
- the length of this vector
- Since:
- 9.10.2
 
- 
getLengthSquareddouble getLengthSquared()Returns the squared length of this vector.- Returns:
- the squared length of this vector
- Since:
- 9.10.2
 
- 
interpolateReturns a vector that is the interpolation between this vector and the given vector so that the weight of the given vector is alpha (result is (1 - alpha) * this + alpha * vector). Values of alpha smaller than 0 default to 0 and values greater than 1 default to 1.- Parameters:
- vector- the vector with which this is interpolated
- alpha- the interpolation factor
- Returns:
- a vector that is the interpolation between this vector and the given vector
- Since:
- 9.10.2
 
- 
negateMVector2d negate()Returns a negated copy of this vector.- Returns:
- a negated copy of this vector
- Since:
- 9.10.2
 
- 
normalizeMVector2d normalize()Returns a normalized copy of this vector.- Returns:
- a normalized copy of this vector
- Since:
- 9.10.2
 
- 
getXdouble getX()Returns the X component of this vector.- Returns:
- the X component of this
- Since:
- 9.10.2
 
- 
getYdouble getY()Returns the Y component of this vector.- Returns:
- the Y component of this
- Since:
- 9.10.2
 
- 
scaleReturns 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
 
- 
to3dVectorMVector3d to3dVector()Returns a new 3-dimensional vector with the X and Y components of this vector and the Z-component set to 0.- Returns:
- a new 3-dimensional vector with the X and Y components of this vector and the Z-component set to 0
- Since:
- 9.10.2
 
- 
getClockwiseAngledouble getClockwiseAngle()This method retrieves the clockwise angle from the positive x-axis to the vector in radians. It produces values in the half-open interval [0,2pi), where the positive x-axis has the value 0 and the vectors approaching the positive x-axis from the positive y-axis -side will have values close to 2pi. Zero vector will return the value 0.0.- Returns:
- the clockwise angle from the positive x-axis to the vector
- Since:
- 9.10.2
 
 
-