Loading...
Searching...
No Matches

Template class for 2D points specified by its coordinates x and y. More...

#include <opencv2/core/types.hpp>

Public Types

typedef _Tp value_type
 

Public Member Functions

 Point_ ()
 default constructor
 
 Point_ (_Tp _x, _Tp _y)
 
 Point_ (const Point_ &pt)=default
 
 Point_ (const Size_< _Tp > &sz)
 
 Point_ (const Vec< _Tp, 2 > &v)
 
 Point_ (Point_ &&pt) CV_NOEXCEPT=default
 
double cross (const Point_ &pt) const
 cross-product
 
double ddot (const Point_ &pt) const
 dot product computed in double-precision arithmetics
 
_Tp dot (const Point_ &pt) const
 dot product
 
bool inside (const Rect_< _Tp > &r) const
 checks whether the point is inside the specified rectangle
 
template<typename _Tp2 >
 operator Point_< _Tp2 > () const
 conversion to another data type
 
 operator Vec< _Tp, 2 > () const
 conversion to the old-style C structures
 
Point_operator= (const Point_ &pt)=default
 
Point_operator= (Point_ &&pt) CV_NOEXCEPT=default
 

Public Attributes

_Tp x
 x coordinate of the point
 
_Tp y
 y coordinate of the point
 

Detailed Description

template<typename _Tp>
class cv::Point_< _Tp >

Template class for 2D points specified by its coordinates x and 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;
double norm(InputArray src1, int normType=NORM_L2, InputArray mask=noArray())
Calculates the absolute norm of an array.

For your convenience, the following type aliases are defined:

typedef Point2i Point;
Template class for 2D points specified by its coordinates x and y.
Definition: types.hpp:163
Point_< int > Point2i
Definition: types.hpp:205
Point2i Point
Definition: types.hpp:209
Point_< double > Point2d
Definition: types.hpp:208
Point_< float > Point2f
Definition: types.hpp:207

Example:

Point2f a(0.3f, 0.f), b(0.f, 0.4f);
Point pt = (a + b)*10.f;
cout << pt.x << ", " << pt.y << endl;
_Tp y
y coordinate of the point
Definition: types.hpp:202
_Tp x
x coordinate of the point
Definition: types.hpp:201

Member Typedef Documentation

◆ value_type

template<typename _Tp >
typedef _Tp cv::Point_< _Tp >::value_type

Constructor & Destructor Documentation

◆ Point_() [1/6]

template<typename _Tp >
cv::Point_< _Tp >::Point_ ( )

default constructor

◆ Point_() [2/6]

template<typename _Tp >
cv::Point_< _Tp >::Point_ ( _Tp  _x,
_Tp  _y 
)

◆ Point_() [3/6]

template<typename _Tp >
cv::Point_< _Tp >::Point_ ( const Point_< _Tp > &  pt)
default

◆ Point_() [4/6]

template<typename _Tp >
cv::Point_< _Tp >::Point_ ( Point_< _Tp > &&  pt)
default

◆ Point_() [5/6]

template<typename _Tp >
cv::Point_< _Tp >::Point_ ( const Size_< _Tp > &  sz)

◆ Point_() [6/6]

template<typename _Tp >
cv::Point_< _Tp >::Point_ ( const Vec< _Tp, 2 > &  v)

Member Function Documentation

◆ cross()

template<typename _Tp >
double cv::Point_< _Tp >::cross ( const Point_< _Tp > &  pt) const

cross-product

◆ ddot()

template<typename _Tp >
double cv::Point_< _Tp >::ddot ( const Point_< _Tp > &  pt) const

dot product computed in double-precision arithmetics

◆ dot()

template<typename _Tp >
_Tp cv::Point_< _Tp >::dot ( const Point_< _Tp > &  pt) const

dot product

◆ inside()

template<typename _Tp >
bool cv::Point_< _Tp >::inside ( const Rect_< _Tp > &  r) const

checks whether the point is inside the specified rectangle

◆ operator Point_< _Tp2 >()

template<typename _Tp >
template<typename _Tp2 >
cv::Point_< _Tp >::operator Point_< _Tp2 > ( ) const

conversion to another data type

◆ operator Vec< _Tp, 2 >()

template<typename _Tp >
cv::Point_< _Tp >::operator Vec< _Tp, 2 > ( ) const

conversion to the old-style C structures

◆ operator=() [1/2]

template<typename _Tp >
Point_ & cv::Point_< _Tp >::operator= ( const Point_< _Tp > &  pt)
default

◆ operator=() [2/2]

template<typename _Tp >
Point_ & cv::Point_< _Tp >::operator= ( Point_< _Tp > &&  pt)
default

Member Data Documentation

◆ x

template<typename _Tp >
_Tp cv::Point_< _Tp >::x

x coordinate of the point

◆ y

template<typename _Tp >
_Tp cv::Point_< _Tp >::y

y coordinate of the point


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