20 template <
class T,
class ENABLE =
void>
62 template <std::
size_t N>
65 static_assert(N == 3,
"CVB: Point3D must have 3 elements");
66 std::copy(std::begin(list), std::end(list), &x_);
136 return sqrt(x_ * x_ + y_ * y_ + z_ * z_);
147 return (x_ == other.x_ && y_ == other.y_ && z_ == other.z_);
158 return !(*
this == other);
166 return Point3D<C>(
static_cast<C
>(
X()),
static_cast<C
>(
Y()),
static_cast<C
>(
Z()));
233 assert(index < 3 && index >= 0);
234 return *(&x_ + index);
245 assert(index < 3 && index >= 0);
246 return *(&x_ + index);
250 T x_ =
static_cast<T
>(0.0);
251 T y_ =
static_cast<T
>(0.0);
252 T z_ =
static_cast<T
>(0.0);
297 return lhs.
X() * rhs.
X() + lhs.
Y() * rhs.
Y() + lhs.
Z() * rhs.
Z();
312 return Point3D<T>(lhs.
X() * rhs, lhs.
Y() * rhs, lhs.
Z() * rhs);
342 return Point3D<T>(lhs.
X() / rhs, lhs.
Y() / rhs, lhs.
Z() / rhs);
357 return Point3D<int>(
static_cast<int>(std::round(rhs.X())),
static_cast<int>(std::round(rhs.Y())),
358 static_cast<int>(std::round(rhs.Z())));
Multi-purpose 3D vector class.
Definition: point_3d.hpp:22
const T & operator[](int index) const noexcept
Index based element access.
Definition: point_3d.hpp:231
T X() const noexcept
Get the x component of the point.
Definition: point_3d.hpp:74
bool operator!=(const Point3D< T > &other) const noexcept
Compares to an other point.
Definition: point_3d.hpp:156
T Y() const noexcept
Get the y component of the point.
Definition: point_3d.hpp:94
void SetX(T x) noexcept
Set the x component of the point.
Definition: point_3d.hpp:84
Point3D< T > operator/(const Point3D< T > &lhs, const T &rhs)
Divide point by scalar.
Definition: point_3d.hpp:340
void SetY(T y)
Set the y component of the point.
Definition: point_3d.hpp:104
Point3D< T > operator*(const Point3D< T > &lhs, const T &rhs)
Multiply point with scalar.
Definition: point_3d.hpp:310
T Z() const noexcept
Get the z component of the point.
Definition: point_3d.hpp:114
Point3D< T > & operator+=(const Point3D< T > &point) noexcept
Adds and assigns to this point.
Definition: point_3d.hpp:175
Point3D< T > & operator-=(const Point3D< T > &point) noexcept
Subtracts and assigns to this point.
Definition: point_3d.hpp:189
bool operator==(const Point3D< T > &other) const noexcept
Compares to an other point.
Definition: point_3d.hpp:145
Point3D< T > operator*(const T &lhs, const Point3D< T > &rhs)
Multiply scalar with point.
Definition: point_3d.hpp:325
Point3D(const T(&list)[N]) noexcept
Construct a point with an initializer list.
Definition: point_3d.hpp:63
T Length() const noexcept
Gets the length of this point.
Definition: point_3d.hpp:134
Point3D< T > operator-(const Point3D< T > &lhs, const Point3D< T > &rhs)
Subtracts two points.
Definition: point_3d.hpp:280
Point3D< T > & operator*=(const T &value) noexcept
Multiplies by a scalar and assigns to this point.
Definition: point_3d.hpp:203
T operator*(const Point3D< T > &lhs, const Point3D< T > &rhs)
Inner product of two point vectors.
Definition: point_3d.hpp:295
Point3D< T > operator+(const Point3D< T > &lhs, const Point3D< T > &rhs)
Add two points.
Definition: point_3d.hpp:265
Point3D< T > & operator/=(const T &value) noexcept
Divide by a scalar and assigns to this point.
Definition: point_3d.hpp:217
T & operator[](int index) noexcept
Index based element access.
Definition: point_3d.hpp:243
Point3D() noexcept=default
Creates a default point at (0, 0).
void SetZ(T z)
Set the z component of the point.
Definition: point_3d.hpp:124
Root namespace for the Image Manager interface.
Definition: c_barcode.h:15
Point2D< int > Round(const Point2D< T > &rhs) noexcept
Round to an integer point.
Definition: point_2d.hpp:371