Class Vector

java.lang.Object
me.autobot.lib.math.linalg.Vector

public class Vector extends Object
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
    Constructor
    Description
    Vector(double[] values)
    Creates a new vector with the given values.
    Vector(int size)
    Creates a new vector with the given size.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Vector vector)
    Adds 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
    Gets the size of the vector.
    subtract(Matrix matrix)
    Subtracts the given matrix from this vector.
    subtract(Vector vector)
    Subtracts the given vector from this vector.
    void
    swap(int index1, int index2)
    Swaps the values at the given indices.
    Converts the vector to a matrix.
    Returns the vector as a string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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

      public Vector add(Vector vector)
      Adds the given vector to this vector.
      Parameters:
      vector - The vector to add.
      Returns:
      The sum of the two vectors.
    • subtract

      public Vector subtract(Vector vector)
      Subtracts the given vector from this vector.
      Parameters:
      vector - The vector to subtract.
      Returns:
      The difference of the two vectors.
    • subtract

      public Vector subtract(Matrix matrix)
      Subtracts the given matrix from this vector.
      Parameters:
      matrix - The matrix to subtract.
      Returns:
      The difference of the vector and the matrix.
    • toMatrix

      public Matrix toMatrix()
      Converts the vector to a matrix.
      Returns:
      The vector as a matrix.
    • toString

      public String toString()
      Returns the vector as a string.
      Overrides:
      toString in class Object