15#pragma pack ( push, 4 )
20template<
class T,
class ENABLE =
void>
67 template<std::
size_t N>
70 static_assert(N == 3,
"CVB: Point3D must have 3 elements");
71 std::copy(std::begin(list), std::end(list), &x_);
142 return sqrt(x_ * x_ + y_ * y_ + z_ * z_);
155 return (x_ == other.x_ && y_ == other.y_ && z_ == other.z_);
167 return !(*
this == other);
175 return Point3D<C>(
static_cast<C
>(
X()),
static_cast<C
>(
Y()),
static_cast<C
>(
Z()));
243 assert(index < 3 && index >= 0);
244 return *(&x_ + index);
255 assert(index < 3 && index >= 0);
256 return *(&x_ + index);
261 T x_ =
static_cast<T
>(0.0);
262 T y_ =
static_cast<T
>(0.0);
263 T z_ =
static_cast<T
>(0.0);
310 return lhs.
X() * rhs.
X() + lhs.
Y() * rhs.
Y() + lhs.
Z() * rhs.
Z();
325 return Point3D<T>(lhs.
X() * rhs, lhs.
Y() * rhs, lhs.
Z() * rhs);
355 return Point3D<T>(lhs.
X() / rhs, lhs.
Y() / rhs, lhs.
Z() / rhs);
371 return Point3D<int>(
static_cast<int>(std::round(rhs.X())),
static_cast<int>(std::round(rhs.Y())),
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:241
T X() const noexcept
Get the x component of the point.
Definition: point_3d.hpp:80
bool operator!=(const Point3D< T > &other) const noexcept
Compares to an other point.
Definition: point_3d.hpp:165
T Y() const noexcept
Get the y component of the point.
Definition: point_3d.hpp:100
void SetX(T x) noexcept
Set the x component of the point.
Definition: point_3d.hpp:90
Point3D< T > operator/(const Point3D< T > &lhs, const T &rhs)
Divide point by scalar.
Definition: point_3d.hpp:353
void SetY(T y)
Set the y component of the point.
Definition: point_3d.hpp:110
Point3D< T > operator*(const Point3D< T > &lhs, const T &rhs)
Multiply point with scalar.
Definition: point_3d.hpp:323
T Z() const noexcept
Get the z component of the point.
Definition: point_3d.hpp:120
Point3D< T > & operator+=(const Point3D< T > &point) noexcept
Adds and assigns to this point.
Definition: point_3d.hpp:184
Point3D< T > & operator-=(const Point3D< T > &point) noexcept
Subtracts and assigns to this point.
Definition: point_3d.hpp:198
bool operator==(const Point3D< T > &other) const noexcept
Compares to an other point.
Definition: point_3d.hpp:153
Point3D< T > operator*(const T &lhs, const Point3D< T > &rhs)
Multiply scalar with point.
Definition: point_3d.hpp:338
Point3D(const T(&list)[N]) noexcept
Construct a point with an initializer list.
Definition: point_3d.hpp:68
T Length() const noexcept
Gets the length of this point.
Definition: point_3d.hpp:140
Point3D< T > operator-(const Point3D< T > &lhs, const Point3D< T > &rhs)
Subtracts two points.
Definition: point_3d.hpp:293
Point3D< T > & operator*=(const T &value) noexcept
Multiplies by a scalar and assigns to this point.
Definition: point_3d.hpp:212
T operator*(const Point3D< T > &lhs, const Point3D< T > &rhs)
Inner product of two point vectors.
Definition: point_3d.hpp:308
Point3D< T > operator+(const Point3D< T > &lhs, const Point3D< T > &rhs)
Add two points.
Definition: point_3d.hpp:278
Point3D< T > & operator/=(const T &value) noexcept
Divide by a scalar and assigns to this point.
Definition: point_3d.hpp:226
T & operator[](int index) noexcept
Index based element access.
Definition: point_3d.hpp:253
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:130
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
Point2D< int > Round(const Point2D< T > &rhs) noexcept
Round to an integer point.
Definition: point_2d.hpp:380