nndeploy C++ API  0.2.0
nndeploy C++ API
Public Types | Public Member Functions | Public Attributes | List of all members
nndeploy::base::Point< T > Class Template Reference

Template class for 2D points specified by its coordinates x_ an y_. An instance of the class is interchangeable with C structures, CvPoint and CvPoint2D32f . There is also a cast operator to convert point coordinates to the specified type. The conversion from floating-point coordinates to integer coordinates is done by rounding. Commonly, the conversion uses this operation for each of the coordinates. Besides the class members listed in the declaration above, the following operations on points are implemented: More...

#include <type.h>

Public Types

typedef T value_type
 

Public Member Functions

double cross (const Point &pt) const
 cross-product More...
 
double ddot (const Point &pt) const
 dot product computed in double-precision arithmetics More...
 
dot (const Point &pt) const
 dot product More...
 
bool inside (const Rect< T > &r) const
 checks whether the point is inside the specified rectangle More...
 
template<typename Tp2 >
 operator Point< Tp2 > () const
 conversion to another data type More...
 
Pointoperator= (const Point &pt)
 
Pointoperator= (Point &&pt)=default
 
 Point ()
 default constructor More...
 
 Point (const Point &pt)
 
 Point (const Size< T > &sz)
 
 Point (Point &&pt)=default
 
 Point (T x, T y)
 

Public Attributes

x_
 x_ coordinate of the point More...
 
y_
 y_ coordinate of the point More...
 

Detailed Description

template<typename T>
class nndeploy::base::Point< T >

Template class for 2D points specified by its coordinates x_ an y_. An instance of the class is interchangeable with C structures, CvPoint and CvPoint2D32f . There is also a cast operator to convert point coordinates to the specified type. The conversion from floating-point coordinates to integer coordinates is done by rounding. Commonly, the conversion uses this operation for each of the coordinates. Besides the class members listed in the declaration above, the following operations on points are implemented:

pt1 = pt2 + pt3;
pt1 = pt2 - pt3;
pt1 = pt2 * a;
pt1 = a * pt2;
pt1 = pt2 / a;
pt1 += pt2;
pt1 -= pt2;
pt1 *= a;
pt1 /= a;
double value = norm(pt); // L2 norm
pt1 == pt2;
pt1 != pt2;

For your convenience, the following type aliases are defined:

typedef Point<int> Point2i;
typedef Point2i Point;
typedef Point<float> Point2f;
typedef Point<double> Point2d;
Point()
default constructor
Definition: type.h:458
Point< double > Point2d
Definition: type.h:180
Point< float > Point2f
Definition: type.h:179
Point< int > Point2i
Definition: type.h:178

Example:

Point2f a(0.3f, 0.f), b(0.f, 0.4f);
Point pt = (a + b)*10.f;
cout << pt.x_ << ", " << pt.y_ << endl;

Definition at line 145 of file type.h.

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T nndeploy::base::Point< T >::value_type

Definition at line 147 of file type.h.

Constructor & Destructor Documentation

◆ Point() [1/5]

template<typename T >
nndeploy::base::Point< T >::Point
inline

default constructor

Definition at line 458 of file type.h.

◆ Point() [2/5]

template<typename T >
nndeploy::base::Point< T >::Point ( x,
y 
)
inline

Definition at line 461 of file type.h.

◆ Point() [3/5]

template<typename T >
nndeploy::base::Point< T >::Point ( const Point< T > &  pt)
inline

Definition at line 464 of file type.h.

◆ Point() [4/5]

template<typename T >
nndeploy::base::Point< T >::Point ( Point< T > &&  pt)
default

◆ Point() [5/5]

template<typename T >
nndeploy::base::Point< T >::Point ( const Size< T > &  sz)
inline

Definition at line 467 of file type.h.

Member Function Documentation

◆ cross()

template<typename T >
double nndeploy::base::Point< T >::cross ( const Point< T > &  pt) const
inline

cross-product

Definition at line 494 of file type.h.

◆ ddot()

template<typename T >
double nndeploy::base::Point< T >::ddot ( const Point< T > &  pt) const
inline

dot product computed in double-precision arithmetics

Definition at line 488 of file type.h.

◆ dot()

template<typename T >
T nndeploy::base::Point< T >::dot ( const Point< T > &  pt) const
inline

dot product

Definition at line 483 of file type.h.

◆ inside()

template<typename T >
bool nndeploy::base::Point< T >::inside ( const Rect< T > &  r) const
inline

checks whether the point is inside the specified rectangle

Definition at line 499 of file type.h.

Here is the call graph for this function:

◆ operator Point< Tp2 >()

template<typename T >
template<typename Tp2 >
nndeploy::base::Point< T >::operator Point< Tp2 >
inline

conversion to another data type

Definition at line 478 of file type.h.

◆ operator=() [1/2]

template<typename T >
Point< T > & nndeploy::base::Point< T >::operator= ( const Point< T > &  pt)
inline

Definition at line 470 of file type.h.

◆ operator=() [2/2]

template<typename T >
Point& nndeploy::base::Point< T >::operator= ( Point< T > &&  pt)
default

Member Data Documentation

◆ x_

template<typename T >
T nndeploy::base::Point< T >::x_

x_ coordinate of the point

Definition at line 174 of file type.h.

◆ y_

template<typename T >
T nndeploy::base::Point< T >::y_

y_ coordinate of the point

Definition at line 175 of file type.h.


The documentation for this class was generated from the following file: