9 #ifndef CUBBYFLOW_POINT2_H 10 #define CUBBYFLOW_POINT2_H 28 static_assert(std::is_arithmetic<T>::value,
"Point only can be instantiated with arithmetic types");
44 constexpr
Point(T _x, T _y) : x(_x), y(_y)
51 Point(
const std::initializer_list<U>& list);
68 void Set(
const std::initializer_list<U>& list);
103 Point RAdd(T v)
const;
109 Point RSub(T v)
const;
115 Point RMul(T v)
const;
121 Point RDiv(T v)
const;
131 void IAdd(
const Point& v);
137 void ISub(
const Point& v);
143 void IMul(
const Point& v);
149 void IDiv(
const Point& v);
153 const T& At(
size_t i)
const;
174 size_t DominantAxis()
const;
177 size_t SubdominantAxis()
const;
180 template <
typename U>
184 bool IsEqual(
const Point& other)
const;
200 Point& operator+=(T v);
206 Point& operator-=(T v);
212 Point& operator*=(T v);
218 Point& operator/=(T v);
224 bool operator==(
const Point& v)
const;
227 bool operator!=(
const Point& v)
const;
231 template <
typename T>
232 Point<T, 2>
operator+(
const Point<T, 2>& a);
235 template <
typename T>
236 Point<T, 2>
operator-(
const Point<T, 2>& a);
239 template <
typename T>
240 Point<T, 2>
operator+(T a,
const Point<T, 2>& b);
243 template <
typename T>
244 Point<T, 2>
operator+(
const Point<T, 2>& a,
const Point<T, 2>& b);
247 template <
typename T>
248 Point<T, 2>
operator-(
const Point<T, 2>& a, T b);
251 template <
typename T>
252 Point<T, 2>
operator-(T a,
const Point<T, 2>& b);
255 template <
typename T>
256 Point<T, 2>
operator-(
const Point<T, 2>& a,
const Point<T, 2>& b);
259 template <
typename T>
260 Point<T, 2>
operator*(
const Point<T, 2>& a, T b);
263 template <
typename T>
264 Point<T, 2>
operator*(T a,
const Point<T, 2>& b);
267 template <
typename T>
268 Point<T, 2>
operator*(
const Point<T, 2>& a,
const Point<T, 2>& b);
271 template <
typename T>
272 Point<T, 2>
operator/(
const Point<T, 2>& a, T b);
275 template <
typename T>
276 Point<T, 2>
operator/(T a,
const Point<T, 2>& b);
279 template <
typename T>
280 Point<T, 2>
operator/(
const Point<T, 2>& a,
const Point<T, 2>& b);
283 template <
typename T>
284 Point<T, 2>
Min(
const Point<T, 2>& a,
const Point<T, 2>& b);
287 template <
typename T>
288 Point<T, 2>
Max(
const Point<T, 2>& a,
const Point<T, 2>& b);
291 template <
typename T>
292 Point<T, 2>
Clamp(
const Point<T, 2>& v,
const Point<T, 2>& low,
const Point<T, 2>& high);
295 template <
typename T>
296 Point<T, 2>
Ceil(
const Point<T, 2>& a);
299 template <
typename T>
300 Point<T, 2>
Floor(
const Point<T, 2>& a);
T AbsMin(T x, T y)
Returns the absolute minimum value among the two inputs.
Definition: MathUtils-Impl.h:39
Point< T, 2 > Ceil(const Point< T, 2 > &a)
Returns element-wise ceiled point.
Definition: Point2-Impl.h:492
Matrix< T, 2, 2 > operator+(const Matrix< T, 2, 2 > &a, const Matrix< T, 2, 2 > &b)
Returns a + b (element-size).
Definition: Matrix2x2-Impl.h:660
T x
X (or the first) component of the point.
Definition: Point2.h:28
void Set(const std::initializer_list< U > &list)
Set point instance with initializer list.
Definition: Point-Impl.h:57
2-D point class.
Definition: Point2.h:25
T y
Y (or the second) component of the point.
Definition: Point2.h:34
constexpr Point()
Constructs default point (0, 0).
Definition: Point2.h:38
Point< T, 2 > Floor(const Point< T, 2 > &a)
Returns element-wise floored point.
Definition: Point2-Impl.h:498
Generic N-D point class.
Definition: Point.h:24
Matrix< T, 2, 2 > operator/(const Matrix< T, 2, 2 > &a, T b)
Definition: Matrix2x2-Impl.h:720
Definition: pybind11Utils.h:24
T Clamp(T val, T low, T high)
Returns the clamped value.
Definition: MathUtils-Impl.h:123
Point & operator=(const std::initializer_list< U > &list)
Set point instance with initializer list.
Matrix< T, 2, 2 > operator-(const Matrix< T, 2, 2 > &a)
Returns a matrix with opposite sign.
Definition: Matrix2x2-Impl.h:654
Point< T, 2 > Max(const Point< T, 2 > &a, const Point< T, 2 > &b)
Returns element-wise max point: (max(a.x, b.x), max(a.y, b.y)).
Definition: Point2-Impl.h:480
const T & operator[](size_t i) const
Returns the const reference to the i -th element.
Definition: Point-Impl.h:91
Vector< T, 3 > operator*(const Quaternion< T > &q, const Vector< T, 3 > &v)
Returns quaternion q * vector v.
Definition: Quaternion-Impl.h:481
T AbsMax(T x, T y)
Returns the absolute maximum value among the two inputs.
Definition: MathUtils-Impl.h:45
constexpr Point(const Point &pt)
Copy constructor.
Definition: Point2.h:54
Point()
Constructs a point with zeros.
Definition: Point-Impl.h:17
Point< T, 2 > Min(const Point< T, 2 > &a, const Point< T, 2 > &b)
Returns element-wise min point: (min(a.x, b.x), min(a.y, b.y)).
Definition: Point2-Impl.h:474
constexpr Point(T _x, T _y)
Constructs point with given parameters _x and _y.
Definition: Point2.h:44