![]() |
Scanframe Modular Application 0.1.0
|
3-dimensional vector for math operations. More...
#include <TVector3D.h>
Classes | |
union | data_type |
Storage union of the 3D coordinate making the x,y,z accessible as an array. More... | |
Public Types | |
typedef T | value_type |
Type declaration of the coordinate storage values. | |
Public Member Functions | |
TVector3D ()=default | |
Default constructor. | |
TVector3D (const TVector3D &v) | |
Copy constructor. | |
TVector3D (TVector3D &&) noexcept | |
Move constructor. | |
TVector3D (T xp, T yp, T zp) | |
Initializing constructor. | |
TVector3D & | assign (T xp, T yp, T zp) |
Assignment of new coordinate values. | |
TVector3D & | assign (const TVector3D &v) |
Assignment of vector instance. | |
TVector3D & | operator= (TVector3D &v) noexcept |
Assignment operator. | |
TVector3D & | operator= (TVector3D &&v) noexcept |
Assignment move operator. | |
TVector3D & | operator*= (const TMatrix44< T > &mtx) |
Matrix transform assignment operator. | |
TVector3D | operator* (const TMatrix44< T > &mtx) |
Matrix transform operator. | |
TVector3D | operator- () const |
Inversion math operator inverting the vector. | |
TVector3D & | operator+= (const TVector3D &) |
Compound addition operator. | |
TVector3D & | operator-= (const TVector3D &) |
Compound subtraction operator. | |
TVector3D & | operator*= (T c) |
Compound multiplier operator. | |
TVector3D & | operator/= (T) |
Compound division operator. | |
TVector3D | operator+ (const TVector3D &) const |
Addition operator. | |
TVector3D | operator- (const TVector3D &) const |
Subtraction operator. | |
TVector3D | operator/ (T c) const |
Division operator. | |
bool | isEqual (const TVector3D &v, T tol=tolerance) const |
Compares the passed vector within the set tolerance. | |
bool | operator== (const TVector3D &) const |
Equality operator. | |
bool | operator!= (const TVector3D &) const |
Inequality operator. | |
T & | operator[] (size_t) |
Access like an array. | |
const T & | operator[] (size_t) const |
Access like a const array. | |
constexpr T * | data () |
Gets a const pointer to the data. | |
constexpr const T * | data () const |
Gets a const pointer to the data. | |
constexpr | operator T* () |
Cast operator for pointer. | |
constexpr | operator const T * () const |
Cast operator for const pointer. | |
constexpr T | x () const |
Gets the x-coordinate value. | |
constexpr T & | x () |
Gets the x-coordinate value as reference. | |
constexpr T | y () const |
Gets the y-coordinate value. | |
constexpr T & | y () |
Gets the y-coordinate value as reference. | |
constexpr T | z () const |
Gets the z-coordinate value. | |
constexpr T & | z () |
Gets the z-coordinate value as reference. | |
T | length () const |
Gets the length or magnitude of the vector. | |
T | length2D () const |
Gets the length or magnitude of the vector for only X and Y axis. | |
T | lengthSqr () const |
Gets the squared length or magnitude of the vector. | |
T | lengthSqr2D () const |
Gets the squared length or magnitude of the vector for only the X and Y axis. | |
TVector3D & | normalize () |
Normalizes the vector also called a unit-vector, set to length 1. | |
TVector3D | normalized () const |
Gets a normalized vector also called a unit-vector, made of length 1. | |
TVector3D & | scale (T factor) |
Scales the vector by multiplying all axis with the passed factor. | |
TVector3D | scaled (T factor) const |
Scales the vector by multiplying all axis with the passed factor. | |
TVector3D | crossProduct (const TVector3D &) const |
Gets the cross (out) product of 2 vectors. | |
T | dotProduct (const TVector3D &) const |
Gets the dot (in) product of 2 vectors. | |
T | dotProduct2D (const TVector3D &) const |
Gets the dot (in) product of 2 vectors for only the X and Y axis. | |
TVector3D | operator* (const TVector3D &v) const |
Gets the cross (out) product of 2 vectors. | |
T | angle (const TVector3D &) const |
Gets the angle between the two vectors. | |
T | angleNormalized () const |
Returns a normalized positive angle of function angle(). | |
T | distance (const TVector3D &) const |
Gets the distance between this and the passed vector. Note that this has to return a double because it uses the sqrt() function. | |
T | distance2D (const TVector3D &) const |
Gets the distance between this and the passed vector for only the X and Y axis. Note that this has to return a double because it uses the sqrt() function. | |
T | distanceSqr (const TVector3D &) const |
Gets the squared distance between 2 given points. Avoids taking an expensive sqrt call. Useful when comparing different distances. | |
T | distanceSqr2D (const TVector3D &) const |
Gets the squared distance between 2 given points in 2D only (z is ignored). Avoids taking an expensive sqrt call. Useful when comparing different distances. | |
void | updateMin (const TVector3D &vertex) |
Copy only those values of x,y or z which are smaller. | |
void | updateMax (const TVector3D &vertex) |
Copy only those values of x,y or z which are larger. | |
std::string | toString () const |
Gets the string representation of the 2D vector formed like '(1.23,4.56)'. | |
TVector3D & | fromString (const std::string &s) noexcept(false) |
Gets the vector value from the string representation formed like '(1.23,4.56,7.89)'. Throws an exception when the string is not in the correct format. | |
int | dominantAxis () |
Gets the dominant axis where x=0, y=1 and z=2. | |
void | copyTo (T fa[3]) const |
Copies the X, Y and Z values to an array of type 'T' or type 'TVector3D<T>::value_type'. | |
template<typename F = T, size_t N = 3> | |
std::array< F, N > | array (F value=1) const |
Gets a std::array of type F of the X, Y and Z axis. Allows the size of the array to be specified so it can be used in a OpenGL function call. | |
template<typename F = float, size_t N = 4> | |
const F * | floatPtr (F value=1) const |
Gets an array pointer of floating point type F of the X, Y and Z axis. Used to pass to OpenGL where a specific floating point value is required. This function is thread safe by returning a thread local static variable. | |
Static Public Attributes | |
static constexpr auto | tolerance = std::numeric_limits<T>::epsilon() * T(15.0) |
Tolerance for when comparing in the equal operator. Empirical chosen epsilon multiplier to make it work after calculations. Used as: std::fabs(x1 - x2) < tolerance. | |
Protected Attributes | |
union sf::TVector3D::data_type | _data |
3-dimensional vector for math operations.
typedef T sf::TVector3D< T >::value_type |
Type declaration of the coordinate storage values.
|
default |
Default constructor.
sf::TVector3D< T >::TVector3D | ( | const TVector3D< T > & | v | ) |
Copy constructor.
|
noexcept |
Move constructor.
sf::TVector3D< T >::TVector3D | ( | T | xp, |
T | yp, | ||
T | zp | ||
) |
Initializing constructor.
xp | X-axis value. |
yp | Y-axis value. |
zp | Z-axis value. |
T sf::TVector3D< T >::angle | ( | const TVector3D< T > & | ) | const |
Gets the angle between the two vectors.
T sf::TVector3D< T >::angleNormalized | ( | ) | const |
Returns a normalized positive angle of function angle().
std::array< F, N > sf::TVector3D< T >::array | ( | F | value = 1 | ) | const |
Gets a std::array of type F of the X, Y and Z axis. Allows the size of the array to be specified so it can be used in a OpenGL function call.
F | Type of the float array being returned. |
N | Size of the array being returned. |
value | Value of the array entries beyond the 3rd entry. |
TVector3D & sf::TVector3D< T >::assign | ( | const TVector3D< T > & | v | ) |
Assignment of vector instance.
v | Vector value. |
TVector3D & sf::TVector3D< T >::assign | ( | T | xp, |
T | yp, | ||
T | zp | ||
) |
Assignment of new coordinate values.
xp | X-axis value. |
yp | Y-axis value. |
zp | Y-axis value. |
void sf::TVector3D< T >::copyTo | ( | T | fa[3] | ) | const |
Copies the X, Y and Z values to an array of type 'T' or type 'TVector3D<T>::value_type'.
TVector3D sf::TVector3D< T >::crossProduct | ( | const TVector3D< T > & | ) | const |
Gets the cross (out) product of 2 vectors.
|
constexpr |
Gets a const pointer to the data.
|
constexpr |
Gets a const pointer to the data.
T sf::TVector3D< T >::distance | ( | const TVector3D< T > & | ) | const |
Gets the distance between this and the passed vector. Note that this has to return a double because it uses the sqrt() function.
T sf::TVector3D< T >::distance2D | ( | const TVector3D< T > & | ) | const |
Gets the distance between this and the passed vector for only the X and Y axis. Note that this has to return a double because it uses the sqrt() function.
T sf::TVector3D< T >::distanceSqr | ( | const TVector3D< T > & | ) | const |
Gets the squared distance between 2 given points. Avoids taking an expensive sqrt call. Useful when comparing different distances.
T sf::TVector3D< T >::distanceSqr2D | ( | const TVector3D< T > & | ) | const |
Gets the squared distance between 2 given points in 2D only (z is ignored). Avoids taking an expensive sqrt call. Useful when comparing different distances.
int sf::TVector3D< T >::dominantAxis | ( | ) |
Gets the dominant axis where x=0, y=1 and z=2.
T sf::TVector3D< T >::dotProduct | ( | const TVector3D< T > & | ) | const |
Gets the dot (in) product of 2 vectors.
T sf::TVector3D< T >::dotProduct2D | ( | const TVector3D< T > & | ) | const |
Gets the dot (in) product of 2 vectors for only the X and Y axis.
const F * sf::TVector3D< T >::floatPtr | ( | F | value = 1 | ) | const |
Gets an array pointer of floating point type F of the X, Y and Z axis. Used to pass to OpenGL where a specific floating point value is required. This function is thread safe by returning a thread local static variable.
F | Type of the float pointer being returned. |
N | Depth of the array being returned. |
value | Value of the array entries beyond the 3rd entry. |
TVector3D & sf::TVector3D< T >::fromString | ( | const std::string & | s | ) |
Gets the vector value from the string representation formed like '(1.23,4.56,7.89)'. Throws an exception when the string is not in the correct format.
std::invalid_argument |
bool sf::TVector3D< T >::isEqual | ( | const TVector3D< T > & | v, |
T | tol = tolerance |
||
) | const |
Compares the passed vector within the set tolerance.
v | Vector to compare with. |
tol | The tolerance when comparing which has a default. |
T sf::TVector3D< T >::length | ( | ) | const |
Gets the length or magnitude of the vector.
Note that this has to return a double because it uses the sqrt function.
T sf::TVector3D< T >::length2D | ( | ) | const |
Gets the length or magnitude of the vector for only X and Y axis.
Note that this has to return a double because it uses the sqrt function.
T sf::TVector3D< T >::lengthSqr | ( | ) | const |
Gets the squared length or magnitude of the vector.
T sf::TVector3D< T >::lengthSqr2D | ( | ) | const |
Gets the squared length or magnitude of the vector for only the X and Y axis.
TVector3D & sf::TVector3D< T >::normalize | ( | ) |
Normalizes the vector also called a unit-vector, set to length 1.
TVector3D sf::TVector3D< T >::normalized | ( | ) | const |
Gets a normalized vector also called a unit-vector, made of length 1.
|
constexpr |
Cast operator for const pointer.
|
constexpr |
Cast operator for pointer.
bool sf::TVector3D< T >::operator!= | ( | const TVector3D< T > & | ) | const |
Inequality operator.
TVector3D sf::TVector3D< T >::operator* | ( | const TMatrix44< T > & | mtx | ) |
Matrix transform operator.
TVector3D sf::TVector3D< T >::operator* | ( | const TVector3D< T > & | v | ) | const |
Gets the cross (out) product of 2 vectors.
TVector3D & sf::TVector3D< T >::operator*= | ( | const TMatrix44< T > & | mtx | ) |
Matrix transform assignment operator.
TVector3D & sf::TVector3D< T >::operator*= | ( | T | c | ) |
Compound multiplier operator.
TVector3D sf::TVector3D< T >::operator+ | ( | const TVector3D< T > & | ) | const |
Addition operator.
TVector3D & sf::TVector3D< T >::operator+= | ( | const TVector3D< T > & | ) |
Compound addition operator.
TVector3D sf::TVector3D< T >::operator- | ( | ) | const |
Inversion math operator inverting the vector.
TVector3D sf::TVector3D< T >::operator- | ( | const TVector3D< T > & | ) | const |
Subtraction operator.
TVector3D & sf::TVector3D< T >::operator-= | ( | const TVector3D< T > & | ) |
Compound subtraction operator.
TVector3D sf::TVector3D< T >::operator/ | ( | T | c | ) | const |
Division operator.
TVector3D & sf::TVector3D< T >::operator/= | ( | T | ) |
Compound division operator.
|
noexcept |
Assignment move operator.
|
noexcept |
Assignment operator.
bool sf::TVector3D< T >::operator== | ( | const TVector3D< T > & | ) | const |
Equality operator.
T & sf::TVector3D< T >::operator[] | ( | size_t | ) |
Access like an array.
std::out_of_range |
const T & sf::TVector3D< T >::operator[] | ( | size_t | ) | const |
Access like a const array.
std::out_of_range |
TVector3D & sf::TVector3D< T >::scale | ( | T | factor | ) |
Scales the vector by multiplying all axis with the passed factor.
TVector3D sf::TVector3D< T >::scaled | ( | T | factor | ) | const |
Scales the vector by multiplying all axis with the passed factor.
std::string sf::TVector3D< T >::toString | ( | ) | const |
Gets the string representation of the 2D vector formed like '(1.23,4.56)'.
void sf::TVector3D< T >::updateMax | ( | const TVector3D< T > & | vertex | ) |
Copy only those values of x,y or z which are larger.
vertex |
void sf::TVector3D< T >::updateMin | ( | const TVector3D< T > & | vertex | ) |
Copy only those values of x,y or z which are smaller.
vertex |
|
constexpr |
Gets the x-coordinate value as reference.
|
constexpr |
Gets the x-coordinate value.
|
constexpr |
Gets the y-coordinate value as reference.
|
constexpr |
Gets the y-coordinate value.
|
constexpr |
Gets the z-coordinate value as reference.
|
constexpr |
Gets the z-coordinate value.
|
protected |
|
staticconstexpr |
Tolerance for when comparing in the equal operator. Empirical chosen epsilon multiplier to make it work after calculations. Used as: std::fabs(x1 - x2) < tolerance.