summaryrefslogtreecommitdiff
path: root/include/mat33.h
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2015-09-11 12:02:26 -0700
committerchrome-bot <chrome-bot@chromium.org>2015-10-13 05:28:54 -0700
commit828b55a7358ad5ec8bc27552bfb280eb173dd453 (patch)
treeb9430d2bf624ee2b6976eed211696b50ae56decb /include/mat33.h
parent0647f66f81de880af603a7fb70f57159519782ac (diff)
downloadchrome-ec-828b55a7358ad5ec8bc27552bfb280eb173dd453.tar.gz
common: Add magnetometer online calibration.
Code for hard iron calibration: Every seconds (or faster if enough samples), find a sphere that fit the compass data. Based on Android code. BRANCH=smaug BUG=chrome-os-partner:39900 TEST=Check hard-iron bias is removed. Works better outside. Change-Id: Iab479d5113b6560b4f01b0fd87373d2eecdb9b54 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/299583 Reviewed-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'include/mat33.h')
-rw-r--r--include/mat33.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/mat33.h b/include/mat33.h
new file mode 100644
index 0000000000..de7debbbc1
--- /dev/null
+++ b/include/mat33.h
@@ -0,0 +1,30 @@
+/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_MAT_33_H
+
+#define __CROS_EC_MAT_33_H
+
+#include "vec3.h"
+#include "util.h"
+
+typedef float mat33_t[3][3];
+typedef size_t size3_t[3];
+
+void init_zero_matrix(mat33_t A);
+void init_diagonal_matrix(mat33_t A, float x);
+
+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);
+
+size_t mat33_maxind(mat33_t A, size_t k);
+
+void mat33_rotate(mat33_t A, float c, float s,
+ size_t k, size_t l, size_t i, size_t j);
+
+#endif /* __CROS_EC_MAT_33_H */