9 #ifndef CUBBYFLOW_POINT3_H 10 #define CUBBYFLOW_POINT3_H 29 static_assert(std::is_arithmetic<T>::value,
"Point only can be instantiated with arithmatic types");
42 constexpr
Point() : x(0), y(0), z(0)
48 constexpr
Point(T _x, T _y, T _z) : x(_x), y(_y), z(_z)
61 Point(
const std::initializer_list<U>& list);
64 constexpr
Point(
const Point& pt) : x(pt.x), y(pt.y), z(pt.z)
74 void Set(T x, T y, T z);
81 void Set(
const std::initializer_list<U>& list);
103 Point Mul(T v)
const;
109 Point Div(T v)
const;
116 Point RAdd(T v)
const;
122 Point RSub(T v)
const;
128 Point RMul(T v)
const;
134 Point RDiv(T v)
const;
144 void IAdd(
const Point& v);
150 void ISub(
const Point& v);
156 void IMul(
const Point& v);
162 void IDiv(
const Point& v);
166 const T& At(
size_t i)
const;
187 size_t DominantAxis()
const;
190 size_t SubdominantAxis()
const;
193 template <
typename U>
197 bool IsEqual(
const Point& other)
const;
213 Point& operator+=(T v);
219 Point& operator-=(T v);
225 Point& operator*=(T v);
231 Point& operator/=(T v);
237 bool operator==(
const Point& v)
const;
240 bool operator!=(
const Point& v)
const;
244 template <
typename T>
245 Point<T, 3>
operator+(
const Point<T, 3>& a);
248 template <
typename T>
249 Point<T, 3>
operator-(
const Point<T, 3>& a);
252 template <
typename T>
253 Point<T, 3>
operator+(T a,
const Point<T, 3>& b);
256 template <
typename T>
257 Point<T, 3>
operator+(
const Point<T, 3>& a,
const Point<T, 3>& b);
260 template <
typename T>
261 Point<T, 3>
operator-(
const Point<T, 3>& a, T b);
264 template <
typename T>
265 Point<T, 3>
operator-(T a,
const Point<T, 3>& b);
268 template <
typename T>
269 Point<T, 3>
operator-(
const Point<T, 3>& a,
const Point<T, 3>& b);
272 template <
typename T>
273 Point<T, 3>
operator*(
const Point<T, 3>& a, T b);
276 template <
typename T>
277 Point<T, 3>
operator*(T a,
const Point<T, 3>& b);
280 template <
typename T>
281 Point<T, 3>
operator*(
const Point<T, 3>& a,
const Point<T, 3>& b);
284 template <
typename T>
285 Point<T, 3>
operator/(
const Point<T, 3>& a, T b);
288 template <
typename T>
289 Point<T, 3>
operator/(T a,
const Point<T, 3>& b);
292 template <
typename T>
293 Point<T, 3>
operator/(
const Point<T, 3>& a,
const Point<T, 3>& b);
296 template <
typename T>
297 Point<T, 3>
Min(
const Point<T, 3>& a,
const Point<T, 3>& b);
300 template <
typename T>
301 Point<T, 3>
Max(
const Point<T, 3>& a,
const Point<T, 3>& b);
304 template <
typename T>
305 Point<T, 3>
Clamp(
const Point<T, 3>& v,
const Point<T, 3>& low,
const Point<T, 3>& high);
308 template <
typename T>
309 Point<T, 3>
Ceil(
const Point<T, 3>& a);
312 template <
typename T>
313 Point<T, 3>
Floor(
const Point<T, 3>& 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
constexpr Point(T _x, T _y, T _z)
Constructs point with given parameters _x, _y, and _z.
Definition: Point3.h:48
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
3-D point class.
Definition: Point3.h:26
constexpr Point(const Point &pt)
Copy constructor.
Definition: Point3.h:64
Point< T, 2 > Floor(const Point< T, 2 > &a)
Returns element-wise floored point.
Definition: Point2-Impl.h:498
constexpr Point(const Point2< T > &pt, T _z)
Constructs point with a 2-D point and a scalar.
Definition: Point3.h:54
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.
T z
Z (or the third) component of the point.
Definition: Point3.h:38
T y
Y (or the second) component of the point.
Definition: Point3.h:35
Matrix< T, 2, 2 > operator-(const Matrix< T, 2, 2 > &a)
Returns a matrix with opposite sign.
Definition: Matrix2x2-Impl.h:654
T x
X (or the first) component of the point.
Definition: Point3.h:29
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
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()
Constructs default point (0, 0, 0).
Definition: Point3.h:42