diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2018-12-19 09:08:12 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-02-28 11:01:47 -0800 |
commit | 068c46513aac5ecfb06489191fad9fd60e5d750c (patch) | |
tree | 3241f63ceb44735e9482495b935f648c191562cf /include/math_util.h | |
parent | 265eceed674b7208fa303d0cfd5345b9113342da (diff) | |
download | chrome-ec-068c46513aac5ecfb06489191fad9fd60e5d750c.tar.gz |
math: Add/expose some vector operation
Expose dot procdut and cros product for vector operations.
BUG=b:120346412
BRANCH=none
TEST=compile, check unit tests.
Change-Id: Ief50f31aa6105dc2f0d92caf8b7473a7e141eb45
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1387923
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Diffstat (limited to 'include/math_util.h')
-rw-r--r-- | include/math_util.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/math_util.h b/include/math_util.h index 942aaf8908..8d779846b3 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -151,6 +151,24 @@ enum { fp_t arc_cos(fp_t x); /** + * Calculate the dot product of 2 vectors. + */ +fp_inter_t dot_product(const intv3_t v1, const intv3_t v2); + +/* + * Calculate the dot product of 2 vectors, + * + * Assume the result vector components fits in 32bit. + */ +void cross_product(const intv3_t v1, const intv3_t v2, intv3_t v); + +/** + * Scale a vector by fixed point constant. + */ +void vector_scale(intv3_t v, fp_t s); + + +/** * Find the cosine of the angle between two vectors. * * The implementation assumes no vector component is greater than |