3次元ベクトルクラスVector3ライブラリです。

Dependents:   Quaternion HAPS_GPS_Test_0002 GYSFDMAXB HAPS_EKF ... more

Revision:
2:33c104711999
Parent:
1:8e112552bdfc
--- a/Vector3.hpp	Fri Jun 09 19:54:15 2017 +0000
+++ b/Vector3.hpp	Wed Oct 25 08:08:00 2017 +0000
@@ -33,7 +33,7 @@
 		return *this;
 	};
 
-	/**3次元ベクトルを足して代入する
+	/**3次元ベクトルを足して代入する*/
 	Vector3 operator+=(Vector3 vec){
 		x += vec.x;
 		y += vec.y;
@@ -41,7 +41,7 @@
 		return *this;
 	};
 
-	/**3次元ベクトルを引いて代入する*/
+	/** 3次元ベクトルを引いて代入する */
 	Vector3 operator-=(Vector3 vec){
 		x -= vec.x;
 		y -= vec.y;
@@ -89,6 +89,13 @@
 	*  @param 自分とのなす角度を計算するVector3クラスのインスタンス
 	*/
 	double Angle(Vector3 v);
+	
+	/**
+	*  @bref 2つのVector3クラスのなす角を計算します.
+	*  @param 自分とのなす角度を計算するVector3クラスのインスタンス
+	*  @return 自分 * 相手となるベクトルを回転軸として符号付きのなす角度です
+	*/
+	double sgnAngle(Vector3 vec);
 
 	/**
 	*  @bref ゼロベクトルかどうか判定します.
@@ -210,6 +217,14 @@
 	return acos(r);
 }
 
+inline double Vector3::sgnAngle(Vector3 vec){
+	double 	theta = this->Angle(vec);
+	vec = *this * vec;
+	if(vec.z < 0) theta *= -1.0;
+	
+	return theta;
+}
+
 inline double Vector3::Norm(){
 	return sqrt(x*x + y*y + z*z);
 }