45 for (
int i = 0; i < 3; i++) {
46 P[i][0] = anchors[i].
pos.
x;
47 P[i][1] = anchors[i].
pos.
y;
48 P[i][2] = anchors[i].
pos.
z;
75 Ez[1] =
Ex[2]*Ey[0] -
Ex[0]*Ey[2];
76 Ez[2] =
Ex[0]*Ey[1] -
Ex[1]*Ey[0];
95 const float d2 =
D *
D;
96 const float i2 =
I *
I;
97 const float j2 =
J *
J;
99 tmp[0] = (r02 - r12 +
d2) / (2.f * D);
100 tmp[1] = (r02 - r22 + i2 + j2) / (2.f * J) - ((I * tmp[0]) / J);
101 const float d0 = r02 - (tmp[0] * tmp[0]) - (tmp[1] * tmp[1]);
110 pos->
x =
P[0][0] + tmp[0] *
Ex[0] + tmp[1] *
Ey[0] + tmp[2] *
Ez[0];
111 pos->
y =
P[0][1] + tmp[0] *
Ex[1] + tmp[1] *
Ey[1] + tmp[2] * Ez[1];
112 pos->
z =
P[0][2] + tmp[0] *
Ex[2] + tmp[1] *
Ey[2] + tmp[2] * Ez[2];
static float float_vect_norm(const float *a, const int n)
||a||
int trilateration_compute(struct Anchor *anchors, struct EnuCoor_f *pos)
Compute trilateration based on the latest measurments.
static void float_vect_add(float *a, const float *b, const int n)
a += b
vector in East North Up coordinates Units: meters
int trilateration_init(struct Anchor *anchors)
Init internal trilateration structures.
static void float_vect_sdiv(float *o, const float *a, const float s, const int n)
o = a / s
Paparazzi floating point algebra.
static void float_vect_smul(float *o, const float *a, const float s, const int n)
o = a * s
float distance
last measured distance
static void float_vect_diff(float *o, const float *a, const float *b, const int n)
o = a - b
struct EnuCoor_f pos
position of the anchor
static float float_vect_dot_product(const float *a, const float *b, const int n)
a.b