Visual Servoing Platform  version 3.6.1 under development (2024-12-12)
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)
 
vpTrianglebuildFrom (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 53 of file vpTriangle.h.

Constructor & Destructor Documentation

◆ vpTriangle() [1/3]

BEGIN_VISP_NAMESPACE 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 46 of file vpTriangle.cpp.

◆ vpTriangle() [2/3]

vpTriangle::vpTriangle ( const vpTriangle tri)

Copy constructor

Parameters
tri: The triangle used for the initialisation.

Definition at line 73 of file vpTriangle.cpp.

◆ ~vpTriangle()

vpTriangle::~vpTriangle ( )
virtual

Basic destructor

Definition at line 83 of file vpTriangle.cpp.

◆ vpTriangle() [3/3]

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 61 of file vpTriangle.cpp.

Member Function Documentation

◆ buildFrom()

vpTriangle & 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 113 of file vpTriangle.cpp.

◆ getArea()

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 102 of file vpTriangle.h.

◆ getTriangleApexes()

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 89 of file vpTriangle.h.

◆ inTriangle()

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 161 of file vpTriangle.cpp.

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

◆ operator=()

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

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

Definition at line 88 of file vpTriangle.cpp.