四元数(クォータニオン)の計算やらなんやらができます.主に演算子オーバーロードの練習で作りました.温かい目で見てやってください.
Dependencies: Vector3
Dependents: Hybrid_main_FirstEdtion MadgwickFilter MadgwickFilter
Fork of Quaternion by
Diff: Quaternion.hpp
- Revision:
- 1:81bcd478f8d7
- Parent:
- 0:31fe79c6544c
- Child:
- 2:7c23225b23dc
diff -r 31fe79c6544c -r 81bcd478f8d7 Quaternion.hpp --- a/Quaternion.hpp Sat Jan 28 19:53:10 2017 +0000 +++ b/Quaternion.hpp Sat Jan 28 21:13:13 2017 +0000 @@ -1,12 +1,10 @@ #ifndef _QUATERNION_HPP_ #define _QUATERNION_HPP_ -/** - @fn Quaternion.hpp - @author Gaku MATSUMOTO - @bref クォータニオンを使えるクラスです. +/** クォータニオンの足し,引き,掛け算などを簡単にできるようになります. +* @author Gaku MATSUMOTO +* @bref クォータニオンを使えるクラスです. */ - class Quaternion{ public: /** @@ -20,6 +18,10 @@ }; /** @bref 要素を代入しながら,インスタンスを生成します. + @param[in] _w 実部wの初期値 + @param[in] _x 虚部iの初期値 + @param[in] _y 虚部jの初期値 + @param[in] _z 虚部kの初期値 */ Quaternion(double _w, double _x, double _y, double _z){ w = _w; x = _x; y = _y; z = _z; @@ -34,7 +36,8 @@ public: /** - @bref クォータニオンの要素をコピーします. + @bref クォータニオンの要素をコピーします. + @note 通常の数のように代入できます */ Quaternion operator=(Quaternion r){ w = r.w; @@ -45,7 +48,8 @@ }; /** - @bref クォータニオンを足して代入します. + @bref クォータニオンを足して代入します. + @note 通常の数のように代入できます */ Quaternion operator+=(Quaternion r){ w += r.w; @@ -56,7 +60,8 @@ }; /** - @bref クォータニオンを引いて代入します. + @bref クォータニオンを引いて代入します. + @note 通常の数のように代入できます */ Quaternion operator-=(Quaternion r){ w -= r.w; @@ -131,9 +136,8 @@ q3Dot = gz*qg0 + gy*qg1 - gx*qg2;*/ return Q; }; -/** -@bref クォータニオンをスカラー倍します.. -*/ + +/** @bref クォータニオンをスカラー倍します..*/ Quaternion operator*(double s, Quaternion q){ static Quaternion Q; Q.w = q.w * s; @@ -142,6 +146,8 @@ Q.z = q.z * s; return Q; }; + +/** @bref クォータニオンをスカラー倍します..*/ Quaternion operator*(Quaternion q, double s){ static Quaternion Q; Q.w = q.w * s; @@ -151,9 +157,7 @@ return Q; }; -/** - @bref クォータニオンの足し算をします. -*/ +/** @bref クォータニオンの足し算をします.*/ Quaternion operator+(Quaternion l, Quaternion r){ static Quaternion Q; Q.w = l.w + r.w; @@ -163,9 +167,7 @@ return Q; } -/** - @bref クォータニオンの引き算をします. -*/ +/** @bref クォータニオンの引き算をします.*/ Quaternion operator-(Quaternion l, Quaternion r){ static Quaternion Q; Q.w = l.w - r.w;