C library of triangulation algorithms (for the problems of mobile robot positioning or resection)
Functions
total.c File Reference

Implementation of the ToTal algorithm. More...

#include <math.h>
#include "const.h"
#include "total.h"
Include dependency graph for total.c:

Go to the source code of this file.

Functions

tfloat triangulationPierlot (tfloat *x, tfloat *y, tfloat alpha1, tfloat alpha2, tfloat alpha3, tfloat x1, tfloat y1, tfloat x2, tfloat y2, tfloat x3, tfloat y3)
 
tfloat triangulationPierlot2 (tfloat *x, tfloat *y, tfloat alpha1, tfloat alpha2, tfloat alpha3, tfloat x1, tfloat y1, tfloat x2, tfloat y2, tfloat x3, tfloat y3)
 

Detailed Description

Implementation of the ToTal algorithm.

Date
15/02/2011 The algorithm was implemented after [12] (published earlier in [13] ). This algorithm was used develop in the context of the Eurobot contest.
Author
Vincent Pierlot

Definition in file total.c.

Function Documentation

tfloat triangulationPierlot ( tfloat x,
tfloat y,
tfloat  alpha1,
tfloat  alpha2,
tfloat  alpha3,
tfloat  x1,
tfloat  y1,
tfloat  x2,
tfloat  y2,
tfloat  x3,
tfloat  y3 
)

Implementation of the ToTal algorithm

Parameters
xHorizontal position of the robot
yVertical position of the robot
alpha1Angle with beacon 1
alpha2Angle with beacon 2
alpha3Angle with beacon 3
x1Horizontal position of beacon 1
y1Vertical position of beacon 1
x2Horizontal position of beacon 2
y2Vertical position of beacon 2
x3Horizontal position of beacon 3
y3Vertical position of beacon 3
Returns
??

Definition at line 16 of file total.c.

References PI.

Referenced by triangulationMethod().

19 {
20  tfloat cot_12 = Cot( alpha2 - alpha1 ) ;
21  tfloat cot_23 = Cot( alpha3 - alpha2 ) ;
22  cot_12 = adjust_value_to_bounds( cot_12 , COT_MAX ) ;
23  cot_23 = adjust_value_to_bounds( cot_23 , COT_MAX ) ;
24  tfloat cot_31 = ( 1.0 - cot_12 * cot_23 ) / ( cot_12 + cot_23 ) ;
25  cot_31 = adjust_value_to_bounds( cot_31 , COT_MAX ) ;
26 
27  tfloat x1_ = x1 - x2 , y1_ = y1 - y2 , x3_ = x3 - x2 , y3_ = y3 - y2 ;
28 
29  tfloat c12x = x1_ + cot_12 * y1_ ;
30  tfloat c12y = y1_ - cot_12 * x1_ ;
31 
32  tfloat c23x = x3_ - cot_23 * y3_ ;
33  tfloat c23y = y3_ + cot_23 * x3_ ;
34 
35  tfloat c31x = (x3_ + x1_) + cot_31 * (y3_ - y1_) ;
36  tfloat c31y = (y3_ + y1_) - cot_31 * (x3_ - x1_) ;
37  tfloat k31 = (x3_ * x1_) + (y3_ * y1_) + cot_31 * ( (y3_ * x1_) - (x3_ * y1_) ) ;
38 
39  tfloat D = (c12x - c23x) * (c23y - c31y) - (c23x - c31x) * (c12y - c23y) ;
40  tfloat invD = 1.0 / D ;
41  tfloat K = k31 * invD ;
42 
43  *x = K * (c12y - c23y) + x2 ;
44  *y = K * (c23x - c12x) + y2 ;
45 
46  return invD ; /* return 1/D */
47 }
double tfloat
Defines the type for float/double.
Definition: const.h:38