Class ClusterVector

java.lang.Object
de.grogra.pointcloud.clustering.ClusterVector

public class ClusterVector extends Object
  • Constructor Details

    • ClusterVector

      public ClusterVector(double[] data)
      Creates a new vector and sets the data. If the data is null, an exception is thrown.
      Parameters:
      data - The new data for this vector
      Throws:
      NullPointerException - If the data array is null
  • Method Details

    • getNumberOfElemenents

      public int getNumberOfElemenents()
      Returns the number of elements in this vector.
      Returns:
      The number of elements in this vector
    • set

      public void set(int index, double value)
      Sets the value of the element at the given position.
      Parameters:
      index - The position where the value should be set
      value - The value that should be set at that position
    • get

      public double get(int index)
      Returns the value of the element at the given position.
      Parameters:
      index - The position from where the value should be returned
      Returns:
      The value at that position
    • getPythagoreanLength

      public double getPythagoreanLength()
      Returns the pythagorean length of this vector. This length considers all dimensions.
      Returns:
      The pythagorean length of this vector
    • addVectors

      public static ClusterVector addVectors(ClusterVector vector1, ClusterVector vector2)
      Adds the values of both vectors and returns a third vector with the sum of both input vectors in each field of the output vector. If the dimensions do not fit together, an exception is thrown.
      Parameters:
      vector1 - The first vector for the sum
      vector2 - The second vector for the sum
      Returns:
      The resulting vector with the sum of the elements from both input vectors
      Throws:
      IllegalArgumentException - If the vectors have a different number of elements
    • subtractVectors

      public static ClusterVector subtractVectors(ClusterVector vector1, ClusterVector vector2)
      Subtracts the values of both vectors and returns a third vector with the subtraction of the second vector from the first vector in each field of the output vector. If the dimensions do not fit together, an exception is thrown.
      Parameters:
      vector1 - The first vector for the subtraction
      vector2 - The second vector for the subtraction
      Returns:
      The resulting vector with the subtraction of the elements from both input vectors
      Throws:
      IllegalArgumentException - If the vectors have a different number of elements
    • getScalarProduct

      public static double getScalarProduct(ClusterVector vector1, ClusterVector vector2)
      Calculates and returns the scalar product of both given vectors and throws an exception if the dimensions of both input vectors are different.
      Parameters:
      vector1 - The first vector for the scalar product
      vector2 - The second vector for the scalar product
      Returns:
      The scalar product of both input vectors
      Throws:
      IllegalArgumentException - If the dimensions of the vectors do not fit together
    • getCrossProduct3

      public static ClusterVector getCrossProduct3(ClusterVector vector1, ClusterVector vector2)
      Calculates and returns the cross product of two three dimensional vectors. If the vectors have too few dimensions, an exception will be thrown.
      Parameters:
      vector1 - The first vector for the cross product
      vector2 - The second vector for the cross product
      Returns:
      The cross product of both vectors
    • multiplyWithScalar

      public static ClusterVector multiplyWithScalar(ClusterVector vector, double scalar)
      Multiplies the given scalar value with all values of the given vector and returns a new vector with all multiplication results as fields.
      Parameters:
      vector - The vector to get the elements from
      scalar - The scalar value to multiply with all vector values
      Returns:
      The new vector with all multiplication results
    • trimToLength

      public void trimToLength(double length)
      Changes this vector so that the relation between the dimensions (the direction) are/is kept and the new length is as long as the given length.
      Parameters:
      length - The target length for this vector
    • clone

      public ClusterVector clone()
      Clones this vector and returns the clone vector.
      Overrides:
      clone in class Object
      Returns:
      The clone vector