Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed_accelerometer
Fork of LSM303DLHC by
Revision 5:762e7cfed86f, committed 2014-09-29
- Comitter:
- jn80842
- Date:
- Mon Sep 29 08:51:35 2014 +0000
- Parent:
- 4:612f7d5a822d
- Commit message:
- tweak to work with frdm-kl25z
Changed in this revision
| vector.cpp | Show annotated file Show diff for this revision Revisions of this file |
| vector.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vector.cpp Mon Sep 29 08:51:35 2014 +0000
@@ -0,0 +1,22 @@
+#include <vector.h>
+#include <math.h>
+
+void vector_cross(const vector *a,const vector *b, vector *out)
+{
+ out->x = a->y*b->z - a->z*b->y;
+ out->y = a->z*b->x - a->x*b->z;
+ out->z = a->x*b->y - a->y*b->x;
+}
+
+float vector_dot(const vector *a,const vector *b)
+{
+ return a->x*b->x+a->y*b->y+a->z*b->z;
+}
+
+void vector_normalize(vector *a)
+{
+ float mag = sqrt(vector_dot(a,a));
+ a->x /= mag;
+ a->y /= mag;
+ a->z /= mag;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vector.h Mon Sep 29 08:51:35 2014 +0000
@@ -0,0 +1,11 @@
+#ifndef vector_h
+#define vector_h
+typedef struct vector
+{
+ float x, y, z;
+} vector;
+
+extern void vector_cross(const vector *a, const vector *b, vector *out);
+extern float vector_dot(const vector *a,const vector *b);
+extern void vector_normalize(vector *a);
+#endif
\ No newline at end of file
