Jet
v1.3.3
|
2-D point class. More...
#include <jet/point2.h>
Public Member Functions | |
constexpr | Point () |
Constructs default point (0, 0). More... | |
constexpr | Point (T x_, T y_) |
Constructs point with given parameters x_ and y_ . More... | |
template<typename U > | |
Point (const std::initializer_list< U > &lst) | |
Constructs point with initializer list. More... | |
constexpr | Point (const Point &v) |
Copy constructor. More... | |
void | set (T s) |
Set both x and y components to s . More... | |
void | set (T x, T y) |
Set x and y components with given parameters. More... | |
template<typename U > | |
void | set (const std::initializer_list< U > &lst) |
Set x and y components with given initializer list. More... | |
void | set (const Point &pt) |
Set x and y with other point pt . More... | |
void | setZero () |
Set both x and y to zero. More... | |
Point | add (T v) const |
Computes this + (v, v). More... | |
Point | add (const Point &v) const |
Computes this + (v.x, v.y). More... | |
Point | sub (T v) const |
Computes this - (v, v). More... | |
Point | sub (const Point &v) const |
Computes this - (v.x, v.y). More... | |
Point | mul (T v) const |
Computes this * (v, v). More... | |
Point | mul (const Point &v) const |
Computes this * (v.x, v.y). More... | |
Point | div (T v) const |
Computes this / (v, v). More... | |
Point | div (const Point &v) const |
Computes this / (v.x, v.y). More... | |
Point | rsub (T v) const |
Computes (v, v) - this. More... | |
Point | rsub (const Point &v) const |
Computes (v.x, v.y) - this. More... | |
Point | rdiv (T v) const |
Computes (v, v) / this. More... | |
Point | rdiv (const Point &v) const |
Computes (v.x, v.y) / this. More... | |
void | iadd (T v) |
Computes this += (v, v). More... | |
void | iadd (const Point &v) |
Computes this += (v.x, v.y). More... | |
void | isub (T v) |
Computes this -= (v, v). More... | |
void | isub (const Point &v) |
Computes this -= (v.x, v.y). More... | |
void | imul (T v) |
Computes this *= (v, v). More... | |
void | imul (const Point &v) |
Computes this *= (v.x, v.y). More... | |
void | idiv (T v) |
Computes this /= (v, v). More... | |
void | idiv (const Point &v) |
Computes this /= (v.x, v.y). More... | |
const T & | at (size_t i) const |
Returns const reference to the i -th element of the point. More... | |
T & | at (size_t i) |
Returns reference to the i -th element of the point. More... | |
T | sum () const |
Returns the sum of all the components (i.e. x + y). More... | |
T | min () const |
Returns the minimum value among x and y. More... | |
T | max () const |
Returns the maximum value among x and y. More... | |
T | absmin () const |
Returns the absolute minimum value among x and y. More... | |
T | absmax () const |
Returns the absolute maximum value among x and y. More... | |
size_t | dominantAxis () const |
Returns the index of the dominant axis. More... | |
size_t | subminantAxis () const |
Returns the index of the subminant axis. More... | |
template<typename U > | |
Point< U, 2 > | castTo () const |
Returns a point with different value type. More... | |
bool | isEqual (const Point &other) const |
Returns true if other is the same as this point. More... | |
T & | operator[] (size_t i) |
Returns reference to the i -th element of the point. More... | |
const T & | operator[] (size_t i) const |
Returns const reference to the i -th element of the point. More... | |
Point & | operator= (const std::initializer_list< T > &lst) |
Set x and y components with given initializer list. More... | |
Point & | operator= (const Point &v) |
Set x and y with other point pt . More... | |
Point & | operator+= (T v) |
Computes this += (v, v) More... | |
Point & | operator+= (const Point &v) |
Computes this += (v.x, v.y) More... | |
Point & | operator-= (T v) |
Computes this -= (v, v) More... | |
Point & | operator-= (const Point &v) |
Computes this -= (v.x, v.y) More... | |
Point & | operator*= (T v) |
Computes this *= (v, v) More... | |
Point & | operator*= (const Point &v) |
Computes this *= (v.x, v.y) More... | |
Point & | operator/= (T v) |
Computes this /= (v, v) More... | |
Point & | operator/= (const Point &v) |
Computes this /= (v.x, v.y) More... | |
bool | operator== (const Point &v) const |
Returns true if other is the same as this point. More... | |
bool | operator!= (const Point &v) const |
Returns true if other is the not same as this point. More... | |
Public Attributes | |
T | x |
X (or the first) component of the point. More... | |
T | y |
Y (or the second) component of the point. More... | |
2-D point class.
This class defines simple 2-D point data.
T | - Type of the element |
|
inlineconstexpr |
Constructs default point (0, 0).
|
inlineconstexpr |
Constructs point with given parameters x_
and y_
.
jet::Point< T, 2 >::Point | ( | const std::initializer_list< U > & | lst | ) |
Constructs point with initializer list.
|
inlineconstexpr |
Copy constructor.
T jet::Point< T, 2 >::absmax | ( | ) | const |
Returns the absolute maximum value among x and y.
T jet::Point< T, 2 >::absmin | ( | ) | const |
Returns the absolute minimum value among x and y.
Point jet::Point< T, 2 >::add | ( | const Point< T, 2 > & | v | ) | const |
Computes this + (v.x, v.y).
Point jet::Point< T, 2 >::add | ( | T | v | ) | const |
Computes this + (v, v).
T& jet::Point< T, 2 >::at | ( | size_t | i | ) |
Returns reference to the i
-th element of the point.
const T& jet::Point< T, 2 >::at | ( | size_t | i | ) | const |
Returns const reference to the i
-th element of the point.
Returns a point with different value type.
Point jet::Point< T, 2 >::div | ( | const Point< T, 2 > & | v | ) | const |
Computes this / (v.x, v.y).
Point jet::Point< T, 2 >::div | ( | T | v | ) | const |
Computes this / (v, v).
size_t jet::Point< T, 2 >::dominantAxis | ( | ) | const |
Returns the index of the dominant axis.
void jet::Point< T, 2 >::iadd | ( | const Point< T, 2 > & | v | ) |
Computes this += (v.x, v.y).
void jet::Point< T, 2 >::iadd | ( | T | v | ) |
Computes this += (v, v).
void jet::Point< T, 2 >::idiv | ( | const Point< T, 2 > & | v | ) |
Computes this /= (v.x, v.y).
void jet::Point< T, 2 >::idiv | ( | T | v | ) |
Computes this /= (v, v).
void jet::Point< T, 2 >::imul | ( | const Point< T, 2 > & | v | ) |
Computes this *= (v.x, v.y).
void jet::Point< T, 2 >::imul | ( | T | v | ) |
Computes this *= (v, v).
bool jet::Point< T, 2 >::isEqual | ( | const Point< T, 2 > & | other | ) | const |
Returns true if other
is the same as this point.
void jet::Point< T, 2 >::isub | ( | const Point< T, 2 > & | v | ) |
Computes this -= (v.x, v.y).
void jet::Point< T, 2 >::isub | ( | T | v | ) |
Computes this -= (v, v).
T jet::Point< T, 2 >::max | ( | ) | const |
Returns the maximum value among x and y.
T jet::Point< T, 2 >::min | ( | ) | const |
Returns the minimum value among x and y.
Point jet::Point< T, 2 >::mul | ( | const Point< T, 2 > & | v | ) | const |
Computes this * (v.x, v.y).
Point jet::Point< T, 2 >::mul | ( | T | v | ) | const |
Computes this * (v, v).
bool jet::Point< T, 2 >::operator!= | ( | const Point< T, 2 > & | v | ) | const |
Returns true if other
is the not same as this point.
Point& jet::Point< T, 2 >::operator*= | ( | const Point< T, 2 > & | v | ) |
Computes this *= (v.x, v.y)
Point& jet::Point< T, 2 >::operator*= | ( | T | v | ) |
Computes this *= (v, v)
Point& jet::Point< T, 2 >::operator+= | ( | const Point< T, 2 > & | v | ) |
Computes this += (v.x, v.y)
Point& jet::Point< T, 2 >::operator+= | ( | T | v | ) |
Computes this += (v, v)
Point& jet::Point< T, 2 >::operator-= | ( | const Point< T, 2 > & | v | ) |
Computes this -= (v.x, v.y)
Point& jet::Point< T, 2 >::operator-= | ( | T | v | ) |
Computes this -= (v, v)
Point& jet::Point< T, 2 >::operator/= | ( | const Point< T, 2 > & | v | ) |
Computes this /= (v.x, v.y)
Point& jet::Point< T, 2 >::operator/= | ( | T | v | ) |
Computes this /= (v, v)
Point& jet::Point< T, 2 >::operator= | ( | const Point< T, 2 > & | v | ) |
Set x and y with other point pt
.
Point& jet::Point< T, 2 >::operator= | ( | const std::initializer_list< T > & | lst | ) |
Set x and y components with given initializer list.
bool jet::Point< T, 2 >::operator== | ( | const Point< T, 2 > & | v | ) | const |
Returns true if other
is the same as this point.
T& jet::Point< T, 2 >::operator[] | ( | size_t | i | ) |
Returns reference to the i
-th element of the point.
const T& jet::Point< T, 2 >::operator[] | ( | size_t | i | ) | const |
Returns const reference to the i
-th element of the point.
Point jet::Point< T, 2 >::rdiv | ( | const Point< T, 2 > & | v | ) | const |
Computes (v.x, v.y) / this.
Point jet::Point< T, 2 >::rdiv | ( | T | v | ) | const |
Computes (v, v) / this.
Point jet::Point< T, 2 >::rsub | ( | const Point< T, 2 > & | v | ) | const |
Computes (v.x, v.y) - this.
Point jet::Point< T, 2 >::rsub | ( | T | v | ) | const |
Computes (v, v) - this.
void jet::Point< T, 2 >::set | ( | const Point< T, 2 > & | pt | ) |
Set x and y with other point pt
.
void jet::Point< T, 2 >::set | ( | const std::initializer_list< U > & | lst | ) |
Set x and y components with given initializer list.
void jet::Point< T, 2 >::set | ( | T | s | ) |
Set both x and y components to s
.
void jet::Point< T, 2 >::set | ( | T | x, |
T | y | ||
) |
Set x and y components with given parameters.
void jet::Point< T, 2 >::setZero | ( | ) |
Set both x and y to zero.
Point jet::Point< T, 2 >::sub | ( | const Point< T, 2 > & | v | ) | const |
Computes this - (v.x, v.y).
Point jet::Point< T, 2 >::sub | ( | T | v | ) | const |
Computes this - (v, v).
size_t jet::Point< T, 2 >::subminantAxis | ( | ) | const |
Returns the index of the subminant axis.
T jet::Point< T, 2 >::sum | ( | ) | const |
Returns the sum of all the components (i.e. x + y).
T jet::Point< T, 2 >::x |
X (or the first) component of the point.
T jet::Point< T, 2 >::y |
Y (or the second) component of the point.