A quick implementation of Quaternion and Vector classes for use with my MPU9150 library
Dependents: cool_step_new cool_step_1 SML2
Fork of QuaternionMath by
Diff: Vector3.h
- Revision:
- 1:857642c51139
- Parent:
- 0:3cc1a808d8c6
- Child:
- 2:26ba41c58962
--- a/Vector3.h Mon Sep 01 13:48:26 2014 +0000 +++ b/Vector3.h Tue Feb 24 10:05:29 2015 +0000 @@ -1,7 +1,7 @@ #ifndef __AHRSMATHDSP_VECTOR3_ #define __AHRSMATHDSP_VECTOR3_ -#include "arm_math.h" +//#include "arm_math.h" class Vector3 { public: @@ -21,11 +21,11 @@ this->z = z; } - float length_squared(){ + float length_squared() const{ return x*x + y*y + z*z; } - float length(){ + float length() const{ return sqrt(length_squared()); } @@ -36,11 +36,11 @@ z = z/len; } - float dot_product(const Vector3 &v){ + float dot_product(const Vector3 &v) const{ return x*v.x + y*v.y + z*v.z; } - Vector3 cross_product(const Vector3 &v){ + Vector3 cross_product(const Vector3 &v) const{ Vector3 temp(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x); return temp; } @@ -52,11 +52,11 @@ this->z = z; } - bool operator == (const Vector3 &v) { + bool operator == (const Vector3 &v) const { return (x==v.x && y==v.y && z==v.z); } - bool operator != (const Vector3 &v) { + bool operator != (const Vector3 &v) const { return (x!=v.x || y!=v.y || z!=v.z); }