1 #ifndef _SURFACEINSPECTOR_MATHS_VECTOR_HPP_
2 #define _SURFACEINSPECTOR_MATHS_VECTOR_HPP_
6 #include <surfaceinspector/util/Object.hpp>
7 #include <surfaceinspector/util/SurfaceInspectorException.hpp>
13 namespace SurfaceInspector{
namespace maths {
31 static vector<T>
add(vector<T>
const u, vector<T>
const v);
37 static inline vector<T>
subtract(vector<T>
const u, vector<T>
const v)
44 static vector<T>
scalarAdd(vector<T>
const u, T
const scalar);
89 static vector<T>
negate(vector<T>
const u);
100 static bool equals(vector<T>
const u, vector<T>
const v);
106 static T
min(vector<T>
const &u);
112 static T
max(vector<T>
const &u);
118 static size_t argmin(vector<T>
const &u);
124 static size_t argmax(vector<T>
const &u);
198 {
return normSquare(u);}
211 static T
norm(vector<T>
const u);
270 bool alreadyNormalized=
false
297 bool alreadyNormalized=
false
383 static vector<T>
project(vector<T>
const v, vector<T>
const u);
403 static vector<T>
project(vector<T>
const v, vector<vector<T>>
const u);
418 static vector<T>
diff(vector<T>
const u);
423 #include <surfaceinspector/maths/Vector.tpp>
Class providing vector operations.
Definition: Vector.hpp:23
static void scalarSubtractInPlace(vector< T > &u, T const scalar)
Like scalarSubtract function but modifying given vector.
static void scalarAddInPlace(vector< T > &u, T const scalar)
Like scalarAdd function but modifying given vector.
static vector< T > project(vector< T > const v, vector< vector< T >> const u)
Project vector over subspace .
static T squareMagnitude(vector< T > const u)
Definition: Vector.hpp:197
static vector< T > negate(vector< T > const u)
Compute the opposite of given vector .
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 co...
static size_t argmin(vector< T > const &u)
Obtain the index of minimum value in given vector.
static vector< T > subtract(vector< T > const u, vector< T > const v)
Subtract two vectors.
Definition: Vector.hpp:37
static vector< T > normalize(vector< T > const u)
Normalize given vector , obtaining .
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 o...
static T magnitude(vector< T > const u)
Definition: Vector.hpp:215
static vector< vector< T > > xyRotations(size_t const depth, bool complement)
Compute normal vectors representing different rotations on 2D.
static vector< T > diff(vector< T > const u)
Compute as the discrete differences of vector .
static bool equals(vector< T > const u, vector< T > const v)
Check if you vectors are equal or not.
static T squareNorm(vector< T > const u)
Compute the square norm (magnitude) of vector .
static T dotProduct(vector< T > const u, vector< T > const v)
Compute the dot product between vectors and .
static T norm(vector< T > const u)
Compute the norm (magnitude) of vector , which is the square root of its square norm.
static vector< T > scalarAdd(vector< T > const u, T const scalar)
Add the scalar to all elements in vector .
static vector< T > scalarMultiply(vector< T > const u, T const scalar)
Multiply all elements in vector by scalar.
static vector< T > scalarDivide(vector< T > const u, T const scalar)
Divide all elements in vector by scalar.
static T midrange(vector< T > const &u)
Compute the midrange for given vector.
static T acuteAngle(vector< T > const u, vector< T > const v, bool alreadyNormalized=false)
Compute the angle between two given vectors and .
static vector< T > add(vector< T > const u, vector< T > const v)
Add two vectors.
static void scalarMultiplyInPlace(vector< T > &u, T const scalar)
Like scalarMultiply function but modifying given vector.
static size_t argmax(vector< T > const &u)
Obtain the index of maximum value in given vector.
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.
static vector< T > scalarSubtract(vector< T > const u, T const scalar)
Subtract the scalar to all elements in vector .
static vector< T > crossProduct3D(vector< T > const u, vector< T > const v)
Compute the 3D cross product between vectors and .
static vector< T > findOrthogonal(vector< T > const v)
Find a orthogonal vector with respect to .
static vector< T > hadamardProduct(vector< T > const u, vector< T > const v)
Compute the hadamard product between vectors and .
static bool isNull(vector< T > const &v)
Check if is a null vector (all zero) or not.
static void scalarDivideInPlace(vector< T > &u, T const scalar)
Like scalarDivide function but modifying given vector.
static T toAngle2D(vector< T > const u)
Compute the 2D angle coming from two first components of vector .
static T angle(vector< T > const u, vector< T > const v, bool alreadyNormalized=false)
Compute the angle between two given vectors and .
static T min(vector< T > const &u)
Obtain the minimum value in given vector.
static vector< T > project(vector< T > const v, vector< T > const u)
Project vector over vector .
static void normalizeInPlace(vector< T > &u)
Like Vector::normalize(vector<T> const) but modifying given vector instead of creating new one.
static vector< T > findOrthonormal(vector< T > const v)
Like findOrthogonal(vector<T> const) but returning a normalized orthogonal vector.
Definition: Vector.hpp:329
static T max(vector< T > const &u)
Obtain the maximum value in given vector.
Class representing an object. All surface inspector classes must extend Object.
Definition: Object.hpp:12