18 template <
class T,
class ENABLE =
void>
27 class Point2D<T, typename EnableIfArithmetic<T>::type> final
63 :
Point2D(
static_cast<T
>(
static_cast<double>(r) *
Cos(phi)),
static_cast<T
>(
static_cast<double>(r) *
Sin(phi)))
72 template <std::
size_t N>
75 static_assert(N == 2,
"CVB: Point2D must have 2 elements");
84 T
X() const noexcept {
…}
104 T
Y() const noexcept {
…}
126 return static_cast<T
>(
127 sqrt(
static_cast<double>(x_) *
static_cast<double>(x_) +
static_cast<double>(y_) *
static_cast<double>(y_)));
147 return Atan2(
static_cast<double>(y_),
static_cast<double>(x_));
168 return (x_ == other.x_ && y_ == other.y_);
179 return !(*
this == other);
187 "CVB: Unsupported data type - must be floating point!");
188 return Point2D<C>(
static_cast<C
>(
X()),
static_cast<C
>(
Y()));
251 assert(index < 2 && index >= 0);
252 return *(&x_ + index);
263 assert(index < 2 && index >= 0);
264 return *(&x_ + index);
268 T x_ =
static_cast<T
>(0);
269 T y_ =
static_cast<T
>(0);
314 return lhs.
X() * rhs.
X() + lhs.
Y() * rhs.
Y();
373 static_assert(IsNumeric<T>::value,
"CVB: Unsupported data type - must be numeric!");
Object for convenient and type - safe handling of angles.
Definition angle.hpp:16
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
Point2D< T > & operator/=(const T &value) noexcept
Divide by a scalar and assigns to this point.
Definition point_2d.hpp:236
Point2D< T > & operator*=(const T &value) noexcept
Multiplies by a scalar and assigns to this point.
Definition point_2d.hpp:223
Point2D< T > operator/(const Point2D< T > &lhs, const T &rhs)
Divide point by scalar.
Definition point_2d.hpp:357
const T & operator[](int index) const noexcept
Index based element access.
Definition point_2d.hpp:249
Point2D< T > & operator+=(const Point2D< T > &point) noexcept
Adds and assigns to this point.
Definition point_2d.hpp:197
T X() const noexcept
Gets the x-component of the point.
Definition point_2d.hpp:84
T operator*(const Point2D< T > &lhs, const Point2D< T > &rhs)
Inner product of two point vectors.
Definition point_2d.hpp:312
T Y() const noexcept
Gets the y-component of the point.
Definition point_2d.hpp:104
void SetX(T x) noexcept
Sets the x-component of the point.
Definition point_2d.hpp:94
void SetY(T y)
Sets the y-component of the point.
Definition point_2d.hpp:114
Point2D(const T(&list)[N]) noexcept
Construct a point with an initializer list.
Definition point_2d.hpp:73
Point2D() noexcept=default
Creates a default point at (0, 0).
Point2D< T > operator*(const T &lhs, const Point2D< T > &rhs)
Multiply scalar with point.
Definition point_2d.hpp:342
Point2D< T > operator*(const Point2D< T > &lhs, const T &rhs)
Multiply point with scalar.
Definition point_2d.hpp:327
bool operator!=(const Point2D< T > &other) const noexcept
Compares to an other point.
Definition point_2d.hpp:177
Point2D< T > operator-(const Point2D< T > &lhs, const Point2D< T > &rhs)
Subtracts two points.
Definition point_2d.hpp:297
T Length() const noexcept
Gets the length of the vector represented by this point object.
Definition point_2d.hpp:124
Angle Phi() const noexcept
Gets the orientation of the vector represented by this point object.
Definition point_2d.hpp:145
bool operator==(const Point2D< T > &other) const noexcept
Compares to an other point.
Definition point_2d.hpp:166
Point2D< T > operator+(const Point2D< T > &lhs, const Point2D< T > &rhs)
Add two points.
Definition point_2d.hpp:282
T & operator[](int index) noexcept
Index based element access.
Definition point_2d.hpp:261
Point2D< T > & operator-=(const Point2D< T > &point) noexcept
Subtracts and assigns to this point.
Definition point_2d.hpp:210
void SetLength(T length) noexcept
Sets the length of the vector represented by this point object.
Definition point_2d.hpp:135
Point2D(Angle phi, T r) noexcept
Create a PointD vector from radial coordinates.
Definition point_2d.hpp:62
void SetPhi(Angle phi) noexcept
Sets the orientation of the vector represented by this point object.
Definition point_2d.hpp:155
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
double Sin(Angle angle) noexcept
Returns the sine of an angle.
Definition angle.hpp:429
Angle Atan2(double y, double x) noexcept
Returns the angle whose tangent is the quotient of two specified numbers.
Definition angle.hpp:390
Point2D< int > Round(const Point2D< T > &rhs) noexcept
Round to an integer point.
Definition point_2d.hpp:371
double Cos(Angle angle) noexcept
Returns the cosine of an angle.
Definition angle.hpp:403
Point2D< T > Vector2D
Alias for Point2D.
Definition point_2d.hpp:379