Interface Vector
-
-
Method Summary
Modifier and Type Method Description abstract S
fromCoordinates(DoubleArray coordinates)
Builds a new Vector from the provided coordinates. abstract Double
get(Integer dim)
The coordinate of this vector in the specified dimension relatively to the basis its space is described with. abstract S
plus(S other)
Support for sum. abstract S
minus(S other)
Support for subtraction. abstract S
times(Double other)
Multiplication by a Double. S
div(Double other)
Division by a Double. Double
dot(S other)
Computes the dot product between two vectors. Double
angleBetween(S other)
Computes the angle in radians between two vectors. abstract Double
distanceTo(S other)
Computes the distance between two vectors, interpreted as points in an Euclidean space. S
resized(Double newLen)
abstract S
normalized()
S
coerceAtMost(Double maximumMagnitude)
S
coerceAtLeast(Double minimumMagnitude)
S
coerceIn(Double minimumMagnitude, Double maximumMagnitude)
Performs a coercion at least and at most. abstract S
normal()
Find the normal of a vector. abstract Integer
getDimensions()
The dimensions of the space this vector belongs to. abstract DoubleArray
getCoordinates()
Coordinates for a Cartesian space. S
getZero()
Double
getMagnitude()
-
-
Method Detail
-
fromCoordinates
abstract S fromCoordinates(DoubleArray coordinates)
Builds a new Vector from the provided coordinates.
-
get
abstract Double get(Integer dim)
The coordinate of this vector in the specified dimension relatively to the basis its space is described with.
- Parameters:
dim
-the dimension. E.g., in a 2-dimensional implementation, 0 could be the X-axis and 1 the Y-axis
- Returns:
the coordinate value
-
plus
abstract S plus(S other)
Support for sum. Note: the dimensions must coincide.
- Returns:
a vector containing the result
-
minus
abstract S minus(S other)
Support for subtraction. Note: the dimensions must coincide.
- Returns:
a vector containing the result
-
times
abstract S times(Double other)
Multiplication by a Double.
- Returns:
the resulting vector, the operation is not performed in-place.
-
div
S div(Double other)
Division by a Double.
- Returns:
the resulting vector, the operation is not performed in-place.
-
angleBetween
Double angleBetween(S other)
Computes the angle in radians between two vectors.
-
distanceTo
abstract Double distanceTo(S other)
Computes the distance between two vectors, interpreted as points in an Euclidean space. Throws IllegalArgumentException if vectors have different dimensions.
-
resized
S resized(Double newLen)
- Returns:
a resized version of the vector, whose magnitude is equal to newLen. Direction and verse of the original vector are preserved.
-
normalized
abstract S normalized()
- Returns:
a normalized version of the vector (i.e. of unitary magnitude).
-
coerceAtMost
S coerceAtMost(Double maximumMagnitude)
- Returns:
this vector if its magnitude is smaller than or equal to maximumMagnitude or a resized version of maximumMagnitude otherwise.
-
coerceAtLeast
S coerceAtLeast(Double minimumMagnitude)
- Returns:
this vector if its magnitude is greater than or equal to minimumMagnitude or a resized version of minimumMagnitude otherwise.
-
coerceIn
S coerceIn(Double minimumMagnitude, Double maximumMagnitude)
Performs a coercion at least and at most.
-
getDimensions
abstract Integer getDimensions()
The dimensions of the space this vector belongs to.
-
getCoordinates
abstract DoubleArray getCoordinates()
Coordinates for a Cartesian space. Implementors must guarantee that internal state is not exposed.
-
getMagnitude
Double getMagnitude()
-
-
-
-