Go to the documentation of this file.
7 #ifndef INCLUDE_JET_POINT2_H_
8 #define INCLUDE_JET_POINT2_H_
25 static_assert(std::is_arithmetic<T>::value,
26 "Point only can be instantiated with arithmetic types");
37 constexpr
Point() : x(0), y(0) {}
40 constexpr
Point(T x_, T y_) : x(x_), y(y_) {}
44 Point(
const std::initializer_list<U>& lst);
59 void set(
const std::initializer_list<U>& lst);
136 const T&
at(
size_t i)
const;
163 template <
typename U>
215 template <
typename T>
219 template <
typename T>
223 template <
typename T>
227 template <
typename T>
231 template <
typename T>
235 template <
typename T>
239 template <
typename T>
243 template <
typename T>
247 template <
typename T>
251 template <
typename T>
255 template <
typename T>
259 template <
typename T>
263 template <
typename T>
267 template <
typename T>
271 template <
typename T>
275 template <
typename T>
279 template <
typename T>
284 template <
typename T>
288 template <
typename T>
305 #include "detail/point2-inl.h"
307 #endif // INCLUDE_JET_POINT2_H_
2-D point class.
Definition: point2.h:23
T x
X (or the first) component of the point.
Definition: point2.h:26
void iadd(const Point &v)
Computes this += (v.x, v.y).
Point2< T > ceil(const Point2< T > &a)
Returns element-wise ceiled point.
Point sub(const Point &v) const
Computes this - (v.x, v.y).
Point2< ssize_t > Point2I
Integer-type 2D point.
Definition: point2.h:298
void set(T s)
Set both x and y components to s.
Point mul(const Point &v) const
Computes this * (v.x, v.y).
T absmax() const
Returns the absolute maximum value among x and y.
Point & operator=(const std::initializer_list< T > &lst)
Set x and y components with given initializer list.
Point & operator*=(const Point &v)
Computes this *= (v.x, v.y)
Point rsub(T v) const
Computes (v, v) - this.
Point & operator+=(T v)
Computes this += (v, v)
T absmin() const
Returns the absolute minimum value among x and y.
Point2< T > max(const Point2< T > &a, const Point2< T > &b)
Returns element-wise max point: (max(a.x, b.x), max(a.y, b.y)).
Point add(T v) const
Computes this + (v, v).
void set(const Point &pt)
Set x and y with other point pt.
void iadd(T v)
Computes this += (v, v).
Point & operator-=(T v)
Computes this -= (v, v)
T y
Y (or the second) component of the point.
Definition: point2.h:32
bool isEqual(const Point &other) const
Returns true if other is the same as this point.
Point div(T v) const
Computes this / (v, v).
T & at(size_t i)
Returns reference to the i -th element of the point.
void set(const std::initializer_list< U > &lst)
Set x and y components with given initializer list.
Point add(const Point &v) const
Computes this + (v.x, v.y).
Point & operator+=(const Point &v)
Computes this += (v.x, v.y)
const T & operator[](size_t i) const
Returns const reference to the i -th element of the point.
constexpr Point()
Constructs default point (0, 0).
Definition: point2.h:37
size_t subminantAxis() const
Returns the index of the subminant axis.
T min() const
Returns the minimum value among x and y.
Definition: advection_solver2.h:18
T sum() const
Returns the sum of all the components (i.e. x + y).
T & operator[](size_t i)
Returns reference to the i -th element of the point.
Point2< double > Point2D
Double-type 2D point.
Definition: point2.h:295
constexpr Point(T x_, T y_)
Constructs point with given parameters x_ and y_.
Definition: point2.h:40
T clamp(T val, T low, T high)
Returns the clamped value.
void idiv(const Point &v)
Computes this /= (v.x, v.y).
Matrix2x2< T > operator+(const Matrix2x2< T > &a, const Matrix2x2< T > &b)
Returns a + b (element-size).
Point2< T > floor(const Point2< T > &a)
Returns element-wise floored point.
T max() const
Returns the maximum value among x and y.
void imul(T v)
Computes this *= (v, v).
void idiv(T v)
Computes this /= (v, v).
Point2< float > Point2F
Float-type 2D point.
Definition: point2.h:292
Point & operator/=(T v)
Computes this /= (v, v)
void imul(const Point &v)
Computes this *= (v.x, v.y).
Point(const std::initializer_list< U > &lst)
Constructs point with initializer list.
Point2< size_t > Point2UI
Unsigned integer-type 2D point.
Definition: point2.h:301
size_t dominantAxis() const
Returns the index of the dominant axis.
bool operator!=(const Point &v) const
Returns true if other is the not same as this point.
constexpr Point(const Point &v)
Copy constructor.
Definition: point2.h:47
Point & operator=(const Point &v)
Set x and y with other point pt.
Generic N-D point class.
Definition: point.h:23
Matrix2x2< T > operator/(const Matrix2x2< T > &a, T b)
Returns a' / b, where every element of matrix a' is a.
Point & operator-=(const Point &v)
Computes this -= (v.x, v.y)
Point2< T > min(const Point2< T > &a, const Point2< T > &b)
Returns element-wise min point: (min(a.x, b.x), min(a.y, b.y)).
Point & operator*=(T v)
Computes this *= (v, v)
Point rdiv(T v) const
Computes (v, v) / this.
Point div(const Point &v) const
Computes this / (v.x, v.y).
Matrix2x2< T > operator-(const Matrix2x2< T > &a)
Returns a matrix with opposite sign.
void set(T x, T y)
Set x and y components with given parameters.
Point rdiv(const Point &v) const
Computes (v.x, v.y) / this.
Point mul(T v) const
Computes this * (v, v).
Matrix2x2< T > operator*(const Matrix2x2< T > &a, T b)
Returns a * b', where every element of matrix b' is b.
Point rsub(const Point &v) const
Computes (v.x, v.y) - this.
Point & operator/=(const Point &v)
Computes this /= (v.x, v.y)
bool operator==(const Point &v) const
Returns true if other is the same as this point.
void setZero()
Set both x and y to zero.
Point sub(T v) const
Computes this - (v, v).
void isub(const Point &v)
Computes this -= (v.x, v.y).
const T & at(size_t i) const
Returns const reference to the i -th element of the point.
Point< U, 2 > castTo() const
Returns a point with different value type.
void isub(T v)
Computes this -= (v, v).