diff options
author | Yilun Lin <yllin@google.com> | 2018-09-08 00:08:36 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-09-18 15:38:11 +0000 |
commit | 467de25f544ce3318aa890b96a7c881cef843404 (patch) | |
tree | 90100249fe312edc1c3d2951179c5431c602d00a | |
parent | 3e778f707a0a4d252a64dd6db3f4c142d482dbbc (diff) | |
download | chrome-ec-467de25f544ce3318aa890b96a7c881cef843404.tar.gz |
type: Rename vec3_t to floatv3_t.
Naming of many vector types and matrix types are not clear enough.
For example, we have:
vector_3_t, which is a vector of three int.
vec3_t, which is a vector of three float.
size4_t, which is a vector of four size_t.
mat33_t, which is a 3x3 matrix of float.
matrix_3x3_t, which is a 3x3 matrix of fixed point.
Besides, we have types like int8_t, uint16_t types.
To clearly distinguished types, the CL propose to,
For vector types, naming should be `$type + 'v' + $num + '_t'`:
vector_3_t becomes intv3_t
vec3_t becomes floatv3_t
vector 4 of uint16_t becomes uint16v4_t (which doesn't exist yet)
For matrix types, naming should be `mat$N$N_` + $type + '_t', where $N is the
matrix size:
matrix_3x3_t becomes mat33_fp_t # fp: fixed point
mat33_t becomes mat33_float_t
TEST=make buildall -j
BUG=b:114662791
Change-Id: I8cac6a7c0abe3d462326291b76b1ed44ce6c9a9c
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1215443
Commit-Ready: Yilun Lin <yllin@chromium.org>
Tested-by: Yilun Lin <yllin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1230985
Reviewed-by: Martin Roth <martinroth@chromium.org>
Commit-Queue: Martin Roth <martinroth@chromium.org>
Tested-by: Martin Roth <martinroth@chromium.org>
-rw-r--r-- | common/mag_cal.c | 12 | ||||
-rw-r--r-- | common/mat33.c | 2 | ||||
-rw-r--r-- | common/vec3.c | 12 | ||||
-rw-r--r-- | include/mat33.h | 2 | ||||
-rw-r--r-- | include/vec3.h | 10 |
5 files changed, 19 insertions, 19 deletions
diff --git a/common/mag_cal.c b/common/mag_cal.c index dab2b64d96..f9a0710650 100644 --- a/common/mag_cal.c +++ b/common/mag_cal.c @@ -35,7 +35,7 @@ static int moc_eigen_test(struct mag_cal_t *moc) { mat33_t S; - vec3_t eigenvals; + floatv3_t eigenvals; mat33_t eigenvecs; float evmax, evmin, evmag; int eigen_pass; @@ -80,7 +80,7 @@ static int moc_eigen_test(struct mag_cal_t *moc) /* * Kasa sphere fitting with normal equation */ -static int moc_fit(struct mag_cal_t *moc, vec3_t bias, float *radius) +static int moc_fit(struct mag_cal_t *moc, floatv3_t bias, float *radius) { size4_t pivot; vec4_t out; @@ -120,10 +120,10 @@ static int moc_fit(struct mag_cal_t *moc, vec3_t bias, float *radius) * r = sqrt(xc^2 + yc^2 + zc^2 - out[W]) */ - memcpy(bias, out, sizeof(vec3_t)); - vec3_scalar_mul(bias, -0.5f); + memcpy(bias, out, sizeof(floatv3_t)); + floatv3_scalar_mul(bias, -0.5f); - *radius = sqrtf(vec3_dot(bias, bias) - out[W]); + *radius = sqrtf(floatv3_dot(bias, bias) - out[W]); #if 0 CPRINTF("mag cal: bias (%d, %d, %d), R %d uT\n", @@ -197,7 +197,7 @@ int mag_cal_update(struct mag_cal_t *moc, const intv3_t v) /* 3. eigen test */ if (moc_eigen_test(moc)) { - vec3_t bias; + floatv3_t bias; float radius; /* 4. Kasa sphere fitting */ diff --git a/common/mat33.c b/common/mat33.c index 8317ee8a97..17938c0c4f 100644 --- a/common/mat33.c +++ b/common/mat33.c @@ -55,7 +55,7 @@ void mat33_swap_rows(mat33_t A, const size_t i, const size_t j) * The i-th eigenvalue corresponds to the eigenvector in the i-th _row_ of * "eigenvecs". */ -void mat33_get_eigenbasis(mat33_t S, vec3_t e_vals, mat33_t e_vecs) +void mat33_get_eigenbasis(mat33_t S, floatv3_t e_vals, mat33_t e_vecs) { const size_t N = 3; size3_t ind; diff --git a/common/vec3.c b/common/vec3.c index 12c33179c2..4c157467c1 100644 --- a/common/vec3.c +++ b/common/vec3.c @@ -9,25 +9,25 @@ #include "vec3.h" #include "util.h" -void vec3_scalar_mul(vec3_t v, float c) +void floatv3_scalar_mul(floatv3_t v, float c) { v[X] *= c; v[Y] *= c; v[Z] *= c; } -float vec3_dot(const vec3_t v, const vec3_t w) +float floatv3_dot(const floatv3_t v, const floatv3_t w) { return v[X] * w[X] + v[Y] * w[Y] + v[Z] * w[Z]; } -float vec3_norm_squared(const vec3_t v) +float floatv3_norm_squared(const floatv3_t v) { - return vec3_dot(v, v); + return floatv3_dot(v, v); } -float vec3_norm(const vec3_t v) +float floatv3_norm(const floatv3_t v) { - return sqrtf(vec3_norm_squared(v)); + return sqrtf(floatv3_norm_squared(v)); } diff --git a/include/mat33.h b/include/mat33.h index de7debbbc1..75c0d79366 100644 --- a/include/mat33.h +++ b/include/mat33.h @@ -20,7 +20,7 @@ void mat33_scalar_mul(mat33_t A, float c); void mat33_swap_rows(mat33_t A, const size_t i, const size_t j); -void mat33_get_eigenbasis(mat33_t S, vec3_t eigenvals, mat33_t eigenvecs); +void mat33_get_eigenbasis(mat33_t S, floatv3_t eigenvals, mat33_t eigenvecs); size_t mat33_maxind(mat33_t A, size_t k); diff --git a/include/vec3.h b/include/vec3.h index 68ec1a5c72..367956b2a1 100644 --- a/include/vec3.h +++ b/include/vec3.h @@ -7,11 +7,11 @@ #ifndef __CROS_EC_VEC_3_H #define __CROS_EC_VEC_3_H -typedef float vec3_t[3]; +typedef float floatv3_t[3]; -void vec3_scalar_mul(vec3_t v, float c); -float vec3_dot(const vec3_t v, const vec3_t w); -float vec3_norm_squared(const vec3_t v); -float vec3_norm(const vec3_t v); +void floatv3_scalar_mul(floatv3_t v, float c); +float floatv3_dot(const floatv3_t v, const floatv3_t w); +float floatv3_norm_squared(const floatv3_t v); +float floatv3_norm(const floatv3_t v); #endif /* __CROS_EC_VEC_3_H */ |