Mike Panetta
/
FirstTest
Second revision of test code for Polyathalon sensor board.
Diff: Quaternion/Quaternion.h
- Revision:
- 0:13a7de7ce046
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Quaternion/Quaternion.h Sat Nov 05 18:29:39 2011 +0000 @@ -0,0 +1,45 @@ +/** + * @file Quaternion.h + * @author Mike Panetta + * + * Created Oct 29th 2011 + * + * Based on tutorial here: http://www.cprogramming.com/tutorial/3d/quaternions.html + * + */ + +#ifndef _QUATERNION_H_ +#define _QUATERNION_H_ + +#include <math.h> + +class Quaternion +{ + public: + Quaternion(float const & a, + float const & b, + float const & c, + float const & d) : w(a), x(b), y(c), z(d) {} + + float norm(void) + { + return sqrtf(w*w+x*x+y*y+z*z); + } + + float real(void) + { + return w; + } + + Quaternion unreal(void) + { + return Quaternion(0, x, y, z); + } + + private: + + float w, x, y, z; +}; + + +#endif //_QUATERNION_H)_ \ No newline at end of file