C library of triangulation algorithms (for the problems of mobile robot positioning or resection)
easton.c
Go to the documentation of this file.
1 /**
2  * @file easton.c
3  * @date 05/09/2012
4  * @author Vincent Pierlot
5  *
6  * The algorithm was implemented after \cite Easton2006AGaussian.
7 */
8 #include <math.h>
9 #include "const.h"
10 #include "easton.h"
11 
12 tfloat triangulationEaston(tfloat *x, tfloat *y,
13  tfloat alpha1, tfloat alpha2, tfloat alpha3,
14  tfloat x1, tfloat y1, tfloat x2, tfloat y2, tfloat x3, tfloat y3)
15 {
16  tfloat tAB = adjust_value_to_bounds( Tan( alpha1 - alpha2 ) , COT_MAX ) ;
17  tfloat tAC = adjust_value_to_bounds( Tan( alpha1 - alpha3 ) , COT_MAX ) ;
18 
19  tfloat theta = -alpha1 + atan2( (x2*tAB*tAC + y2*tAC - y1*tAC - x3*tAB*tAC - y3*tAB + y1*tAB) , (x2*tAC - y2*tAB*tAC - x1*tAC - x3*tAB + y3*tAB*tAC + x1*tAB)) ;
20 
21  tfloat tTA = adjust_value_to_bounds( Tan( theta + alpha1 ) , COT_MAX ) ;
22  tfloat tTB = adjust_value_to_bounds( Tan( theta + alpha2 ) , COT_MAX ) ;
23 
24  tfloat K = 1 / ( tTA - tTB ) ;
25 
26  *x = K * ( y2 - y1 + x1 * tTA - x2 * tTB ) ;
27  *y = K * ( tTA * tTB * ( x1 - x2 ) + y2 * tTA - y1 * tTB ) ;
28 
29  return K;
30 }
31 
double tfloat
Defines the type for float/double.
Definition: const.h:38