Class Vector<V extends Vector<V>>
java.lang.Object
dev.prozilla.pine.common.math.vector.Vector<V>
- Direct Known Subclasses:
VectorFloat
,VectorInt
Abstract class for vectors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract V
Adds another vector to this vector.abstract V
clone()
Returns a new object that is equal to this object.divide
(float scalar) Divides this vector by a scalar.boolean
abstract boolean
Checks if the given object is equal to this object.int
hashCode()
abstract float
length()
Calculates the length of this vector.Calculates a linear interpolation between this vector with another vector.negate()
Negates this vector.Normalizes this vector.protected static Float[]
parseToFloats
(String input) protected static Float[]
parseToFloats
(String input, int count) protected static Integer[]
parseToIntegers
(String input) protected static Integer[]
parseToIntegers
(String input, int count) protected static <T> T[]
parseToNumbers
(String input, Function<String, T> parser, Class<T> type) abstract V
scale
(float scalar) Scales this vector by a scalar.Subtracts another vector from this vector.abstract String
toString()
Converts this vector to a string representation.
-
Constructor Details
-
Vector
public Vector()
-
-
Method Details
-
length
public abstract float length()Calculates the length of this vector. -
normalize
Normalizes this vector.- Returns:
- Self.
-
add
Adds another vector to this vector.- Returns:
- Self
-
negate
Negates this vector.- Returns:
- Self
-
subtract
Subtracts another vector from this vector.- Returns:
- Self
-
scale
Scales this vector by a scalar.- Returns:
- Self
-
divide
Divides this vector by a scalar.- Returns:
- Self
-
lerp
Calculates a linear interpolation between this vector with another vector.- Parameters:
alpha
- The alpha value, in the range of0f
and1f
- Returns:
- Self
-
equals
-
hashCode
public int hashCode() -
equals
Description copied from interface:Cloneable
Checks if the given object is equal to this object. -
clone
Description copied from interface:Cloneable
Returns a new object that is equal to this object. -
toString
Converts this vector to a string representation. -
parseToNumbers
protected static <T> T[] parseToNumbers(String input, Function<String, T> parser, Class<T> type) throws InvalidStringException- Throws:
InvalidStringException
-
parseToFloats
protected static Float[] parseToFloats(String input, int count) throws InvalidStringException, InvalidArrayException -
parseToFloats
- Throws:
InvalidStringException
-
parseToIntegers
protected static Integer[] parseToIntegers(String input, int count) throws InvalidStringException, InvalidArrayException -
parseToIntegers
- Throws:
InvalidStringException
-