Package civitas.celestis.math.vector
Interface BigVector<N,D,V extends BigVector<N,D,V,DV,PV>,DV extends BigVector<D,D,DV,DV,? extends BaseTuple<?>>,PV extends BaseTuple<? extends Number>>
- Type Parameters:
N- The type of number to useD- The type of decimal number to useV- The vector itself (the parameter and result of various operations)DV- The type of decimal vector to use (the result of normalization)PV- The primitive vector of which this vector can be converted to
- All Superinterfaces:
BaseTuple<N>,Iterable<N>,Serializable,Tuple<N>
- All Known Subinterfaces:
DecimalVector<V,,PV> IntegerVector<V,DV, PV>
- All Known Implementing Classes:
Decimal2,Decimal3,Decimal4,DecimalQuaternion,Integer2,Integer3,Integer4
public interface BigVector<N,D,V extends BigVector<N,D,V,DV,PV>,DV extends BigVector<D,D,DV,DV,? extends BaseTuple<?>>,PV extends BaseTuple<? extends Number>>
extends Tuple<N>
A mathematical vector which uses an arbitrary numeric type
N.-
Method Summary
Modifier and TypeMethodDescriptionAdds a scalar to this vector component-wise, then returns the resulting vector.Adds another vector to this vector, then returns the resulting vector.Between this vector and the provided boundary vectorsminandmax, this returns a new vector whose components are clamped to respect the range of[min, max].Returns the Euclidean distance between this vector and the provided vectorv.Returns the squared Euclidean distance between this vector and the provided vectorv.Returns the Manhattan distance between this vector and the provided vectorv.Divides this vector by a scalar component-wise, then returns the resulting vector.Returns the dot product between this vector and the provided vectorv.booleanChecks for equality between this vector and the provided vectorv.Between this vector and the provided boundary vectorv, this takes the maximum of each corresponding pair of components, then returns a new vector whose components are populated from that of the maximum values between each pair of components.merge(V v, BinaryOperator<N> f) Between this vector and the provided vectorv, this applies the merger functionfto each corresponding pair of components, then returns a new vector whose components are populated from the return values of the functionf.Between this vector and the provided boundary vectorv, this takes the minimum of each corresponding pair of components, then returns a new vector whose components are populated from that of the minimum values between each pair of components.Multiplies this vector by a scalar component-wise, then returns the resulting vector.negate()Negates all components of this vector, then returns the resulting vector.norm()Returns the Euclidean norm (the magnitude) of this vector.norm2()Returns the squared Euclidean norm (the squared magnitude) of this vector.Normalizes this vector to have a Euclidean norm (magnitude) of1.Normalizes this vector to have a Euclidean norm (magnitude) of1.Normalizes this vector ot have a Euclidean norm (magnitude) of1.Returns the Manhattan norm of this vector.Converts this vector into a primitive vector.Subtracts this vector by a scalar component-wise, then returns the resulting vector.Subtracts another vector from this vector, then returns the resulting vector.transform(UnaryOperator<N> f) Applies the provided transformation functionfto each component of this vector, then returns a new vector containing the return values of the function f.Methods inherited from interface java.lang.Iterable
spliterator
-
Method Details
-
norm
Returns the Euclidean norm (the magnitude) of this vector.- Returns:
- The Euclidean norm of this vector
-
norm2
Returns the squared Euclidean norm (the squared magnitude) of this vector.- Returns:
- The squared Euclidean norm of this vector
-
normManhattan
Returns the Manhattan norm of this vector.- Returns:
- The Manhattan norm of this vector
-
add
Adds a scalar to this vector component-wise, then returns the resulting vector.- Parameters:
s- The scalar of which to add to each component of this vector- Returns:
- The resulting vector
-
subtract
Subtracts this vector by a scalar component-wise, then returns the resulting vector.- Parameters:
s- The scalar of which to subtract from each component of this vector- Returns:
- The resulting vector
-
multiply
Multiplies this vector by a scalar component-wise, then returns the resulting vector.- Parameters:
s- The scalar of which to multiply each component of this vector by- Returns:
- The resulting vector
-
divide
Divides this vector by a scalar component-wise, then returns the resulting vector.- Parameters:
s- The scalar of which to divide each component of this vector by- Returns:
- The resulting vector
- Throws:
ArithmeticException- When the denominatorsis zero
-
add
Adds another vector to this vector, then returns the resulting vector.- Parameters:
v- The vector of which to add to this vector- Returns:
- The resulting vector
-
subtract
Subtracts another vector from this vector, then returns the resulting vector.- Parameters:
v- The vector of which to subtract from this vector- Returns:
- The resulting vector
-
dot
Returns the dot product between this vector and the provided vectorv.- Parameters:
v- The vector of which to get the dot product between- Returns:
- The dot product between the two vectors
-
normalize
Normalizes this vector to have a Euclidean norm (magnitude) of1.- Returns:
- The normalized vector of this vector
- Throws:
ArithmeticException- When the Euclidean norm of this vector is zero
-
normalizeOrZero
Normalizes this vector ot have a Euclidean norm (magnitude) of1. If this vector's Euclidean norm is zero, this will return itself. (which is guaranteed to be a vector where all components are zero, as only zero vectors have a Euclidean norm of zero)- Returns:
- The normalized vector of this vector if successful, zero otherwise
-
normalizeOrDefault
Normalizes this vector to have a Euclidean norm (magnitude) of1. If this vector's Euclidean norm is zero, this will return the provided fallback valuev.- Parameters:
v- The value of which to return in case of division by zero- Returns:
- The normalized vector of this vector if successful, the fallback value
votherwise
-
negate
Negates all components of this vector, then returns the resulting vector.- Returns:
- The negation of this vector
-
min
Between this vector and the provided boundary vectorv, this takes the minimum of each corresponding pair of components, then returns a new vector whose components are populated from that of the minimum values between each pair of components.- Parameters:
v- The boundary vector of which to compare to- Returns:
- The minimum vector of the two vectors
-
max
Between this vector and the provided boundary vectorv, this takes the maximum of each corresponding pair of components, then returns a new vector whose components are populated from that of the maximum values between each pair of components.- Parameters:
v- The boundary vector of which to compare to- Returns:
- The maximum vector of the two vectors
-
clamp
Between this vector and the provided boundary vectorsminandmax, this returns a new vector whose components are clamped to respect the range of[min, max]. This is the equivalent of clamping each component to the corresponding pair of minimum and maximum values.- Parameters:
min- The minimum boundary vector to compare tomax- The maximum boundary vector to compare to- Returns:
- The clamped vector which respects the boundaries of
[min, max]
-
distance
Returns the Euclidean distance between this vector and the provided vectorv.- Parameters:
v- The vector of which get the Euclidean distance between- Returns:
- The Euclidean distance between the two vectors
-
distance2
Returns the squared Euclidean distance between this vector and the provided vectorv.- Parameters:
v- The vector of which to get the squared Euclidean distance between- Returns:
- The squared Euclidean distance between the two vectors
-
distanceManhattan
Returns the Manhattan distance between this vector and the provided vectorv.- Parameters:
v- The vector of which to get the Manhattan distance between- Returns:
- The Manhattan distance between the two vectors
-
transform
Applies the provided transformation functionfto each component of this vector, then returns a new vector containing the return values of the function f.- Parameters:
f- The function of which to apply to each component of this vector- Returns:
- The resulting vector
-
merge
Between this vector and the provided vectorv, this applies the merger functionfto each corresponding pair of components, then returns a new vector whose components are populated from the return values of the functionf.- Parameters:
v- The vector of which to merge this vector withf- The merger function to handle the merging of the two vectors- Returns:
- The resulting vector
-
primValue
Converts this vector into a primitive vector. Precision and/or scale may be lost.- Returns:
- The primitive representation of this vector
-
equals
Checks for equality between this vector and the provided vectorv.- Parameters:
v- The vector to compare to- Returns:
trueif the component values are equal
-