Package me.autobot.lib.math.linalg
Class Vector
java.lang.Object
me.autobot.lib.math.linalg.Vector
Creates a new vector with the given values.
Not to be disturbed with Vector2d or Vector3d, as this is a general vector.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the given vector to this vector.double
get
(int index) Gets the value at the given index.double[]
Gets the values of the vector.void
set
(int index, double value) Sets the value at the given index.int
size()
Gets the size of the vector.Subtracts the given matrix from this vector.Subtracts the given vector from this vector.void
swap
(int index1, int index2) Swaps the values at the given indices.toMatrix()
Converts the vector to a matrix.toString()
Returns the vector as a string.
-
Constructor Details
-
Vector
public Vector(double[] values) Creates a new vector with the given values.- Parameters:
values
- The values of the vector.
-
Vector
public Vector(int size) Creates a new vector with the given size.- Parameters:
size
- The size of the vector.
-
-
Method Details
-
getValues
public double[] getValues()Gets the values of the vector.- Returns:
- The values of the vector.
-
get
public double get(int index) Gets the value at the given index.- Parameters:
index
- The index to get the value for.- Returns:
- The value at the given index.
-
set
public void set(int index, double value) Sets the value at the given index.- Parameters:
index
- The index to set the value for.value
- The value to set.
-
swap
public void swap(int index1, int index2) Swaps the values at the given indices.- Parameters:
index1
- The first index.index2
- The second index.
-
size
public int size()Gets the size of the vector.- Returns:
- The size of the vector.
-
add
Adds the given vector to this vector.- Parameters:
vector
- The vector to add.- Returns:
- The sum of the two vectors.
-
subtract
Subtracts the given vector from this vector.- Parameters:
vector
- The vector to subtract.- Returns:
- The difference of the two vectors.
-
subtract
Subtracts the given matrix from this vector.- Parameters:
matrix
- The matrix to subtract.- Returns:
- The difference of the vector and the matrix.
-
toMatrix
Converts the vector to a matrix.- Returns:
- The vector as a matrix.
-
toString
Returns the vector as a string.
-