CVB++ 14.0
Point2D< T, ENABLE > Class Template Referencefinal

Multi-purpose 2D vector class. More...

#include <cvb/point_2d.hpp>

Public Member Functions

 Point2D () noexcept=default
 Creates a default point at (0, 0). More...
 
 Point2D (T x, T y) noexcept
 Create a point from the x and y component. More...
 
 Point2D (Angle phi, T r) noexcept
 Create a PointD vector from radial coordinates. More...
 
template<std::size_t N>
 Point2D (const T(&list)[N]) noexcept
 Construct a point with an initializer list. More...
 
X () const noexcept
 Gets the x-component of the point. More...
 
void SetX (T x) noexcept
 Sets the x-component of the point. More...
 
Y () const noexcept
 Gets the y-component of the point. More...
 
void SetY (T y)
 Sets the y-component of the point. More...
 
Length () const noexcept
 Gets the length of the vector represented by this point object. More...
 
void SetLength (T length) noexcept
 Sets the length of the vector represented by this point object. More...
 
Angle Phi () const noexcept
 Gets the orientation of the vector represented by this point object. More...
 
void SetPhi (Angle phi) noexcept
 Sets the orientation of the vector represented by this point object. More...
 
bool operator== (const Point2D< T > &other) const noexcept
 Compares to an other point. More...
 
bool operator!= (const Point2D< T > &other) const noexcept
 Compares to an other point. More...
 
template<class C >
 operator Point2D< C > () const noexcept
 Enable casting.
 
Point2D< T > & operator+= (const Point2D< T > &point) noexcept
 Adds and assigns to this point. More...
 
Point2D< T > & operator-= (const Point2D< T > &point) noexcept
 Subtracts and assigns to this point. More...
 
Point2D< T > & operator*= (const T &value) noexcept
 Multiplies by a scalar and assigns to this point. More...
 
Point2D< T > & operator/= (const T &value) noexcept
 Divide by a scalar and assigns to this point. More...
 
const T & operator[] (int index) const noexcept
 Index based element access. More...
 
T & operator[] (int index) noexcept
 Index based element access. More...
 

Related Functions

(Note that these are not member functions.)

template<size_t I, class T , std::enable_if_t< less< I, 2 >::value, int > = 0>
CVB_BEGIN_INLINE_NS auto get (const Point2D< T > &point) noexcept -> decltype(point[I])
 Get's the I-th element of the Point2D<T>. More...
 
template<size_t I, class T , std::enable_if_t< less< I, 2 >::value, int > = 0>
void set (Point2D< T > &point, const T &val) noexcept
 Set's the value of the I-th element in the Point2D<T> point. More...
 
template<class T >
Point2D< T > operator+ (const Point2D< T > &lhs, const Point2D< T > &rhs)
 Add two points. More...
 
template<class T >
Point2D< T > operator- (const Point2D< T > &lhs, const Point2D< T > &rhs)
 Subtracts two points. More...
 
template<class T >
operator* (const Point2D< T > &lhs, const Point2D< T > &rhs)
 Inner product of two point vectors. More...
 
template<class T >
Point2D< T > operator* (const Point2D< T > &lhs, const T &rhs)
 Multiply point with scalar. More...
 
template<class T >
Point2D< T > operator* (const T &lhs, const Point2D< T > &rhs)
 Multiply scalar with point. More...
 
template<class T >
Point2D< T > operator/ (const Point2D< T > &lhs, const T &rhs)
 Divide point by scalar. More...
 

Detailed Description

template<class T, class ENABLE = void>
class Cvb::Point2D< T, ENABLE >

Multi-purpose 2D vector class.

Examples
ShapeFinder2/QtShapeFinder2.

Constructor & Destructor Documentation

◆ Point2D() [1/4]

Point2D ( )
defaultnoexcept

Creates a default point at (0, 0).

Exceptions
Doesnot throw any exception.

◆ Point2D() [2/4]

Point2D ( x,
y 
)
inlinenoexcept

Create a point from the x and y component.

Parameters
[in]xData to initialize with.
[in]yData to initialize with.
Exceptions
Doesnot throw any exception.

◆ Point2D() [3/4]

Point2D ( Angle  phi,
r 
)
inlinenoexcept

Create a PointD vector from radial coordinates.

Parameters
[in]phiAngle coordinate.
[in]rRadius coordinate.
Exceptions
Doesnot throw any exception.

The vectors are internally stored in Cartesian coordinates and that extensive use of radial coordinates my be slow.

◆ Point2D() [4/4]

Point2D ( const T(&)  list[N])
inlinenoexcept

Construct a point with an initializer list.

Parameters
[in]listContaining exactly 2 elements.
Exceptions
Doesnot throw any exception.

Member Function Documentation

◆ Length()

T Length ( ) const
inlinenoexcept

Gets the length of the vector represented by this point object.

Returns
T The length (accurate only for double or float).
Exceptions
Doesnot throw any exception.

◆ operator!=()

bool operator!= ( const Point2D< T > &  other) const
inlinenoexcept

Compares to an other point.

Parameters
[in]otherOther point.
Returns
True if not equal, otherwise false.
Exceptions
Doesnot throw any exception.

◆ operator*=()

Point2D< T > & operator*= ( const T &  value)
inlinenoexcept

Multiplies by a scalar and assigns to this point.

Parameters
[in]valueThe scalar.
Returns
This point.
Exceptions
Doesnot throw any exception.

◆ operator+=()

Point2D< T > & operator+= ( const Point2D< T > &  point)
inlinenoexcept

Adds and assigns to this point.

Parameters
[in]pointOther point.
Returns
This point.
Exceptions
Doesnot throw any exception.

◆ operator-=()

Point2D< T > & operator-= ( const Point2D< T > &  point)
inlinenoexcept

Subtracts and assigns to this point.

Parameters
[in]pointOther point.
Returns
This point.
Exceptions
Doesnot throw any exception.

◆ operator/=()

Point2D< T > & operator/= ( const T &  value)
inlinenoexcept

Divide by a scalar and assigns to this point.

Parameters
[in]valueThe scalar.
Returns
This point.
Exceptions
Doesnot throw any exception.

◆ operator==()

bool operator== ( const Point2D< T > &  other) const
inlinenoexcept

Compares to an other point.

Parameters
[in]otherOther point.
Returns
True if equal, otherwise false.
Exceptions
Doesnot throw any exception.

◆ operator[]() [1/2]

const T & operator[] ( int  index) const
inlinenoexcept

Index based element access.

Parameters
[in]indexIndex of the element.
Returns
A const reference to the element.
Exceptions
Doesnot throw any exception.

◆ operator[]() [2/2]

T & operator[] ( int  index)
inlinenoexcept

Index based element access.

Parameters
[in]indexIndex of the element.
Returns
A reference to the element.
Exceptions
Doesnot throw any exception.

◆ Phi()

Angle Phi ( ) const
inlinenoexcept

Gets the orientation of the vector represented by this point object.

Returns
The angle (accurate only for double or float).
Exceptions
Doesnot throw any exception.

◆ SetLength()

void SetLength ( length)
inlinenoexcept

Sets the length of the vector represented by this point object.

Parameters
[in]lengthThe length (accurate only for double or float).
Exceptions
Doesnot throw any exception.

◆ SetPhi()

void SetPhi ( Angle  phi)
inlinenoexcept

Sets the orientation of the vector represented by this point object.

Parameters
[in]phiThe angle (accurate only for double or float).
Exceptions
Doesnot throw any exception.

◆ SetX()

void SetX ( x)
inlinenoexcept

Sets the x-component of the point.

Parameters
[in]xX-component.
Exceptions
Doesnot throw any exception.

◆ SetY()

void SetY ( y)
inline

Sets the y-component of the point.

Parameters
[in]yY-component.
Exceptions
Doesnot throw any exception.

◆ X()

T X ( ) const
inlinenoexcept

Gets the x-component of the point.

Returns
X-component.
Exceptions
Doesnot throw any exception.

◆ Y()

T Y ( ) const
inlinenoexcept

Gets the y-component of the point.

Returns
Y-component.
Exceptions
Doesnot throw any exception.

Friends And Related Function Documentation

◆ get()

CVB_BEGIN_INLINE_NS auto get ( const Point2D< T > &  point) -> decltype(point[I])
related

Get's the I-th element of the Point2D<T>.

See also
Block, Visit
Precondition
I < 2
Template Parameters
IThe index of the element.
Parameters
pointThe Point2D<T> to retrieve the I-th element from.
Returns
The I-th element of point.

◆ operator*() [1/3]

T operator* ( const Point2D< T > &  lhs,
const Point2D< T > &  rhs 
)
related

Inner product of two point vectors.

Parameters
[in]lhsRight hand side point.
[in]rhsLeft hand side value.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator*() [2/3]

Point2D< T > operator* ( const Point2D< T > &  lhs,
const T &  rhs 
)
related

Multiply point with scalar.

Parameters
[in]lhsRight hand side point.
[in]rhsLeft hand side value.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator*() [3/3]

Point2D< T > operator* ( const T &  lhs,
const Point2D< T > &  rhs 
)
related

Multiply scalar with point.

Parameters
[in]lhsRight hand side value.
[in]rhsLeft hand side point.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator+()

Point2D< T > operator+ ( const Point2D< T > &  lhs,
const Point2D< T > &  rhs 
)
related

Add two points.

Parameters
[in]lhsRight hand side point.
[in]rhsLeft hand side point.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator-()

Point2D< T > operator- ( const Point2D< T > &  lhs,
const Point2D< T > &  rhs 
)
related

Subtracts two points.

Parameters
[in]lhsRight hand side point.
[in]rhsLeft hand side point.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator/()

Point2D< T > operator/ ( const Point2D< T > &  lhs,
const T &  rhs 
)
related

Divide point by scalar.

Parameters
[in]lhsRight hand side matrix.
[in]rhsLeft hand side value.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ set()

void set ( Point2D< T > &  point,
const T &  val 
)
related

Set's the value of the I-th element in the Point2D<T> point.

See also
Block, Visit
Precondition
I < 2
Template Parameters
IThe index of the element.
Parameters
pointThe Point2D<T,K> to set the I-th value in.
valThe value to be written to the I-th element of point.