|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
80 m_a2c->
m[0] = m_b2c->
m[0] * m_a2b->
m[0] + m_b2c->
m[1] * m_a2b->
m[3] + m_b2c->
m[2] * m_a2b->
m[6];
81 m_a2c->
m[1] = m_b2c->
m[0] * m_a2b->
m[1] + m_b2c->
m[1] * m_a2b->
m[4] + m_b2c->
m[2] * m_a2b->
m[7];
82 m_a2c->
m[2] = m_b2c->
m[0] * m_a2b->
m[2] + m_b2c->
m[1] * m_a2b->
m[5] + m_b2c->
m[2] * m_a2b->
m[8];
83 m_a2c->
m[3] = m_b2c->
m[3] * m_a2b->
m[0] + m_b2c->
m[4] * m_a2b->
m[3] + m_b2c->
m[5] * m_a2b->
m[6];
84 m_a2c->
m[4] = m_b2c->
m[3] * m_a2b->
m[1] + m_b2c->
m[4] * m_a2b->
m[4] + m_b2c->
m[5] * m_a2b->
m[7];
85 m_a2c->
m[5] = m_b2c->
m[3] * m_a2b->
m[2] + m_b2c->
m[4] * m_a2b->
m[5] + m_b2c->
m[5] * m_a2b->
m[8];
86 m_a2c->
m[6] = m_b2c->
m[6] * m_a2b->
m[0] + m_b2c->
m[7] * m_a2b->
m[3] + m_b2c->
m[8] * m_a2b->
m[6];
87 m_a2c->
m[7] = m_b2c->
m[6] * m_a2b->
m[1] + m_b2c->
m[7] * m_a2b->
m[4] + m_b2c->
m[8] * m_a2b->
m[7];
88 m_a2c->
m[8] = m_b2c->
m[6] * m_a2b->
m[2] + m_b2c->
m[7] * m_a2b->
m[5] + m_b2c->
m[8] * m_a2b->
m[8];
96 m_a2b->
m[0] = m_b2c->
m[0] * m_a2c->
m[0] + m_b2c->
m[3] * m_a2c->
m[3] + m_b2c->
m[6] * m_a2c->
m[6];
97 m_a2b->
m[1] = m_b2c->
m[0] * m_a2c->
m[1] + m_b2c->
m[3] * m_a2c->
m[4] + m_b2c->
m[6] * m_a2c->
m[7];
98 m_a2b->
m[2] = m_b2c->
m[0] * m_a2c->
m[2] + m_b2c->
m[3] * m_a2c->
m[5] + m_b2c->
m[6] * m_a2c->
m[8];
99 m_a2b->
m[3] = m_b2c->
m[1] * m_a2c->
m[0] + m_b2c->
m[4] * m_a2c->
m[3] + m_b2c->
m[7] * m_a2c->
m[6];
100 m_a2b->
m[4] = m_b2c->
m[1] * m_a2c->
m[1] + m_b2c->
m[4] * m_a2c->
m[4] + m_b2c->
m[7] * m_a2c->
m[7];
101 m_a2b->
m[5] = m_b2c->
m[1] * m_a2c->
m[2] + m_b2c->
m[4] * m_a2c->
m[5] + m_b2c->
m[7] * m_a2c->
m[8];
102 m_a2b->
m[6] = m_b2c->
m[2] * m_a2c->
m[0] + m_b2c->
m[5] * m_a2c->
m[3] + m_b2c->
m[8] * m_a2c->
m[6];
103 m_a2b->
m[7] = m_b2c->
m[2] * m_a2c->
m[1] + m_b2c->
m[5] * m_a2c->
m[4] + m_b2c->
m[8] * m_a2c->
m[7];
104 m_a2b->
m[8] = m_b2c->
m[2] * m_a2c->
m[2] + m_b2c->
m[5] * m_a2c->
m[5] + m_b2c->
m[8] * m_a2c->
m[8];
112 vb->
x = m_a2b->
m[0] * va->
x + m_a2b->
m[1] * va->
y + m_a2b->
m[2] * va->
z;
113 vb->
y = m_a2b->
m[3] * va->
x + m_a2b->
m[4] * va->
y + m_a2b->
m[5] * va->
z;
114 vb->
z = m_a2b->
m[6] * va->
x + m_a2b->
m[7] * va->
y + m_a2b->
m[8] * va->
z;
122 vb->
x = m_b2a->
m[0] * va->
x + m_b2a->
m[3] * va->
y + m_b2a->
m[6] * va->
z;
123 vb->
y = m_b2a->
m[1] * va->
x + m_b2a->
m[4] * va->
y + m_b2a->
m[7] * va->
z;
124 vb->
z = m_b2a->
m[2] * va->
x + m_b2a->
m[5] * va->
y + m_b2a->
m[8] * va->
z;
132 rb->
phi = m_a2b->
m[0] * ra->
phi + m_a2b->
m[1] * ra->
theta + m_a2b->
m[2] * ra->
psi;
134 rb->
psi = m_a2b->
m[6] * ra->
phi + m_a2b->
m[7] * ra->
theta + m_a2b->
m[8] * ra->
psi;
142 rb->
phi = m_b2a->
m[0] * ra->
phi + m_b2a->
m[3] * ra->
theta + m_b2a->
m[6] * ra->
psi;
144 rb->
psi = m_b2a->
m[2] * ra->
phi + m_b2a->
m[5] * ra->
theta + m_b2a->
m[8] * ra->
psi;
152 rb->
p = m_a2b->
m[0] * ra->
p + m_a2b->
m[1] * ra->
q + m_a2b->
m[2] * ra->
r;
153 rb->
q = m_a2b->
m[3] * ra->
p + m_a2b->
m[4] * ra->
q + m_a2b->
m[5] * ra->
r;
154 rb->
r = m_a2b->
m[6] * ra->
p + m_a2b->
m[7] * ra->
q + m_a2b->
m[8] * ra->
r;
162 rb->
p = m_b2a->
m[0] * ra->
p + m_b2a->
m[3] * ra->
q + m_b2a->
m[6] * ra->
r;
163 rb->
q = m_b2a->
m[1] * ra->
p + m_b2a->
m[4] * ra->
q + m_b2a->
m[7] * ra->
r;
164 rb->
r = m_b2a->
m[2] * ra->
p + m_b2a->
m[5] * ra->
q + m_b2a->
m[8] * ra->
r;
171 const float ux2 = uv->
x * uv->
x;
172 const float uy2 = uv->
y * uv->
y;
173 const float uz2 = uv->
z * uv->
z;
174 const float uxuy = uv->
x * uv->
y;
175 const float uyuz = uv->
y * uv->
z;
176 const float uxuz = uv->
x * uv->
z;
177 const float can = cosf(angle);
178 const float san = sinf(angle);
179 const float one_m_can = (1. - can);
181 RMAT_ELMT(*rm, 0, 0) = ux2 + (1. - ux2) * can;
182 RMAT_ELMT(*rm, 0, 1) = uxuy * one_m_can + uv->
z * san;
183 RMAT_ELMT(*rm, 0, 2) = uxuz * one_m_can - uv->
y * san;
185 RMAT_ELMT(*rm, 1, 1) = uy2 + (1. - uy2) * can;
186 RMAT_ELMT(*rm, 1, 2) = uyuz * one_m_can + uv->
x * san;
189 RMAT_ELMT(*rm, 2, 2) = uz2 + (1. - uz2) * can;
196 const float sphi = sinf(e->
phi);
197 const float cphi = cosf(e->
phi);
198 const float stheta = sinf(e->
theta);
199 const float ctheta = cosf(e->
theta);
200 const float spsi = sinf(e->
psi);
201 const float cpsi = cosf(e->
psi);
206 RMAT_ELMT(*rm, 1, 0) = sphi * stheta * cpsi - cphi * spsi;
207 RMAT_ELMT(*rm, 1, 1) = sphi * stheta * spsi + cphi * cpsi;
209 RMAT_ELMT(*rm, 2, 0) = cphi * stheta * cpsi + sphi * spsi;
210 RMAT_ELMT(*rm, 2, 1) = cphi * stheta * spsi - sphi * cpsi;
216 const float sphi = sinf(e->
phi);
217 const float cphi = cosf(e->
phi);
218 const float stheta = sinf(e->
theta);
219 const float ctheta = cosf(e->
theta);
220 const float spsi = sinf(e->
psi);
221 const float cpsi = cosf(e->
psi);
223 RMAT_ELMT(*rm, 0, 0) = ctheta * cpsi - sphi * stheta * spsi;
224 RMAT_ELMT(*rm, 0, 1) = ctheta * spsi + sphi * stheta * cpsi;
229 RMAT_ELMT(*rm, 2, 0) = stheta * cpsi + sphi * ctheta * spsi;
230 RMAT_ELMT(*rm, 2, 1) = stheta * spsi - sphi * ctheta * cpsi;
242 const float a2_1 = _a * _a - 1;
243 const float ab = _a * _b;
244 const float ac = _a * _c;
245 const float ad = _a * _d;
246 const float bc = _b * _c;
247 const float bd = _b * _d;
248 const float cd = _c * _d;
265 1. , dt *omega->
r, -dt *omega->
q,
266 -dt *omega->
r, 1. , dt *omega->
p,
267 dt *omega->
q, -dt *omega->
p, 1.
272 memcpy(rm, &R_tdt,
sizeof(R_tdt));
277 if (n < 1.5625f && n > 0.64
f) {
279 }
else if (n < 100.0f && n > 0.01
f) {
280 return 1. / sqrtf(n);
322 a2c->
qi = a2b->
qi * b2c->
qi - a2b->
qx * b2c->
qx - a2b->
qy * b2c->
qy - a2b->
qz * b2c->
qz;
323 a2c->
qx = a2b->
qi * b2c->
qx + a2b->
qx * b2c->
qi + a2b->
qy * b2c->
qz - a2b->
qz * b2c->
qy;
324 a2c->
qy = a2b->
qi * b2c->
qy - a2b->
qx * b2c->
qz + a2b->
qy * b2c->
qi + a2b->
qz * b2c->
qx;
325 a2c->
qz = a2b->
qi * b2c->
qz + a2b->
qx * b2c->
qy - a2b->
qy * b2c->
qx + a2b->
qz * b2c->
qi;
330 a2b->
qi = a2c->
qi * b2c->
qi + a2c->
qx * b2c->
qx + a2c->
qy * b2c->
qy + a2c->
qz * b2c->
qz;
331 a2b->
qx = -a2c->
qi * b2c->
qx + a2c->
qx * b2c->
qi - a2c->
qy * b2c->
qz + a2c->
qz * b2c->
qy;
332 a2b->
qy = -a2c->
qi * b2c->
qy + a2c->
qx * b2c->
qz + a2c->
qy * b2c->
qi - a2c->
qz * b2c->
qx;
333 a2b->
qz = -a2c->
qi * b2c->
qz - a2c->
qx * b2c->
qy + a2c->
qy * b2c->
qx + a2c->
qz * b2c->
qi;
338 b2c->
qi = a2b->
qi * a2c->
qi + a2b->
qx * a2c->
qx + a2b->
qy * a2c->
qy + a2b->
qz * a2c->
qz;
339 b2c->
qx = a2b->
qi * a2c->
qx - a2b->
qx * a2c->
qi - a2b->
qy * a2c->
qz + a2b->
qz * a2c->
qy;
340 b2c->
qy = a2b->
qi * a2c->
qy + a2b->
qx * a2c->
qz - a2b->
qy * a2c->
qi - a2b->
qz * a2c->
qx;
341 b2c->
qz = a2b->
qi * a2c->
qz - a2b->
qx * a2c->
qy + a2b->
qy * a2c->
qx - a2b->
qz * a2c->
qi;
367 const float v_norm = sqrtf(w->
p * w->
p + w->
q * w->
q + w->
r * w->
r);
368 const float c2 = cos(dt * v_norm / 2.0);
369 const float s2 = sin(dt * v_norm / 2.0);
377 q_out->
qx = w->
p / v_norm *
s2;
378 q_out->
qy = w->
q / v_norm *
s2;
379 q_out->
qz = w->
r / v_norm *
s2;
386 const float qi = q->
qi;
387 const float qx = q->
qx;
388 const float qy = q->
qy;
389 const float qz = q->
qz;
390 const float dp = 0.5 * dt * omega->
p;
391 const float dq = 0.5 * dt * omega->
q;
392 const float dr = 0.5 * dt * omega->
r;
393 q->
qi = qi - dp * qx - dq * qy - dr * qz;
394 q->
qx = dp * qi + qx + dr * qy - dq * qz;
395 q->
qy = dq * qi - dr * qx + qy + dp * qz;
396 q->
qz = dr * qi + dq * qx - dp * qy + qz;
404 const float a = 0.5 * no * dt;
405 const float ca = cosf(a);
406 const float sa_ov_no = sinf(a) / no;
407 const float dp = sa_ov_no * omega->
p;
408 const float dq = sa_ov_no * omega->
q;
409 const float dr = sa_ov_no * omega->
r;
410 const float qi = q->
qi;
411 const float qx = q->
qx;
412 const float qy = q->
qy;
413 const float qz = q->
qz;
414 q->
qi = ca * qi - dp * qx - dq * qy - dr * qz;
415 q->
qx = dp * qi + ca * qx + dr * qy - dq * qz;
416 q->
qy = dq * qi - dr * qx + ca * qy + dp * qz;
417 q->
qz = dr * qi + dq * qx - dp * qy + ca * qz;
423 const float qi2_M1_2 = q->
qi * q->
qi - 0.5;
424 const float qiqx = q->
qi * q->
qx;
425 const float qiqy = q->
qi * q->
qy;
426 const float qiqz = q->
qi * q->
qz;
427 float m01 = q->
qx * q->
qy;
428 float m02 = q->
qx * q->
qz;
429 float m12 = q->
qy * q->
qz;
431 const float m00 = qi2_M1_2 + q->
qx * q->
qx;
432 const float m10 = m01 - qiqz;
433 const float m20 = m02 + qiqy;
434 const float m21 = m12 - qiqx;
438 const float m11 = qi2_M1_2 + q->
qy * q->
qy;
439 const float m22 = qi2_M1_2 + q->
qz * q->
qz;
440 v_out->
x = 2 * (m00 * v_in->
x + m01 * v_in->
y + m02 * v_in->
z);
441 v_out->
y = 2 * (m10 * v_in->
x + m11 * v_in->
y + m12 * v_in->
z);
442 v_out->
z = 2 * (m20 * v_in->
x + m21 * v_in->
y + m22 * v_in->
z);
452 qd->
qi = -0.5 * (r->
p * q->
qx + r->
q * q->
qy + r->
r * q->
qz);
453 qd->
qx = -0.5 * (-r->
p * q->
qi - r->
r * q->
qy + r->
q * q->
qz);
454 qd->
qy = -0.5 * (-r->
q * q->
qi + r->
r * q->
qx - r->
p * q->
qz);
455 qd->
qz = -0.5 * (-r->
r * q->
qi - r->
q * q->
qx + r->
p * q->
qy);
463 const float K_LAGRANGE = 1.;
465 qd->
qi = -0.5 * (
c * q->
qi + r->
p * q->
qx + r->
q * q->
qy + r->
r * q->
qz);
466 qd->
qx = -0.5 * (-r->
p * q->
qi +
c * q->
qx - r->
r * q->
qy + r->
q * q->
qz);
467 qd->
qy = -0.5 * (-r->
q * q->
qi + r->
r * q->
qx +
c * q->
qy - r->
p * q->
qz);
468 qd->
qz = -0.5 * (-r->
r * q->
qi - r->
q * q->
qx + r->
p * q->
qy +
c * q->
qz);
480 const float phi2 = e->
phi / 2.f;
481 const float theta2 = e->
theta / 2.f;
482 const float psi2 = e->
psi / 2.f;
484 const float s_phi2 = sinf(phi2);
485 const float c_phi2 = cosf(phi2);
486 const float s_theta2 = sinf(theta2);
487 const float c_theta2 = cosf(theta2);
488 const float s_psi2 = sinf(psi2);
489 const float c_psi2 = cosf(psi2);
491 q->
qi = c_phi2 * c_theta2 * c_psi2 + s_phi2 * s_theta2 * s_psi2;
492 q->
qx = -c_phi2 * s_theta2 * s_psi2 + s_phi2 * c_theta2 * c_psi2;
493 q->
qy = c_phi2 * s_theta2 * c_psi2 + s_phi2 * c_theta2 * s_psi2;
494 q->
qz = c_phi2 * c_theta2 * s_psi2 - s_phi2 * s_theta2 * c_psi2;
506 const float phi2 = e->
phi / 2.f;
507 const float theta2 = e->
theta / 2.f;
508 const float psi2 = e->
psi / 2.f;
510 const float s_phi2 = sinf(phi2);
511 const float c_phi2 = cosf(phi2);
512 const float s_theta2 = sinf(theta2);
513 const float c_theta2 = cosf(theta2);
514 const float s_psi2 = sinf(psi2);
515 const float c_psi2 = cosf(psi2);
517 q->
qi = c_phi2 * c_theta2 * c_psi2 - s_phi2 * s_theta2 * s_psi2;
518 q->
qx = s_phi2 * c_theta2 * c_psi2 - c_phi2 * s_theta2 * s_psi2;
519 q->
qy = c_phi2 * s_theta2 * c_psi2 + s_phi2 * c_theta2 * s_psi2;
520 q->
qz = s_phi2 * s_theta2 * c_psi2 + c_phi2 * c_theta2 * s_psi2;
534 const float phi2 = e->
phi / 2.f;
535 const float theta2 = e->
theta / 2.f;
536 const float psi2 = e->
psi / 2.f;
538 const float s_phi2 = sinf(phi2);
539 const float c_phi2 = cosf(phi2);
540 const float s_theta2 = sinf(theta2);
541 const float c_theta2 = cosf(theta2);
542 const float s_psi2 = sinf(psi2);
543 const float c_psi2 = cosf(psi2);
545 q->
qi = c_theta2 * c_phi2 * c_psi2 + s_theta2 * s_phi2 * s_psi2;
546 q->
qx = c_theta2 * s_phi2 * c_psi2 + s_theta2 * c_phi2 * s_psi2;
547 q->
qy = s_theta2 * c_phi2 * c_psi2 - c_theta2 * s_phi2 * s_psi2;
548 q->
qz = c_theta2 * c_phi2 * s_psi2 - s_theta2 * s_phi2 * c_psi2;
553 const float san = sinf(angle / 2.
f);
554 q->
qi = cosf(angle / 2.
f);
562 const float ov_norm = sqrtf(ov->
x * ov->
x + ov->
y * ov->
y + ov->
z * ov->
z);
563 if (ov_norm < 1e-8) {
569 const float s2_normalized = sinf(ov_norm / 2.0) / ov_norm;
570 q->
qi = cosf(ov_norm / 2.0);
571 q->
qx = ov->
x * s2_normalized;
572 q->
qy = ov->
y * s2_normalized;
573 q->
qz = ov->
z * s2_normalized;
581 const float two_qi = sqrtf(1. + tr);
582 const float four_qi = 2. * two_qi;
583 q->
qi = 0.5 * two_qi;
593 const float four_qx = 2. * two_qx;
595 q->
qx = 0.5 * two_qx;
602 const float four_qy = 2. * two_qy;
605 q->
qy = 0.5 * two_qy;
611 const float four_qz = 2. * two_qz;
615 q->
qz = 0.5 * two_qz;
630 const float dcm00 = rm->
m[0];
631 const float dcm01 = rm->
m[1];
632 float dcm02 = rm->
m[2];
633 const float dcm12 = rm->
m[5];
634 const float dcm22 = rm->
m[8];
637 BoundAbs(dcm02, 1.0);
639 e->
phi = atan2f(dcm12, dcm22);
640 e->
theta = -asinf(dcm02);
641 e->
psi = atan2f(dcm01, dcm00);
652 const float qx2 = q->
qx * q->
qx;
653 const float qy2 = q->
qy * q->
qy;
654 const float qz2 = q->
qz * q->
qz;
655 const float qiqx = q->
qi * q->
qx;
656 const float qiqy = q->
qi * q->
qy;
657 const float qiqz = q->
qi * q->
qz;
658 const float qxqy = q->
qx * q->
qy;
659 const float qxqz = q->
qx * q->
qz;
660 const float qyqz = q->
qy * q->
qz;
661 const float dcm00 = 1.0 - 2.*(qy2 + qz2);
662 const float dcm01 = 2.*(qxqy + qiqz);
663 float dcm02 = 2.*(qxqz - qiqy);
664 const float dcm12 = 2.*(qyqz + qiqx);
665 const float dcm22 = 1.0 - 2.*(qx2 + qy2);
668 BoundAbs(dcm02, 1.0);
670 e->
phi = atan2f(dcm12, dcm22);
671 e->
theta = -asinf(dcm02);
672 e->
psi = atan2f(dcm01, dcm00);
686 const float qx2 = q->
qx * q->
qx;
687 const float qy2 = q->
qy * q->
qy;
688 const float qz2 = q->
qz * q->
qz;
689 const float qi2 = q->
qi * q->
qi;
690 const float qiqx = q->
qi * q->
qx;
691 const float qiqy = q->
qi * q->
qy;
692 const float qiqz = q->
qi * q->
qz;
693 const float qxqy = q->
qx * q->
qy;
694 const float qxqz = q->
qx * q->
qz;
695 const float qyqz = q->
qy * q->
qz;
696 const float r11 = 2.f * (qxqz + qiqy);
697 const float r12 = qi2 - qx2 + qy2 + qz2;
698 float r21 = -2.f * (qyqz - qiqx);
699 const float r31 = 2.f * (qxqy + qiqz);
700 const float r32 = qi2 - qx2 + qy2 - qz2;
705 e->
theta = atan2f(r11, r12);
707 e->
psi = atan2f(r31, r32);
719 const float qx2 = q->
qx * q->
qx;
720 const float qy2 = q->
qy * q->
qy;
721 const float qz2 = q->
qz * q->
qz;
722 const float qi2 = q->
qi * q->
qi;
723 const float qiqx = q->
qi * q->
qx;
724 const float qiqy = q->
qi * q->
qy;
725 const float qiqz = q->
qi * q->
qz;
726 const float qxqy = q->
qx * q->
qy;
727 const float qxqz = q->
qx * q->
qz;
728 const float qyqz = q->
qy * q->
qz;
729 const float r11 = -2 * (qxqy - qiqz);
730 const float r12 = qi2 - qx2 + qy2 - qz2;
731 float r21 = 2 * (qyqz + qiqx);
732 const float r31 = -2 * (qxqz - qiqy);
733 const float r32 = qi2 - qx2 - qy2 + qz2;
738 e->
psi = atan2f(r11, r12);
740 e->
theta = atan2f(r31, r32);
753 float det = mat_in[0] * mat_in[3] - mat_in[1] * mat_in[2];
755 if (fabsf(det) < 1e-4) {
return 1; }
757 inv_out[0] = mat_in[3] / det;
758 inv_out[1] = -mat_in[1] / det;
759 inv_out[2] = -mat_in[2] / det;
760 inv_out[3] = mat_in[0] / det;
774 vect_out->
x = mat[0] * vect_in.
x + mat[1] * vect_in.
y;
775 vect_out->
y = mat[2] * vect_in.
x + mat[3] * vect_in.
y;
785 return m[4 * r0 + c0] * (m[4 * r1 +
c1] * m[4 * r2 +
c2] - m[4 * r2 +
c1] * m[4 * r1 +
c2]) -
786 m[4 * r0 +
c1] * (m[4 * r1 + c0] * m[4 * r2 +
c2] - m[4 * r2 + c0] * m[4 * r1 +
c2]) +
787 m[4 * r0 +
c2] * (m[4 * r1 + c0] * m[4 * r2 +
c1] - m[4 * r2 + c0] * m[4 * r1 +
c1]);
830 if (fabsf(det) < 1e-4) {
return 1; }
832 float inv_det = 1.0f / det;
834 for (i = 0; i < 16; ++i) {
835 invOut[i] = invOut[i] * inv_det;
852 for (i = 0; i < n; i++) {
853 for (j = 0; j < 2 * n; j++) {
856 }
else if ((j >= n) && (j == i + n)) {
865 for (i = 0; i < n; i++) {
868 for (j = i; j < 2 * n; j++) {
869 a[i][j] = a[i][j] / t;
872 for (j = 0; j < n; j++) {
875 for (k = 0; k < 2 * n; k++) {
876 a[j][k] = a[j][k] - t * a[i][k];
883 for (i = 0 ; i < n ; i++) {
884 for (j = n; j < 2 * n; j++) {
885 o[i][j - n] = a[i][j];
920 t = 1.0 / powf(2.0,
s);
932 for (k = 2; k <= q; k++) {
933 c =
c * (float)(q - k + 1) / (float)(k * (2 * q - k + 1));
953 for (k = 1; k <=
s; k++) {
966 for (
int i = 0; i < m; i++) {
968 for (
int j = 0; j < n; j++) {
969 row_sum = row_sum + fabsf(a[i][j]);
971 value =
Max(value, row_sum);
980 float scale = bound/norm;
990 float scale = norm_des/norm;
static float float_mat_minor_4d(float m[16], int r0, int r1, int r2, int c0, int c1, int c2)
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
void float_quat_integrate_fi(struct FloatQuat *q, struct FloatRates *omega, float dt)
in place first order quaternion integration with constant rotational velocity
static void float_mat_scale(float **a, float k, int m, int n)
a *= k, where k is a scalar value
void float_mat_exp(float **a, float **o, int n)
void float_quat_comp(struct FloatQuat *a2c, struct FloatQuat *a2b, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions.
#define FLOAT_RATES_NORM(_v)
void float_eulers_of_rmat(struct FloatEulers *e, struct FloatRMat *rm)
static const float scale[]
float float_rmat_norm(struct FloatRMat *rm)
Norm of a rotation matrix.
void float_mat_invert(float **o, float **mat, int n)
Calculate inverse of any n x n matrix (passed as C array) o = mat^-1 Algorithm verified with Matlab.
#define MAKE_MATRIX_PTR(_ptr, _mat, _rows)
Make a pointer to a matrix of _rows lines.
#define VECT3_CROSS_PRODUCT(_vo, _v1, _v2)
void float_rmat_mult(struct FloatEulers *rb, struct FloatRMat *m_a2b, struct FloatEulers *ra)
rotate angle by rotation matrix.
static void float_mat_diagonal_scal(float **o, float v, int n)
Make an n x n identity matrix (for matrix passed as array)
static void float_mat_copy(float **a, float **b, int m, int n)
a = b
#define MAT33_ROW_VECT3_SMUL(_mat, _row, _vin, _s)
void float_vect3_integrate_fi(struct FloatVect3 *vec, struct FloatVect3 *dv, float dt)
in place first order integration of a 3D-vector
bool float_mat_inv_4d(float invOut[16], float mat_in[16])
4x4 Matrix inverse
#define VECT3_DOT_PRODUCT(_v1, _v2)
Paparazzi floating point algebra.
static void float_mat_adjoint_4d(float adjOut[16], float m[16])
void float_rmat_comp_inv(struct FloatRMat *m_a2b, struct FloatRMat *m_a2c, struct FloatRMat *m_b2c)
Composition (multiplication) of two rotation matrices.
static float float_mat_det_4d(float m[16])
void float_rmat_integrate_fi(struct FloatRMat *rm, struct FloatRates *omega, float dt)
in place first order integration of a rotation matrix
void float_rmat_transp_mult(struct FloatEulers *rb, struct FloatRMat *m_b2a, struct FloatEulers *ra)
rotate angle by transposed rotation matrix.
void float_quat_inv_comp(struct FloatQuat *b2c, struct FloatQuat *a2b, struct FloatQuat *a2c)
Composition (multiplication) of two quaternions.
void float_rmat_transp_vmult(struct FloatVect3 *vb, struct FloatRMat *m_b2a, struct FloatVect3 *va)
rotate 3D vector by transposed rotation matrix.
void float_rmat_vmult(struct FloatVect3 *vb, struct FloatRMat *m_a2b, struct FloatVect3 *va)
rotate 3D vector by rotation matrix.
void float_quat_of_eulers_zxy(struct FloatQuat *q, struct FloatEulers *e)
quat from euler rotation 'ZXY' This rotation order is useful if you need 90 deg pitch
bool float_mat_inv_2d(float inv_out[4], float mat_in[4])
2x2 matrix inverse
void float_rmat_of_eulers_312(struct FloatRMat *rm, struct FloatEulers *e)
#define FLOAT_VECT2_NORM(_v)
void float_mat2_mult(struct FloatVect2 *vect_out, float mat[4], struct FloatVect2 vect_in)
Multiply 2D matrix with vector.
void vect_scale(struct FloatVect3 *vect3, float norm_des)
void float_rmat_comp(struct FloatRMat *m_a2c, struct FloatRMat *m_a2b, struct FloatRMat *m_b2c)
Composition (multiplication) of two rotation matrices.
float float_mat_norm_li(float **a, int m, int n)
void float_rates_integrate_fi(struct FloatRates *r, struct FloatRates *dr, float dt)
in place first order integration of angular rates
static void float_quat_normalize(struct FloatQuat *q)
void float_rmat_of_quat(struct FloatRMat *rm, struct FloatQuat *q)
#define RMAT_ELMT(_rm, _row, _col)
static void float_mat_mul_copy(float **o, float **a, float **b, int m, int n, int l)
o = a * b
void float_quat_of_rmat(struct FloatQuat *q, struct FloatRMat *rm)
Quaternion from rotation matrix.
float float_rmat_reorthogonalize(struct FloatRMat *rm)
void float_quat_integrate(struct FloatQuat *q, struct FloatRates *omega, float dt)
in place quaternion integration with constant rotational velocity
void float_quat_comp_inv_norm_shortest(struct FloatQuat *a2b, struct FloatQuat *a2c, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions with normalization.
void float_rates_of_euler_dot(struct FloatRates *r, struct FloatEulers *e, struct FloatEulers *edot)
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
void float_quat_vmult(struct FloatVect3 *v_out, struct FloatQuat *q, const struct FloatVect3 *v_in)
rotate 3D vector by quaternion.
#define VECT3_SUM_SCALED(_c, _a, _b, _s)
void float_rmat_of_eulers_321(struct FloatRMat *rm, struct FloatEulers *e)
Rotation matrix from 321 Euler angles (float).
static void float_quat_wrap_shortest(struct FloatQuat *q)
void float_quat_of_axis_angle(struct FloatQuat *q, const struct FloatVect3 *uv, float angle)
Quaternion from unit vector and angle.
void float_quat_derivative(struct FloatQuat *qd, struct FloatRates *r, struct FloatQuat *q)
Quaternion derivative from rotational velocity.
void float_eulers_of_quat_zxy(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZXY' This rotation order is useful if you need 90 deg pitch
void vect_bound_in_2d(struct FloatVect3 *vect3, float bound)
void float_quat_of_orientation_vect(struct FloatQuat *q, const struct FloatVect3 *ov)
Quaternion from orientation vector.
void float_rmat_transp_ratemult(struct FloatRates *rb, struct FloatRMat *m_b2a, struct FloatRates *ra)
rotate anglular rates by transposed rotation matrix.
void float_quat_comp_norm_shortest(struct FloatQuat *a2c, struct FloatQuat *a2b, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions with normalization.
void float_rmat_of_axis_angle(struct FloatRMat *rm, struct FloatVect3 *uv, float angle)
initialises a rotation matrix from unit vector axis and angle
void float_rmat_ratemult(struct FloatRates *rb, struct FloatRMat *m_a2b, struct FloatRates *ra)
rotate anglular rates by rotation matrix.
static float float_log_n(float v, float n)
static float float_quat_norm(struct FloatQuat *q)
void float_quat_derivative_lagrange(struct FloatQuat *qd, struct FloatRates *r, struct FloatQuat *q)
Quaternion derivative from rotational velocity.
void float_quat_inv_comp_norm_shortest(struct FloatQuat *b2c, struct FloatQuat *a2b, struct FloatQuat *a2c)
Composition (multiplication) of two quaternions with normalization.
void float_quat_differential(struct FloatQuat *q_out, struct FloatRates *w, float dt)
Delta rotation quaternion with constant angular rates.
void float_eulers_of_quat(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZYX'
static void float_mat_sum_scaled(float **a, float **b, float k, int m, int n)
a += k*b, where k is a scalar value
void float_eulers_of_quat_yxz(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'YXZ' This function calculates from a quaternion the Euler angles with the order YXZ,...
void float_quat_of_eulers_yxz(struct FloatQuat *q, struct FloatEulers *e)
quat from euler rotation 'YXZ' This function calculates a quaternion from Euler angles with the order...
static float renorm_factor(float n)
void float_rmat_inv(struct FloatRMat *m_b2a, struct FloatRMat *m_a2b)
Inverse/transpose of a rotation matrix.
void float_quat_of_eulers(struct FloatQuat *q, struct FloatEulers *e)
quat of euler roation 'ZYX'
void float_quat_comp_inv(struct FloatQuat *a2b, struct FloatQuat *a2c, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions.