PCL
pcl::GenericPoint< T > Class Template Reference

A generic point in the two-dimensional space. More...

#include <Point.h>

Public Types

typedef T component
 

Public Member Functions

constexpr GenericPoint ()
 
template<typename T1 >
constexpr GenericPoint (T1 xPos, T1 yPos)
 
constexpr GenericPoint (component d)
 
template<typename T1 >
 GenericPoint (std::initializer_list< T1 > l)
 
template<typename T1 >
 GenericPoint (const GenericPoint< T1 > &p)
 
GenericPoint Deg () const
 
template<typename T1 >
double DistanceTo (const GenericPoint< T1 > &p) const
 
template<typename T1 , typename T2 >
double Dot (T1 px, T2 py) const
 
template<typename T1 >
double Dot (const GenericPoint< T1 > &p) const
 
template<typename T1 >
double ManhattanDistanceTo (const GenericPoint< T1 > &p) const
 
template<typename T1 >
void MoveBy (const GenericPoint< T1 > &d)
 
template<typename T1 >
void MoveBy (T1 dx, T1 dy)
 
template<typename T1 >
void MoveBy (T1 dxy)
 
template<typename T1 >
GenericPoint MovedBy (const GenericPoint< T1 > &d) const
 
template<typename T1 >
GenericPoint MovedBy (T1 dx, T1 dy) const
 
template<typename T1 >
GenericPoint MovedTo (const GenericPoint< T1 > &p) const
 
template<typename T1 >
GenericPoint MovedTo (T1 xPos, T1 yPos) const
 
template<typename T1 >
void MoveTo (const GenericPoint< T1 > &p)
 
template<typename T1 >
void MoveTo (T1 xPos, T1 yPos)
 
template<typename T1 >
GenericPointoperator*= (const GenericPoint< T1 > &p)
 
GenericPointoperator*= (component d)
 
GenericPoint operator+ () const
 
template<typename T1 >
GenericPointoperator+= (const GenericPoint< T1 > &p)
 
GenericPointoperator+= (component d)
 
GenericPoint operator- () const
 
template<typename T1 >
GenericPointoperator-= (const GenericPoint< T1 > &p)
 
GenericPointoperator-= (component d)
 
template<typename T1 >
GenericPointoperator/= (const GenericPoint< T1 > &p)
 
GenericPointoperator/= (component d)
 
template<typename T1 >
GenericPointoperator= (const GenericPoint< T1 > &p)
 
GenericPointoperator= (component v)
 
componentoperator[] (int i)
 
component operator[] (int i) const
 
template<typename T1 , typename T2 >
void Rotate (T1 angle, T2 xc, T2 yc)
 
template<typename T1 , typename T2 >
void Rotate (T1 angle, const GenericPoint< T2 > &center)
 
template<typename T1 , typename T2 >
void Rotate (T1 sa, T1 ca, T2 xc, T2 yc)
 
template<typename T1 , typename T2 >
void Rotate (T1 sa, T1 ca, const GenericPoint< T2 > &center)
 
template<typename T1 , typename T2 >
GenericPoint Rotated (T1 angle, T2 xc, T2 yc) const
 
template<typename T1 , typename T2 >
GenericPoint Rotated (T1 angle, const GenericPoint< T2 > &center) const
 
template<typename T1 , typename T2 >
GenericPoint Rotated (T1 sa, T1 ca, T2 xc, T2 yc) const
 
template<typename T1 , typename T2 >
GenericPoint Rotated (T1 sa, T1 ca, const GenericPoint< T2 > &center) const
 
void Round ()
 
void Round (int n)
 
GenericPoint Rounded () const
 
GenericPoint Rounded (int n) const
 
GenericPoint< int > RoundedToInt () const
 
template<typename T1 >
double SquaredDistanceTo (const GenericPoint< T1 > &p) const
 
GenericPointToDeg ()
 
GenericPointToRad ()
 
void Truncate ()
 
GenericPoint Truncated () const
 
GenericPoint< int > TruncatedToInt () const
 

Public Attributes

component x
 Abscissa (horizontal, or X-axis coordinate).
 
component y
 Ordinate (vertical, or Y-axis coordinate).
 

Detailed Description

template<typename T>
class pcl::GenericPoint< T >

GenericPoint implements a point in the plane, specified by its x and y coordinates. The type T represents scalar point coordinates and can be any real or integer numerical type.

The coordinates of GenericPoint are accessed directly by its x and y data members. Given a GenericPoint instance p, you can use p.x and p.y directly to get or set coordinate values.

See also
2-D Point Types, 2-D Point Operators and Functions, GenericRectangle

Definition at line 99 of file Point.h.

Member Typedef Documentation

◆ component

template<typename T>
typedef T pcl::GenericPoint< T >::component

Represents the type of a point component.

Definition at line 106 of file Point.h.

Constructor & Destructor Documentation

◆ GenericPoint() [1/5]

template<typename T>
constexpr pcl::GenericPoint< T >::GenericPoint ( )
inline

Constructs a default GenericPoint instance. Point coordinates are not initialized, so they'll have unpredictable garbage values.

Definition at line 118 of file Point.h.

◆ GenericPoint() [2/5]

template<typename T>
template<typename T1 >
constexpr pcl::GenericPoint< T >::GenericPoint ( T1  xPos,
T1  yPos 
)
inline

Constructs a GenericPoint instance given its coordinates xPos and yPos in the plane.

The type T1 can be any suitable real or integer numerical type, or a type with numeric conversion semantics.

Definition at line 131 of file Point.h.

◆ GenericPoint() [3/5]

template<typename T>
constexpr pcl::GenericPoint< T >::GenericPoint ( component  d)
inline

Constructs a GenericPoint instance with both point coordinates equal to the specified scalar d.

Definition at line 141 of file Point.h.

◆ GenericPoint() [4/5]

template<typename T>
template<typename T1 >
pcl::GenericPoint< T >::GenericPoint ( std::initializer_list< T1 >  l)
inline

Constructs a GenericPoint instance from coordinates taken from the specified initializer list l.

This constructor will copy 2, 1 or zero point coordinates, depending on the number of values in the initializer list. Coordinates that cannot be initialized from list values will be set to zero. For example, the following code:

Point p1 = {};
Point p2 = { 1 };
Point p3 = { 1, 2 };

is functionally equivalent to:

Point p1( 0, 0 );
Point p2( 1, 0 );
Point p3( 1, 2 );

Definition at line 170 of file Point.h.

◆ GenericPoint() [5/5]

template<typename T>
template<typename T1 >
pcl::GenericPoint< T >::GenericPoint ( const GenericPoint< T1 > &  p)
inline

Nontrivial copy constructor. Constructs a GenericPoint instance as a copy (possibly involving a conversion between different numerical types) of another point p with different template argument.

Definition at line 195 of file Point.h.

Member Function Documentation

◆ Deg()

template<typename T>
GenericPoint pcl::GenericPoint< T >::Deg ( ) const
inline

Returns a point whose coordinates are the coordinates of this point converted to degrees, assuming that this point has coordinates expressed in radians.

Definition at line 798 of file Point.h.

References pcl::Deg().

◆ DistanceTo()

template<typename T>
template<typename T1 >
double pcl::GenericPoint< T >::DistanceTo ( const GenericPoint< T1 > &  p) const
inline

Returns the Euclidian distance between this point and another point p in the plane.

The Euclidian distance between two points p and q is the length of the straight line between both points: Sqrt( (p.x - q.x)^2 + (p.y - q.y)^2 ).

See also
SquaredDistanceTo(), ManhattanDistanceTo()

Definition at line 241 of file Point.h.

References pcl::Sqrt().

◆ Dot() [1/2]

template<typename T>
template<typename T1 , typename T2 >
double pcl::GenericPoint< T >::Dot ( T1  px,
T2  py 
) const
inline

Returns the dot product of this point and another point given by its coordinates px and py.

Definition at line 851 of file Point.h.

◆ Dot() [2/2]

template<typename T>
template<typename T1 >
double pcl::GenericPoint< T >::Dot ( const GenericPoint< T1 > &  p) const
inline

Returns the dot product of this point and another point p.

Definition at line 860 of file Point.h.

◆ ManhattanDistanceTo()

template<typename T>
template<typename T1 >
double pcl::GenericPoint< T >::ManhattanDistanceTo ( const GenericPoint< T1 > &  p) const
inline

Returns the Manhattan distance between this point and another point p in the plane.

The Manhattan distance between two points p and q is the sum of distances measured along axes at right angles: |p.x - q.x| + |p.y - q.y|.

See also
DistanceTo()

Definition at line 256 of file Point.h.

References pcl::Abs(), pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ MoveBy() [1/3]

template<typename T>
template<typename T1 >
void pcl::GenericPoint< T >::MoveBy ( const GenericPoint< T1 > &  d)
inline

Moves this point by equal increments in the X and Y directions, relative to its current position.

Parameters
dIncrements in the X and Y directions, given by d.x and d.y, respectively.
See also
MoveTo()

Definition at line 320 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ MoveBy() [2/3]

template<typename T>
template<typename T1 >
void pcl::GenericPoint< T >::MoveBy ( T1  dx,
T1  dy 
)
inline

Moves this point by increments dx and dy in the X and Y directions, respectively, relative to its current position.

For example, given the declaration:

GenericPoint<float> p;

These two expressions are equivalent:

p.MoveBy( -3, 7 );
p.MoveTo( p.x-3, p.y+7 );
See also
MoveTo()

Definition at line 343 of file Point.h.

◆ MoveBy() [3/3]

template<typename T>
template<typename T1 >
void pcl::GenericPoint< T >::MoveBy ( T1  dxy)
inline

Moves this point by the same increment dxy in the X and Y directions, relative to its current position.

This function is functionally equivalent to:

MoveBy( dxy, dxy );
See also
MoveTo()

Definition at line 359 of file Point.h.

◆ MovedBy() [1/2]

template<typename T>
template<typename T1 >
GenericPoint pcl::GenericPoint< T >::MovedBy ( const GenericPoint< T1 > &  d) const
inline

Returns a point whose coordinates are the coordinates of this point displaced by the increments specified as the point d.

Definition at line 376 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ MovedBy() [2/2]

template<typename T>
template<typename T1 >
GenericPoint pcl::GenericPoint< T >::MovedBy ( T1  dx,
T1  dy 
) const
inline

Returns a point whose coordinates are the coordinates of this point displaced by the specified increments dx and dy.

Definition at line 386 of file Point.h.

◆ MovedTo() [1/2]

template<typename T>
template<typename T1 >
GenericPoint pcl::GenericPoint< T >::MovedTo ( const GenericPoint< T1 > &  p) const
inline

Returns a point whose coordinates are equal to the coordinates of the specified point d.

Definition at line 296 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ MovedTo() [2/2]

template<typename T>
template<typename T1 >
GenericPoint pcl::GenericPoint< T >::MovedTo ( T1  xPos,
T1  yPos 
) const
inline

Returns a point at the specified xPos and yPos coordinates.

Definition at line 305 of file Point.h.

◆ MoveTo() [1/2]

template<typename T>
template<typename T1 >
void pcl::GenericPoint< T >::MoveTo ( const GenericPoint< T1 > &  p)
inline

Moves this point to the location of another point p.

See also
MoveBy()

Definition at line 267 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ MoveTo() [2/2]

template<typename T>
template<typename T1 >
void pcl::GenericPoint< T >::MoveTo ( T1  xPos,
T1  yPos 
)
inline

Moves this point to the specified absolute coordinates xPos and yPos in the plane.

See also
MoveBy()

Definition at line 279 of file Point.h.

◆ operator*=() [1/2]

template<typename T>
template<typename T1 >
GenericPoint& pcl::GenericPoint< T >::operator*= ( const GenericPoint< T1 > &  p)
inline

Multiplies each coordinate of this point by its homonym coordinate of a given point p. Returns a reference to this point.

See also
operator /=(), operator +=()

Definition at line 697 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ operator*=() [2/2]

template<typename T>
GenericPoint& pcl::GenericPoint< T >::operator*= ( component  d)
inline

Multiplies both coordinates of this point by a scalar d. Returns a reference to this point.

See also
operator /=(), operator +=()

Definition at line 710 of file Point.h.

◆ operator+()

template<typename T>
GenericPoint pcl::GenericPoint< T >::operator+ ( ) const
inline

Returns a copy of this point.

Definition at line 768 of file Point.h.

◆ operator+=() [1/2]

template<typename T>
template<typename T1 >
GenericPoint& pcl::GenericPoint< T >::operator+= ( const GenericPoint< T1 > &  p)
inline

Adds each coordinate of a given point p to its homonym coordinate in this point. Returns a reference to this point.

See also
MoveBy(), operator -=()

Definition at line 625 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ operator+=() [2/2]

template<typename T>
GenericPoint& pcl::GenericPoint< T >::operator+= ( component  d)
inline

Adds a scalar d to both coordinates of this point. Returns a reference to this point.

See also
MoveBy(), operator -=()

Definition at line 638 of file Point.h.

◆ operator-()

template<typename T>
GenericPoint pcl::GenericPoint< T >::operator- ( ) const
inline

Returns a point whose coordinates have the same magnitudes as the coordinates of this point, but opposite signs. The returned point so defined represents a vector diametrically opposed to this one.

Definition at line 778 of file Point.h.

References pcl::Rad().

◆ operator-=() [1/2]

template<typename T>
template<typename T1 >
GenericPoint& pcl::GenericPoint< T >::operator-= ( const GenericPoint< T1 > &  p)
inline

Subtracts each coordinate of a given point p from its homonym coordinate in this point. Returns a reference to this point.

See also
MoveBy(), operator +=()

Definition at line 661 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ operator-=() [2/2]

template<typename T>
GenericPoint& pcl::GenericPoint< T >::operator-= ( component  d)
inline

Subtracts a scalar d from both coordinates of this point. Returns a reference to this point.

See also
MoveBy(), operator +=()

Definition at line 674 of file Point.h.

◆ operator/=() [1/2]

template<typename T>
template<typename T1 >
GenericPoint& pcl::GenericPoint< T >::operator/= ( const GenericPoint< T1 > &  p)
inline

Divides each coordinate of this point by its homonym coordinate of a given point p. Returns a reference to this point.

See also
operator *=(), operator -=()

Definition at line 733 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ operator/=() [2/2]

template<typename T>
GenericPoint& pcl::GenericPoint< T >::operator/= ( component  d)
inline

Divides both coordinates of this point by a scalar d. Returns a reference to this point.

See also
operator *=(), operator -=()

Definition at line 747 of file Point.h.

◆ operator=() [1/2]

template<typename T>
template<typename T1 >
GenericPoint& pcl::GenericPoint< T >::operator= ( const GenericPoint< T1 > &  p)
inline

Assignment operator. Moves this point to the location specified as a point p. Returns a reference to this point.

See also
MoveTo()

Definition at line 590 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ operator=() [2/2]

template<typename T>
GenericPoint& pcl::GenericPoint< T >::operator= ( component  v)
inline

Assignment operator. Given a coordinate v, moves this point to a location x = y = v. Returns a reference to this point.

See also
MoveTo()

Definition at line 603 of file Point.h.

◆ operator[]() [1/2]

template<typename T>
component& pcl::GenericPoint< T >::operator[] ( int  i)
inline

Returns a reference to a point component. Returns a reference to the X point coordinate if the specified index i is zero, or a reference to the Y coordinate otherwise.

Definition at line 832 of file Point.h.

◆ operator[]() [2/2]

template<typename T>
component pcl::GenericPoint< T >::operator[] ( int  i) const
inline

Returns a copy of a point component. Returns the X point coordinate if the specified index i is zero, or the Y coordinate otherwise.

Definition at line 841 of file Point.h.

◆ Rotate() [1/4]

template<typename T>
template<typename T1 , typename T2 >
void pcl::GenericPoint< T >::Rotate ( T1  angle,
T2  xc,
T2  yc 
)
inline

Rotates this point in the plane by the specified angle in radians, with respect to a center of rotation given by its coordinates xc and yc.

Definition at line 397 of file Point.h.

References pcl::Rotate().

Referenced by pcl::GenericPoint< T >::Rotated().

◆ Rotate() [2/4]

template<typename T>
template<typename T1 , typename T2 >
void pcl::GenericPoint< T >::Rotate ( T1  angle,
const GenericPoint< T2 > &  center 
)
inline

Rotates this point in the plane by the specified angle in radians, with respect to the specified center of rotation.

Definition at line 407 of file Point.h.

References pcl::Rotate(), pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ Rotate() [3/4]

template<typename T>
template<typename T1 , typename T2 >
void pcl::GenericPoint< T >::Rotate ( T1  sa,
T1  ca,
T2  xc,
T2  yc 
)
inline

Rotates this point in the plane by the specified angle, given by its sine and cosine, sa and ca respectively, with respect to a center of rotation given by its coordinates xc and yc.

Definition at line 418 of file Point.h.

References pcl::Rotate().

◆ Rotate() [4/4]

template<typename T>
template<typename T1 , typename T2 >
void pcl::GenericPoint< T >::Rotate ( T1  sa,
T1  ca,
const GenericPoint< T2 > &  center 
)
inline

Rotates this point in the plane by the specified angle, given by its sine and cosine, sa and ca respectively, with respect to the specified center of rotation.

Definition at line 429 of file Point.h.

References pcl::Rotate(), pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ Rotated() [1/4]

template<typename T>
template<typename T1 , typename T2 >
GenericPoint pcl::GenericPoint< T >::Rotated ( T1  angle,
T2  xc,
T2  yc 
) const
inline

Returns a point whose coordinates are the coordinates of this point rotated in the plane by the specified angle in radians, with respect to a center of rotation given by its coordinates xc and yc.

Definition at line 440 of file Point.h.

References pcl::GenericPoint< T >::Rotate().

◆ Rotated() [2/4]

template<typename T>
template<typename T1 , typename T2 >
GenericPoint pcl::GenericPoint< T >::Rotated ( T1  angle,
const GenericPoint< T2 > &  center 
) const
inline

Returns a point whose coordinates are the coordinates of this point rotated in the plane by the specified angle in radians, with respect to the specified center of rotation.

Definition at line 453 of file Point.h.

References pcl::GenericPoint< T >::Rotate().

◆ Rotated() [3/4]

template<typename T>
template<typename T1 , typename T2 >
GenericPoint pcl::GenericPoint< T >::Rotated ( T1  sa,
T1  ca,
T2  xc,
T2  yc 
) const
inline

Returns a point whose coordinates are the coordinates of this point rotated in the plane by the specified angle given by its sine and cosine, sa and ca respectively, with respect to a center of rotation given by its coordinates xc and yc.

Definition at line 467 of file Point.h.

References pcl::GenericPoint< T >::Rotate().

◆ Rotated() [4/4]

template<typename T>
template<typename T1 , typename T2 >
GenericPoint pcl::GenericPoint< T >::Rotated ( T1  sa,
T1  ca,
const GenericPoint< T2 > &  center 
) const
inline

Returns a point whose coordinates are the coordinates of this point rotated in the plane by the specified angle given by its sine and cosine, sa and ca respectively, with respect to the specified center of rotation.

Definition at line 481 of file Point.h.

References pcl::GenericPoint< T >::Rotate().

◆ Round() [1/2]

template<typename T>
void pcl::GenericPoint< T >::Round ( )
inline

Rounds the coordinates of this point to their corresponding nearest integer coordinates.

See also
Round( int ), Rounded(), Truncate(), RoundedToInt(), TruncatedToInt()

Definition at line 494 of file Point.h.

References pcl::Round().

◆ Round() [2/2]

template<typename T>
void pcl::GenericPoint< T >::Round ( int  n)
inline

Rounds the coordinates of this point to n fractional digits (n >= 0).

See also
Round(), Rounded( int ), Truncate(), RoundedToInt(), TruncatedToInt()

Definition at line 505 of file Point.h.

References pcl::Round().

◆ Rounded() [1/2]

template<typename T>
GenericPoint pcl::GenericPoint< T >::Rounded ( ) const
inline

Returns a point whose coordinates are the coordinates of this point rounded to their nearest integers.

See also
Round(), Rounded( int ), Truncated(), RoundedToInt(), TruncatedToInt()

Definition at line 518 of file Point.h.

References pcl::Round().

◆ Rounded() [2/2]

template<typename T>
GenericPoint pcl::GenericPoint< T >::Rounded ( int  n) const
inline

Returns a point whose coordinates are the coordinates of this point rounded to n fractional digits (n >= 0).

See also
Round( int ), Rounded(), Truncated(), RoundedToInt(), TruncatedToInt()

Definition at line 529 of file Point.h.

References pcl::Round().

◆ RoundedToInt()

template<typename T>
GenericPoint<int> pcl::GenericPoint< T >::RoundedToInt ( ) const
inline

Returns a point of integer template type whose coordinates are the coordinates of this point rounded to their nearest integers.

See also
Round(), Rounded(), Truncated(), TruncatedToInt()

Definition at line 541 of file Point.h.

References pcl::RoundInt().

◆ SquaredDistanceTo()

template<typename T>
template<typename T1 >
double pcl::GenericPoint< T >::SquaredDistanceTo ( const GenericPoint< T1 > &  p) const
inline

Returns the square of the Euclidian distance between this point and another point p in the plane.

The Euclidian distance between two points p and q is the length of the straight line between both points: Sqrt( (p.x - q.x)^2 + (p.y - q.y)^2 ).

This function returns just the radicand (p.x - q.x)^2 + (p.y - q.y)^2. This is useful because saves calculation of a square root, which is unnecessary in some practical cases. One of them is ordering of distances: Sqrt(A) < Sqrt(B) implies A < B.

See also
DistanceTo(), ManhattanDistanceTo()

Definition at line 224 of file Point.h.

References pcl::GenericPoint< T >::x, and pcl::GenericPoint< T >::y.

◆ ToDeg()

template<typename T>
GenericPoint& pcl::GenericPoint< T >::ToDeg ( )
inline

Converts the coordinates of this point to degrees, assuming that they are expressed in radians before calling this function. Returns a reference to this object.

Definition at line 820 of file Point.h.

References pcl::Deg().

◆ ToRad()

template<typename T>
GenericPoint& pcl::GenericPoint< T >::ToRad ( )
inline

Converts the coordinates of this point to radians, assuming that they are expressed in degrees before calling this function. Returns a reference to this object.

Definition at line 808 of file Point.h.

References pcl::Rad().

◆ Truncate()

template<typename T>
void pcl::GenericPoint< T >::Truncate ( )
inline

Integer truncation of coordinates. Sets the coordinates x, y of this point to the corresponding nearest integer coordinates i, j, such that i <= x and j <= y.

See also
Truncated(), Round(), RoundedToInt(), TruncatedToInt()

Definition at line 553 of file Point.h.

References pcl::Trunc().

◆ Truncated()

template<typename T>
GenericPoint pcl::GenericPoint< T >::Truncated ( ) const
inline

Integer truncation of coordinates. Returns a point whose coordinates are the coordinates x, y of this point truncated to their corresponding nearest integer coordinates i, j, such that i <= x and j <= y.

See also
Truncate(), Rounded(), RoundedToInt(), TruncatedToInt()

Definition at line 566 of file Point.h.

References pcl::Trunc().

◆ TruncatedToInt()

template<typename T>
GenericPoint<int> pcl::GenericPoint< T >::TruncatedToInt ( ) const
inline

Integer truncation of coordinates. Returns a point of integer template type whose coordinates are the coordinates x, y of this point truncated to the nearest integer coordinates i, j, such that i <= x and j <= y.

See also
Truncate(), Truncated(), Rounded(), RoundedToInt()

Definition at line 578 of file Point.h.

References pcl::TruncInt().


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