Lines Matching refs:kasa
1 #include "common/math/kasa.h"
8 void kasaReset(struct KasaFit *kasa) {
9 kasa->acc_x = kasa->acc_y = kasa->acc_z = kasa->acc_w = 0.0f;
10 kasa->acc_xx = kasa->acc_xy = kasa->acc_xz = kasa->acc_xw = 0.0f;
11 kasa->acc_yy = kasa->acc_yz = kasa->acc_yw = 0.0f;
12 kasa->acc_zz = kasa->acc_zw = 0.0f;
13 kasa->nsamples = 0;
16 void kasaInit(struct KasaFit *kasa) { kasaReset(kasa); }
18 void kasaAccumulate(struct KasaFit *kasa, float x, float y, float z) {
21 kasa->acc_x += x;
22 kasa->acc_y += y;
23 kasa->acc_z += z;
24 kasa->acc_w += w;
26 kasa->acc_xx += x * x;
27 kasa->acc_xy += x * y;
28 kasa->acc_xz += x * z;
29 kasa->acc_xw += x * w;
31 kasa->acc_yy += y * y;
32 kasa->acc_yz += y * z;
33 kasa->acc_yw += y * w;
35 kasa->acc_zz += z * z;
36 kasa->acc_zw += z * w;
38 kasa->nsamples += 1;
41 bool kasaNormalize(struct KasaFit *kasa) {
42 if (kasa->nsamples == 0) {
46 float inv = 1.0f / kasa->nsamples;
48 kasa->acc_x *= inv;
49 kasa->acc_y *= inv;
50 kasa->acc_z *= inv;
51 kasa->acc_w *= inv;
53 kasa->acc_xx *= inv;
54 kasa->acc_xy *= inv;
55 kasa->acc_xz *= inv;
56 kasa->acc_xw *= inv;
58 kasa->acc_yy *= inv;
59 kasa->acc_yz *= inv;
60 kasa->acc_yw *= inv;
62 kasa->acc_zz *= inv;
63 kasa->acc_zw *= inv;
68 int kasaFit(struct KasaFit *kasa, struct Vec3 *bias, float *radius,
73 A.elem[0][0] = kasa->acc_xx;
74 A.elem[0][1] = kasa->acc_xy;
75 A.elem[0][2] = kasa->acc_xz;
76 A.elem[0][3] = kasa->acc_x;
77 A.elem[1][0] = kasa->acc_xy;
78 A.elem[1][1] = kasa->acc_yy;
79 A.elem[1][2] = kasa->acc_yz;
80 A.elem[1][3] = kasa->acc_y;
81 A.elem[2][0] = kasa->acc_xz;
82 A.elem[2][1] = kasa->acc_yz;
83 A.elem[2][2] = kasa->acc_zz;
84 A.elem[2][3] = kasa->acc_z;
85 A.elem[3][0] = kasa->acc_x;
86 A.elem[3][1] = kasa->acc_y;
87 A.elem[3][2] = kasa->acc_z;
91 initVec4(&b, -kasa->acc_xw, -kasa->acc_yw, -kasa->acc_zw, -kasa->acc_w);