read acceleration and angler ratio from mpu6050 and estimate pitch and roll angle
Dependencies: mbed
Diff: Vector.h
- Revision:
- 2:4a6b46653abf
- Child:
- 3:40559ebef0f1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Vector.h Mon Apr 20 14:54:55 2015 +0000 @@ -0,0 +1,52 @@ +#pragma once +#include "Matrix.h" +#include "ErrorLogger.h" + +class Vector { +public: + Vector(int dim); + ~Vector(); + Vector(const Vector& v); + + Vector& operator=(const Vector& v); + Vector& operator*=(float c); + Vector& operator/=(float c); + Vector& operator+=(const Vector& v); + Vector& operator-=(const Vector& v); + + void SetComp(int dimNo, float val); + float GetNorm() const; + Vector GetUnit() const; + + inline int GetDim() const { + return dim; + } + + inline const float* GetpComponents() const { + return (const float*)components; + } + + inline float GetComp(int dimNo) const { + if (dimNo > dim) AbortWithMsg("Index Out of Bounds Error !!"); + return components[dimNo-1]; + } + + void CleanUp(); + +private: + int dim; + float* components; + + Vector& operator*=(const Matrix& m); + Vector& operator*=(const Vector& m); +}; + +Vector operator+(const Vector& lhv, const Vector& rhv); +Vector operator-(const Vector& lhv, const Vector& rhv); +Vector Cross(const Vector& lhv, const Vector& rhv); +Vector operator*(const float c, const Vector& rhv); +Vector operator*(const Vector& lhv, const float c); +Vector operator*(const Matrix& lhm, const Vector& rhv); +Vector operator*(const Vector& lhv, const Matrix& rhm); +float operator*(const Vector& lhv, const Vector& rhv); +