java.lang.Object
de.grogra.pointcloud.clustering.ClusterVector
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.clone()
Clones this vector and returns the clone vector.double
get
(int index) Returns the value of the element at the given position.static ClusterVector
getCrossProduct3
(ClusterVector vector1, ClusterVector vector2) Calculates and returns the cross product of two three dimensional vectors.int
Returns the number of elements in this vector.double
Returns the pythagorean length of this vector.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.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.void
set
(int index, double value) Sets the value of the element at the given position.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.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.
-
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 setvalue
- 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
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 sumvector2
- 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
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 subtractionvector2
- 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
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 productvector2
- 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
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 productvector2
- The second vector for the cross product- Returns:
- The cross product of both vectors
-
multiplyWithScalar
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 fromscalar
- 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
Clones this vector and returns the clone vector.
-