Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
vpTriangle Class Reference

#include <visp3/core/vpTriangle.h>

Public Member Functions

 vpTriangle ()
 
 vpTriangle (const vpTriangle &tri)
 
virtual ~vpTriangle ()
 
vpTriangleoperator= (const vpTriangle &tri)
 
 vpTriangle (const vpImagePoint &iP1, const vpImagePoint &iP2, const vpImagePoint &iP3)
 
void buildFrom (const vpImagePoint &iP1, const vpImagePoint &iP2, const vpImagePoint &iP3)
 
bool inTriangle (const vpImagePoint &iP, double threshold=0.00001)
 
void getTriangleApexes (vpImagePoint &iP1, vpImagePoint &iP2, vpImagePoint &iP3) const
 
double getArea () const
 

Detailed Description

Defines a 2D triangle.

A triangle is internally represented by three 2D points.

By default the three coordinates in the $ (i,j) $ frame (see vpImagePoint class documentation for more details about the frame.) are $ (0,0) $, $ (1,0) $ and $ (0,1) $.

Definition at line 58 of file vpTriangle.h.

Constructor & Destructor Documentation

vpTriangle::vpTriangle ( )

Basic constructor.

By default, the three 2D points coordinates which define the triangle are $ (0,0) $, $ (1,0) $ and $ (0,1) $.

Definition at line 49 of file vpTriangle.cpp.

vpTriangle::vpTriangle ( const vpTriangle tri)

Copy constructor

Parameters
tri: The triangle used for the initialisation.

Definition at line 76 of file vpTriangle.cpp.

vpTriangle::~vpTriangle ( )
virtual

Basic destructor

Definition at line 86 of file vpTriangle.cpp.

vpTriangle::vpTriangle ( const vpImagePoint iP1,
const vpImagePoint iP2,
const vpImagePoint iP3 
)

Constructor which initialise the triangle thanks to the three 2D points $ iP1 $, $ iP2 $ and $ iP3 $

Parameters
iP1: The first apex of the triangle.
iP2: The first apex of the triangle.
iP3: The first apex of the triangle.

Definition at line 64 of file vpTriangle.cpp.

Member Function Documentation

void vpTriangle::buildFrom ( const vpImagePoint iP1,
const vpImagePoint iP2,
const vpImagePoint iP3 
)

Initialise the triangle thanks to the three 2D points $ iP1 $, $ iP2 $ and $ iP3 $

Parameters
iP1: The first apex of the triangle.
iP2: The first apex of the triangle.
iP3: The first apex of the triangle.

Definition at line 116 of file vpTriangle.cpp.

References vpMatrix::det(), vpImagePoint::get_i(), vpImagePoint::get_j(), and vpMatrix::inverseByLU().

double vpTriangle::getArea ( ) const
inline

Return the area of the triangle. The area is computed when the triangle is built from three image points.

Returns
The area of the triangle.

Definition at line 107 of file vpTriangle.h.

void vpTriangle::getTriangleApexes ( vpImagePoint iP1,
vpImagePoint iP2,
vpImagePoint iP3 
) const
inline

Get the apexes of the triangle.

Parameters
iP1: first apex.
iP2: second apex.
iP3: third apex.

Definition at line 94 of file vpTriangle.h.

bool vpTriangle::inTriangle ( const vpImagePoint iP,
double  threshold = 0.00001 
)

Check if the 2D point $ iP $ is inside the triangle.

Parameters
iP: The point which coulb be inside the triangle.
threshold: A threshold used to define the accuracy of the computation when the point is very near from the edges of the triangle. 0 is the smallest value.
Returns
Returns true if the point is inside the triangle. Returns false otherwise.

Definition at line 162 of file vpTriangle.cpp.

References vpImagePoint::get_i(), and vpImagePoint::get_j().

vpTriangle & vpTriangle::operator= ( const vpTriangle tri)

Assign tri to this triangle and return a reference to this triangle.

Definition at line 91 of file vpTriangle.cpp.