9 #ifndef CUBBYFLOW_POINT3_IMPL_H 10 #define CUBBYFLOW_POINT3_IMPL_H 56 assert(list.size() >= 3);
58 auto inputElem = list.begin();
59 x =
static_cast<T
>(*inputElem);
60 y =
static_cast<T
>(*(++inputElem));
61 z =
static_cast<T
>(*(++inputElem));
82 return Point(x + v, y + v, z + v);
88 return Point(x + v.x, y + v.y, z + v.z);
94 return Point(x - v, y - v, z - v);
100 return Point(x - v.x, y - v.y, z - v.z);
103 template <
typename T>
106 return Point(x * v, y * v, z * v);
109 template <
typename T>
112 return Point(x * v.x, y * v.y, z * v.z);
115 template <
typename T>
118 return Point(x / v, y / v, z / v);
121 template <
typename T>
124 return Point(x / v.x, y / v.y, z / v.z);
128 template <
typename T>
131 return Point(v + x, v + y, v + z);
134 template <
typename T>
137 return Point(v.x + x, v.y + y, v.z + z);
140 template <
typename T>
143 return Point(v - x, v - y, v - z);
146 template <
typename T>
149 return Point(v.x - x, v.y - y, v.z - z);
152 template <
typename T>
155 return Point(v * x, v * y, v * z);
158 template <
typename T>
161 return Point(v.x * x, v.y * y, v.z * z);
164 template <
typename T>
167 return Point(v / x, v / y, v / z);
170 template <
typename T>
173 return Point(v.x / x, v.y / y, v.z / z);
177 template <
typename T>
184 template <
typename T>
192 template <
typename T>
200 template <
typename T>
208 template <
typename T>
216 template <
typename T>
224 template <
typename T>
232 template <
typename T>
241 template <
typename T>
248 template <
typename T>
255 template <
typename T>
261 template <
typename T>
264 return std::min(std::min(x, y), z);
267 template <
typename T>
270 return std::max(std::max(x, y), z);
273 template <
typename T>
279 template <
typename T>
285 template <
typename T>
288 return (std::fabs(x) > std::fabs(y))
289 ? ((std::fabs(x) > std::fabs(z)) ? 0 : 2)
290 : ((std::fabs(y) > std::fabs(z)) ? 1 : 2);
293 template <
typename T>
296 return (std::fabs(x) < std::fabs(y))
297 ? ((std::fabs(x) < std::fabs(z)) ? 0 : 2)
298 : ((std::fabs(y) < std::fabs(z)) ? 1 : 2);
301 template <
typename T>
302 template <
typename U>
305 return Point3<U>(
static_cast<U
>(x), static_cast<U>(y),
static_cast<U
>(z));
308 template <
typename T>
311 return (x == other.x && y == other.y && z == other.z);
315 template <
typename T>
322 template <
typename T>
329 template <
typename T>
336 template <
typename T>
343 template <
typename T>
350 template <
typename T>
357 template <
typename T>
364 template <
typename T>
371 template <
typename T>
378 template <
typename T>
385 template <
typename T>
392 template <
typename T>
399 template <
typename T>
405 template <
typename T>
412 template <
typename T>
418 template <
typename T>
424 template <
typename T>
430 template <
typename T>
436 template <
typename T>
442 template <
typename T>
448 template <
typename T>
454 template <
typename T>
460 template <
typename T>
466 template <
typename T>
472 template <
typename T>
478 template <
typename T>
484 template <
typename T>
490 template <
typename T>
496 template <
typename T>
502 template <
typename T>
508 template <
typename T>
514 template <
typename T>
517 return Point<T, 3>(std::ceil(a.
x), std::ceil(a.
y), std::ceil(a.
z));
520 template <
typename T>
523 return Point<T, 3>(std::floor(a.
x), std::floor(a.
y), std::floor(a.
z));
T AbsMin(T x, T y)
Returns the absolute minimum value among the two inputs.
Definition: MathUtils-Impl.h:39
Point RDiv(T v) const
Computes (v, v, v) / this.
Definition: Point3-Impl.h:165
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
Point Div(T v) const
Computes this / (v, v, v).
Definition: Point3-Impl.h:116
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
Point Mul(T v) const
Computes this * (v, v, v).
Definition: Point3-Impl.h:104
T y
Y (or the second) component of the point.
Definition: Point2.h:34
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
Point RMul(T v) const
Computes (v, v, v) * this.
Definition: Point3-Impl.h:153
Point Add(T v) const
Computes this + (v, v, v).
Definition: Point3-Impl.h:80
T Clamp(T val, T low, T high)
Returns the clamped value.
Definition: MathUtils-Impl.h:123
Point< T, 3 > Min(const Point< T, 3 > &a, const Point< T, 3 > &b)
Returns element-wise min point.
Definition: Point3-Impl.h:497
Point & operator=(const std::initializer_list< U > &list)
Set point instance with initializer list.
Point Sub(T v) const
Computes this - (v, v, v).
Definition: Point3-Impl.h:92
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
Point RAdd(T v) const
Computes (v, v, v) + this.
Definition: Point3-Impl.h:129
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< T, 3 > Max(const Point< T, 3 > &a, const Point< T, 3 > &b)
Returns element-wise max point.
Definition: Point3-Impl.h:503
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
Point RSub(T v) const
Computes (v, v, v) - this.
Definition: Point3-Impl.h:141