![]() |
Scanframe Modular Application 0.1.0
|
2-dimensional vector for math operations. More...
#include <TVector2D.h>

Classes | |
| union | data_type |
| Storage union of the 2D coordinate making the x,y accessible as an array. More... | |
Public Types | |
| typedef T | value_type |
| Type declaration of the coordinate storage values. | |
Public Member Functions | |
| TVector2D ()=default | |
| Default constructor. | |
| TVector2D (const TVector2D &v) | |
| Copy constructor. | |
| TVector2D (TVector2D &&) noexcept | |
| Move constructor. | |
| TVector2D (T xp, T yp) | |
| Initializing constructor. | |
| TVector2D & | assign (T xp, T yp) |
| Assignment of new coordinate values. | |
| TVector2D & | assign (const TVector2D &v) |
| Assignment of a vector instance. | |
| TVector2D & | operator= (const TVector2D &v) noexcept |
| Assignment operator. | |
| TVector2D & | operator= (TVector2D &&v) noexcept |
| Assignment move operator. | |
| TVector2D & | operator*= (const TMatrix22< T > &mtx) |
| Matrix transform operator. | |
| TVector2D | operator- () const |
| Inversion math operator inverting the vector. | |
| TVector2D & | operator+= (const TVector2D &) |
| Compound addition operator. | |
| TVector2D & | operator-= (const TVector2D &) |
| Compound subtraction operator. | |
| TVector2D & | operator*= (T c) |
| Compound multiplier operator. | |
| TVector2D & | operator/= (T) |
| Compound division operator. | |
| TVector2D | operator+ (const TVector2D &) const |
| Addition operator. | |
| TVector2D | operator- (const TVector2D &) const |
| Subtraction operator. | |
| TVector2D | operator/ (T) const |
| Division operator. | |
| bool | isEqual (const TVector2D &v, T tol=tolerance) const |
| Compares the passed vector within the set tolerance. | |
| bool | operator== (const TVector2D &) const |
| Equality operator. | |
| bool | operator!= (const TVector2D &) 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 to a pointer. | |
| constexpr | operator const T * () const |
| Cast-operator to a const pointer. | |
| constexpr T | x () const |
| Gets the x-coordinate value. | |
| constexpr T & | x () |
| Gets the x-coordinate value as a reference. | |
| constexpr T | y () const |
| Gets the y-coordinate value. | |
| constexpr T & | y () |
| Gets the y-coordinate value as a reference. | |
| T | length () const |
| Gets the length or magnitude of the vector. | |
| T | lengthSqr () const |
| Gets the squared length or magnitude of the vector. | |
| TVector2D & | normalize () |
| Normalizes the vector also called a unit-vector, set to length 1. | |
| TVector2D | normalized () const |
| Gets a normalized vector also called a unit-vector, made of length 1. | |
| TVector2D & | scale (T factor) |
| Scales the vector by multiplying all axes with the passed factor. | |
| TVector2D | scaled (T factor) const |
| Scales the vector by multiplying all axes with the passed factor. | |
| T | crossProduct (const TVector2D &) const |
| Gets the cross (out) product of 2 vectors. | |
| T | dotProduct (const TVector2D &) const |
| Gets the dot (in) product of 2 vectors. | |
| T | operator* (const TVector2D &v) const |
| Gets the cross (out) product of 2 vectors. | |
| T | angle (const TVector2D &) const |
| Gets the angle between the two vectors. | |
| T | angle () const |
| Gets the angle of vector in xy-plane. | |
| T | angleNormalized () const |
| Returns a normalized positive angle of function angle(). | |
| T | slope () const |
| Gets the slope (coefficient) of the line formed with the origin (0, 0). When it is an infinite value +/- std::numeric_limits<T>::infinity() is returned. | |
| T | distance (const TVector2D &) 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 | distanceSqr (const TVector2D &) const |
| Gets the squared distance between 2 given points. Avoids taking an expensive sqrt call. Useful when comparing different distances. | |
| void | updateMin (const TVector2D &vertex) |
| Copy only those values of x or y which are smaller. | |
| void | updateMax (const TVector2D &vertex) |
| Copy only those values of x or y which are larger. | |
| std::string | toString () const |
| Gets the string representation of the 2D vector formed like '(1.23,4.56)'. | |
| TVector2D & | fromString (const std::string &s, bool ignore_err=false) noexcept(false) |
| Gets the vector value from the string representation formed like '(1.23,4.56)'. Throws an exception when the string is not in the correct format. | |
Static Public Member Functions | |
| static int | areOnSameSide (const TVector2D &lp1, const TVector2D &lp2, const TVector2D &p1, const TVector2D &p2) |
| Checks where 2 points lie in relation to a given line given by 2 points. | |
Static Public Attributes | |
| static constexpr auto | tolerance = std::numeric_limits<T>::epsilon() * 10.0 |
| Tolerance for when comparing in the equal operator. Empirical chosen epsilon multiplier to make it work. Used in: sf::isEqual() | |
Protected Attributes | |
| union sf::TVector2D::data_type | _data |
| friend | TRectangle2D< T > |
2-dimensional vector for math operations.
| typedef T sf::TVector2D< T >::value_type |
Type declaration of the coordinate storage values.
|
default |
Default constructor.
| sf::TVector2D< T >::TVector2D | ( | const TVector2D< T > & | v | ) |
Copy constructor.
|
noexcept |
Move constructor.
| sf::TVector2D< T >::TVector2D | ( | T | xp, |
| T | yp | ||
| ) |
Initializing constructor.
| xp | X-axis value. |
| yp | Y-axis value. |
| T sf::TVector2D< T >::angle | ( | ) | const |
Gets the angle of vector in xy-plane.
| T sf::TVector2D< T >::angle | ( | const TVector2D< T > & | ) | const |
Gets the angle between the two vectors.
| T sf::TVector2D< T >::angleNormalized | ( | ) | const |
Returns a normalized positive angle of function angle().
|
static |
Checks where 2 points lie in relation to a given line given by 2 points.
| lp1 | Point 1 as the start of a line. |
| lp2 | Point 2 as the end of a line. |
| p1 | Free point 1. |
| p2 | Free point 2. |
| TVector2D & sf::TVector2D< T >::assign | ( | const TVector2D< T > & | v | ) |
Assignment of a vector instance.
| v | Vector value. |
| TVector2D & sf::TVector2D< T >::assign | ( | T | xp, |
| T | yp | ||
| ) |
Assignment of new coordinate values.
| xp | X-axis value. |
| yp | Y-axis value. |
| T sf::TVector2D< T >::crossProduct | ( | const TVector2D< 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::TVector2D< T >::distance | ( | const TVector2D< 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::TVector2D< T >::distanceSqr | ( | const TVector2D< T > & | ) | const |
Gets the squared distance between 2 given points. Avoids taking an expensive sqrt call. Useful when comparing different distances.
| T sf::TVector2D< T >::dotProduct | ( | const TVector2D< T > & | ) | const |
Gets the dot (in) product of 2 vectors.
| TVector2D & sf::TVector2D< T >::fromString | ( | const std::string & | s, |
| bool | ignore_err = false |
||
| ) |
Gets the vector value from the string representation formed like '(1.23,4.56)'. Throws an exception when the string is not in the correct format.
| s | Formatted string to read the values from. |
| ignore_err | Determines to throw an exception or not. |
| std::invalid_argument |
| bool sf::TVector2D< T >::isEqual | ( | const TVector2D< 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::TVector2D< 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::TVector2D< T >::lengthSqr | ( | ) | const |
Gets the squared length or magnitude of the vector.
| TVector2D & sf::TVector2D< T >::normalize | ( | ) |
Normalizes the vector also called a unit-vector, set to length 1.
| TVector2D sf::TVector2D< T >::normalized | ( | ) | const |
Gets a normalized vector also called a unit-vector, made of length 1.
|
constexpr |
Cast-operator to a const pointer.
|
constexpr |
Cast-operator to a pointer.
| bool sf::TVector2D< T >::operator!= | ( | const TVector2D< T > & | ) | const |
Inequality operator.
| T sf::TVector2D< T >::operator* | ( | const TVector2D< T > & | v | ) | const |
Gets the cross (out) product of 2 vectors.
| TVector2D & sf::TVector2D< T >::operator*= | ( | const TMatrix22< T > & | mtx | ) |
Matrix transform operator.
| TVector2D & sf::TVector2D< T >::operator*= | ( | T | c | ) |
Compound multiplier operator.
| TVector2D sf::TVector2D< T >::operator+ | ( | const TVector2D< T > & | ) | const |
Addition operator.
| TVector2D & sf::TVector2D< T >::operator+= | ( | const TVector2D< T > & | ) |
Compound addition operator.
| TVector2D sf::TVector2D< T >::operator- | ( | ) | const |
Inversion math operator inverting the vector.
| TVector2D sf::TVector2D< T >::operator- | ( | const TVector2D< T > & | ) | const |
Subtraction operator.
| TVector2D & sf::TVector2D< T >::operator-= | ( | const TVector2D< T > & | ) |
Compound subtraction operator.
| TVector2D sf::TVector2D< T >::operator/ | ( | T | ) | const |
Division operator.
| TVector2D & sf::TVector2D< T >::operator/= | ( | T | ) |
Compound division operator.
|
noexcept |
Assignment operator.
|
noexcept |
Assignment move operator.
| bool sf::TVector2D< T >::operator== | ( | const TVector2D< T > & | ) | const |
Equality operator.
| T & sf::TVector2D< T >::operator[] | ( | size_t | ) |
Access like an array.
| std::out_of_range |
| const T & sf::TVector2D< T >::operator[] | ( | size_t | ) | const |
Access like a const array.
| std::out_of_range |
| TVector2D & sf::TVector2D< T >::scale | ( | T | factor | ) |
Scales the vector by multiplying all axes with the passed factor.
| TVector2D sf::TVector2D< T >::scaled | ( | T | factor | ) | const |
Scales the vector by multiplying all axes with the passed factor.
| T sf::TVector2D< T >::slope | ( | ) | const |
Gets the slope (coefficient) of the line formed with the origin (0, 0). When it is an infinite value +/- std::numeric_limits<T>::infinity() is returned.
| std::string sf::TVector2D< T >::toString | ( | ) | const |
Gets the string representation of the 2D vector formed like '(1.23,4.56)'.
| void sf::TVector2D< T >::updateMax | ( | const TVector2D< T > & | vertex | ) |
Copy only those values of x or y which are larger.
| vertex |
| void sf::TVector2D< T >::updateMin | ( | const TVector2D< T > & | vertex | ) |
Copy only those values of x or y which are smaller.
| vertex |
|
constexpr |
Gets the x-coordinate value as a reference.
|
constexpr |
Gets the x-coordinate value.
|
constexpr |
Gets the y-coordinate value as a reference.
|
constexpr |
Gets the y-coordinate value.
|
protected |
|
staticconstexpr |
Tolerance for when comparing in the equal operator. Empirical chosen epsilon multiplier to make it work. Used in: sf::isEqual()
|
protected |