四元数(クォータニオン)の計算やらなんやらができます.主に演算子オーバーロードの練習で作りました.温かい目で見てやってください.

Dependencies:   Vector3

Dependents:   Hybrid_main_FirstEdtion MadgwickFilter MadgwickFilter

Fork of Quaternion by Gaku Matsumoto

Files at this revision

API Documentation at this revision

Comitter:
Gaku0606
Date:
Wed Oct 25 08:08:06 2017 +0000
Parent:
5:3c531c1f56cc
Commit message:
aaa

Changed in this revision

Quaternion.hpp Show annotated file Show diff for this revision Revisions of this file
Vector3.lib Show annotated file Show diff for this revision Revisions of this file
--- a/Quaternion.hpp	Wed Jun 07 00:57:58 2017 +0000
+++ b/Quaternion.hpp	Wed Oct 25 08:08:06 2017 +0000
@@ -23,16 +23,13 @@
 	*  @bref Vector3クラスからクォータニオンを作ります
 	*/
 	Quaternion(Vector3 vector){
-		w = 0.0;
-		x = vector.x;
-		y = vector.y;
-		z = vector.z;
+		set(vector);
 	}
 
 	/**
 	*  @bref   クォータニオンを回転軸と回転角度によって初期化します。
-	*  param   vec 回転軸となる3次元ベクトル
-	*  param   angle 回転角 [rad]
+	*  @param   vec 回転軸となる3次元ベクトル
+	*  @param   angle 回転角 [rad]
 	*/
 	Quaternion(Vector3 vec, double angle){
 		set(vec, angle);
@@ -230,6 +227,14 @@
 		val[2] = (atan2(2.0f * (x * y + w * z), q0q0 + q1q1q2q2 - q3q3));
 	}
 
+	/**
+	*  @bref  クォータニオンをVector3クラスに変換します
+	*  @note  クォータニオンのx,y,z成分を持ったベクトルを作ります
+	*/
+	Vector3 makeVector3(){
+		Vector3 vec3(x, y, z);
+		return vec3;	
+	}
 
 };
 
--- a/Vector3.lib	Wed Jun 07 00:57:58 2017 +0000
+++ b/Vector3.lib	Wed Oct 25 08:08:06 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/Gaku0606/code/Vector3/#deef87aa67a3
+https://developer.mbed.org/users/Gaku0606/code/Vector3/#33c104711999