Helios++
Helios software for LiDAR simulations
|
Class providing vector operations. More...
#include <Vector.hpp>
Static Public Member Functions | |
static vector< T > | add (vector< T > const u, vector< T > const v) |
Add two vectors. More... | |
static vector< T > | subtract (vector< T > const u, vector< T > const v) |
Subtract two vectors. More... | |
static vector< T > | scalarAdd (vector< T > const u, T const scalar) |
Add the scalar to all elements in vector \(\overline{u}\). More... | |
static vector< T > | scalarSubtract (vector< T > const u, T const scalar) |
Subtract the scalar to all elements in vector \(\overline{u}\). More... | |
static vector< T > | scalarMultiply (vector< T > const u, T const scalar) |
Multiply all elements in vector \(overline{u}\) by scalar. More... | |
static vector< T > | scalarDivide (vector< T > const u, T const scalar) |
Divide all elements in vector \(\overline{u}\) by scalar. More... | |
static void | scalarAddInPlace (vector< T > &u, T const scalar) |
Like scalarAdd function but modifying given vector. More... | |
static void | scalarSubtractInPlace (vector< T > &u, T const scalar) |
Like scalarSubtract function but modifying given vector. More... | |
static void | scalarMultiplyInPlace (vector< T > &u, T const scalar) |
Like scalarMultiply function but modifying given vector. More... | |
static void | scalarDivideInPlace (vector< T > &u, T const scalar) |
Like scalarDivide function but modifying given vector. More... | |
static vector< T > | negate (vector< T > const u) |
Compute the opposite of given vector \(u\). More... | |
static bool | equals (vector< T > const u, vector< T > const v) |
Check if you vectors are equal or not. More... | |
static T | min (vector< T > const &u) |
Obtain the minimum value in given vector. More... | |
static T | max (vector< T > const &u) |
Obtain the maximum value in given vector. More... | |
static size_t | argmin (vector< T > const &u) |
Obtain the index of minimum value in given vector. More... | |
static size_t | argmax (vector< T > const &u) |
Obtain the index of maximum value in given vector. More... | |
static T | midrange (vector< T > const &u) |
Compute the midrange \(\lambda\) for given vector. More... | |
static T | dotProduct (vector< T > const u, vector< T > const v) |
Compute the dot product between vectors \(\overline{u}\) and \(\overline{v}\). More... | |
static vector< T > | crossProduct3D (vector< T > const u, vector< T > const v) |
Compute the 3D cross product between vectors \(\overline{u}\) and \(\overline{v}\). More... | |
static vector< T > | hadamardProduct (vector< T > const u, vector< T > const v) |
Compute the hadamard product between vectors \(\overline{u}\) and \(\overline{v}\). More... | |
static T | squareNorm (vector< T > const u) |
Compute the square norm (magnitude) of vector \(\overline{u}\). More... | |
static T | squareMagnitude (vector< T > const u) |
static T | norm (vector< T > const u) |
Compute the norm (magnitude) of vector \(\overline{u}\), which is the square root of its square norm. More... | |
static T | magnitude (vector< T > const u) |
static vector< T > | normalize (vector< T > const u) |
Normalize given vector \(\overline{u}\), obtaining \(\hat{u}\). More... | |
static vector< T > | normalize (vector< T > const u, T const norm) |
Like Vector::normalize(vector<T> const) but providing a precomputed norm so it is not necessary to compute it. Hence, it is faster as it performs less operations. More... | |
static void | normalizeInPlace (vector< T > &u) |
Like Vector::normalize(vector<T> const) but modifying given vector instead of creating new one. More... | |
static void | normalizeInPlace (vector< T > &u, T const norm) |
Like Vector::normalize(vector<T> const, T const) but modifying given vector instead of creating new one. More... | |
static T | angle (vector< T > const u, vector< T > const v, bool alreadyNormalized=false) |
Compute the angle between two given vectors \(overline{u}\) and \(\overline{v}\). More... | |
static T | acuteAngle (vector< T > const u, vector< T > const v, bool alreadyNormalized=false) |
Compute the \(\theta \leq \frac{\pi}{2}\) angle between two given vectors \(\vec{u}\) and \(\vec{v}\). More... | |
static T | toAngle2D (vector< T > const u) |
Compute the 2D angle coming from two first components of vector \(\overline{u}\). More... | |
static vector< T > | findOrthogonal (vector< T > const v) |
Find a orthogonal vector with respect to \(v\). More... | |
static vector< T > | findOrthonormal (vector< T > const v) |
Like findOrthogonal(vector<T> const) but returning a normalized orthogonal vector. More... | |
static vector< vector< T > > | findOrthonormals (vector< vector< T >> const V) |
Like findOrthonormal(vector<T> const) but applied to a vector of vectors instead of a single vector. More... | |
static vector< vector< T > > | xyRotations (size_t const depth, bool complement) |
Compute normal vectors representing different rotations on 2D. More... | |
static bool | isNull (vector< T > const &v) |
Check if \(\vec{v}\) is a null vector (all zero) or not. More... | |
static vector< T > | project (vector< T > const v, vector< T > const u) |
Project vector \(v\) over vector \(u\). More... | |
static vector< T > | project (vector< T > const v, vector< vector< T >> const u) |
Project vector \(v\) over subspace \(u\). More... | |
static vector< T > | diff (vector< T > const u) |
Compute \(v\) as the discrete differences of vector \(u\). More... | |
Class providing vector operations.
T | Type of element used by the vector |
|
static |
Compute the \(\theta \leq \frac{\pi}{2}\) angle between two given vectors \(\vec{u}\) and \(\vec{v}\).
\[ {\theta}' = \arccos{\left( \frac{\langle{\overline{u},\overline{v}}\rangle} {||\overline{u}||\cdot||\overline{v}||} \right)} \]
When \({\theta}' \leq \frac{\pi}{2}\) then \(\theta = {\theta}'\), otherwise \(\theta = \pi - {\theta}'\)
u | First vector |
v | Second vector |
alreadyNormalized | True when vectors are already normalized so normalization is not necessary and computation will be faster, false otherwise |
|
static |
Add two vectors.
|
static |
Compute the angle between two given vectors \(overline{u}\) and \(\overline{v}\).
\[ \theta = \arccos{\left( \frac{\overline{u}\cdot\overline{v}} {||\overline{u}||\cdot||\overline{v}||} \right)} \]
u | First vector |
v | Second vector |
alreadyNormalized | True when vectors are already normalized so normalization is not necessary and computation will be faster, false otherwise |
|
static |
Obtain the index of maximum value in given vector.
u | Vector which maximum value index must be obtained |
|
static |
Obtain the index of minimum value in given vector.
u | Vector which minimum value index must be obtained |
|
static |
Compute the 3D cross product between vectors \(\overline{u}\) and \(\overline{v}\).
\[ \overline{w} = \overline{u} \times \overline{v} = ( u_{y}v_{z} - u_{z}v_{y}, u_{z}v_{x} - u_{x}v_{z}, u_{x}v_{y} - u_{y}v_{x} ) \]
u | First vector |
v | Second vector |
|
static |
Compute \(v\) as the discrete differences of vector \(u\).
The cardinality of \(v\) will be \(|v| = |u| - 1\).
Also, \(v_i = u_{i+1} - u_{i}\), so:
\[ v = \left(u_{2}-u_{1}, \ldots, u_{n}-u_{n-1}\right) \]
u | Vector to differentiate |
|
static |
Compute the dot product between vectors \(\overline{u}\) and \(\overline{v}\).
\[ \overline{u} \cdot \overline{v} = \sum_{i=1}^{n}{u_{i} v_{i}} \]
u | First vector |
v | Second vector |
|
static |
Check if you vectors are equal or not.
Two vectors \(u\) and \(v\) are considered to be equal when \(\forall i,\, u_{i}=v_{i}\)
u | First vector to compare with |
v | Second vector to compare with |
|
static |
|
inlinestatic |
Like findOrthogonal(vector<T> const) but returning a normalized orthogonal vector.
|
static |
Like findOrthonormal(vector<T> const) but applied to a vector of vectors instead of a single vector.
|
static |
Compute the hadamard product between vectors \(\overline{u}\) and \(\overline{v}\).
\[ \overline{w} = \overline{u} \odot \overline{v} = (u_{1}v_{1}, \ldots , u_{n}v_{n}) \]
u | First vector |
v | Second vector |
|
static |
Check if \(\vec{v}\) is a null vector (all zero) or not.
v | Check to be checked for nullity |
|
inlinestatic |
|
static |
Obtain the maximum value in given vector.
u | Vector which maximum value must be obtained |
|
static |
Compute the midrange \(\lambda\) for given vector.
\[ \lambda = \frac{u_{max}+u_{min}}{2} \]
u | Vector which midrange must be obtained |
|
static |
Obtain the minimum value in given vector.
u | Vector which minimum value must be obtained |
|
static |
Compute the opposite of given vector \(u\).
\[ u = (u_{1}, ..., u_{n}) \implies -u = (-u_{1}, ..., -u_{n}) \]
u | Vector to be negated |
|
static |
Compute the norm (magnitude) of vector \(\overline{u}\), which is the square root of its square norm.
\[ ||\overline{u}|| = \sqrt{\sum_{i=1}^{n}{u_{i}^{2}}} \]
u | Vector which norm (magnitude) must be computed |
|
static |
Normalize given vector \(\overline{u}\), obtaining \(\hat{u}\).
\[ \hat{u} = \left(\frac{u_{i}}{||\overline{u}||} ,\ldots, \frac{u_{i}}{||\overline{u}||}\right) \]
u | Vector to be normalized |
|
static |
Like Vector::normalize(vector<T> const) but providing a precomputed norm so it is not necessary to compute it. Hence, it is faster as it performs less operations.
|
static |
Like Vector::normalize(vector<T> const) but modifying given vector instead of creating new one.
|
static |
Like Vector::normalize(vector<T> const, T const) but modifying given vector instead of creating new one.
|
static |
|
static |
Project vector \(v\) over subspace \(u\).
Considering \(u = \langle{b_{1}, \ldots, b_{n}}\rangle\)
\[ \mathrm{proj}_{u}{v} = \frac{\langle{v,b_{1}}\rangle}{\langle{b_{1},b_{1}}\rangle} b_{1} + \ldots + \frac{\langle{v,b_{n}}\rangle}{\langle{b_{n},b_{n}}\rangle} b_{n} = \sum_{i=1}^{n}{\frac{\langle{v,b_{i}}\rangle}{||b_{i}||^{2}}b_{i}} \]
v | Vector to be projected |
u | Basis of the vector subspace to project over it |
|
static |
Add the scalar to all elements in vector \(\overline{u}\).
|
static |
Like scalarAdd function but modifying given vector.
|
static |
Divide all elements in vector \(\overline{u}\) by scalar.
|
static |
Like scalarDivide function but modifying given vector.
|
static |
Multiply all elements in vector \(overline{u}\) by scalar.
|
static |
Like scalarMultiply function but modifying given vector.
|
static |
Subtract the scalar to all elements in vector \(\overline{u}\).
|
static |
Like scalarSubtract function but modifying given vector.
|
inlinestatic |
|
static |
Compute the square norm (magnitude) of vector \(\overline{u}\).
\[ ||\overline{u}||^{2} = \sum_{i=1}^{n}{u_{i}^{2}} \]
u | Vector which square norm (magnitude) must be computed |
|
inlinestatic |
Subtract two vectors.
|
static |
Compute the 2D angle coming from two first components of vector \(\overline{u}\).
u | Vector which 2D angle must be obtained |
|
static |
Compute normal vectors representing different rotations on 2D.
Rotations are computed according to following formula
\[ x' = cos(\theta)x - sin(\theta)y \\ y' = sin(\theta)x + cos(\theta)y \]
depth | The number of rotations computed in the semi-circumference space. |
complement | When it is false, as many vectors as depth will be returned. However, when it is true, as many vectors as depth x 2 will be returned, since the entire circumference will be considered through negation of vectors in the semi-circumference space |