Public 型 | Public メソッド | Static Public メソッド | 変数
クラス テンプレート mist::quaternion< T >

クォータニオン(四元数)を扱うクラス [詳細]

#include <quaternion.h>

Public 型

typedef T value_type
 MISTのコンテナ内に格納するデータ型.mist::array< data > の data と同じ
typedef size_t size_type
 符号なしの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には size_t 型と同じ
typedef ptrdiff_t difference_type
 符号付きの整数を表す型.コンテナ内の要素数や,各要素を指定するときなどに利用し,内部的には ptrdiff_t 型と同じ
typedef float_type< T >::value_type float_type
 長さなどを計算するときに用いる浮動小数点型

Public メソッド

 quaternion ()
 デフォルトコンストラクタ(全要素を0で初期化する)
 quaternion (const value_type &ww, const value_type &xx, const value_type &yy, const value_type &zz)
 ww,xx,yy,zz の値を用いて初期化する
 quaternion (const value_type &ww)
 ww,xx,yy,zz の値を用いて初期化する
template<class TT >
 quaternion (const quaternion< TT > &q)
 他のクォータニオンオブジェクト(データ型が異なる)を用いて初期化する
 quaternion (const quaternion< T > &q)
 他のクォータニオンオブジェクト(データ型が同じ)を用いて初期化する
template<class TT >
 quaternion (value_type ww, const vector3< TT > &v)
 実数成分 ww と虚数成分のベクトル v を用いて初期化する
template<class TT >
 quaternion (const vector3< TT > &axis, value_type theta)
 クォータニオンを用いた任意軸周りの回転
template<class TT >
 quaternion (vector3< TT > dir, vector3< TT > up)
 カメラの視線方向と上向き方向を用いて,カメラの姿勢を表すクォータニオンを計算する
template<class TT >
const quaternionoperator= (const quaternion< TT > &q)
 他のクォータニオンオブジェクトを代入する
const quaternionoperator= (const quaternion< T > &q)
 他のクォータニオンオブジェクトを代入する
quaternion operator- () const
 符号反転したクォータニオンを返す
template<class TT >
const quaternionoperator+= (const quaternion< TT > &q)
 クォータニオンの足し算
template<class TT >
const quaternionoperator+= (const TT &a)
 クォータニオンへの実数成分の足し算
template<class TT >
const quaternionoperator-= (const quaternion< TT > &q)
 クォータニオンの引き算
template<class TT >
const quaternionoperator-= (const TT &a)
 クォータニオンへの実数成分の引き算
template<class TT >
const quaternionoperator*= (const quaternion< TT > &q)
 クォータニオンの掛け算
template<class TT >
const quaternionoperator*= (const TT &a)
 クォータニオンへの実数成分の掛け算
template<class TT >
const quaternionoperator/= (const quaternion< TT > &q)
 クォータニオンの割り算
template<class TT >
const quaternionoperator/= (const TT &a)
 クォータニオンを実数成分で割る
bool operator== (const quaternion &q) const
 2つのクォータニオンが同一かどうかを判定する
bool operator!= (const quaternion &q) const
 2つのクォータニオンが等しくないどうかを判定する
bool operator< (const quaternion &q) const
 2つのベクトルの < を判定する
bool operator<= (const quaternion &q) const
 2つのベクトルの <= を判定する
bool operator> (const quaternion &q) const
 2つのベクトルの > を判定する
bool operator>= (const quaternion &q) const
 2つのベクトルの >= を判定する
const quaternion conjugate () const
 共役クォータニオン
const quaternion inv () const
 逆クォータニオン
const quaternion unit () const
 単位クォータニオン
template<class TT >
value_type inner (const quaternion< TT > &q) const
 クォータニオンの内積
float_type length () const
 クォータニオンのノルム
template<class TT >
const vector3< TT > rotate (const vector3< TT > &v) const
 クォータニオンを用いたベクトルの回転

Static Public メソッド

template<class TT >
static quaternion rotate (vector3< TT > v1, vector3< TT > v2)
 ベクトル1からベクトル2への回転を表すクォータニオンを作成する
template<class TT >
static quaternion rotate (vector3< TT > v1, vector3< TT > v2, const vector3< TT > &axis)
 指定した回転軸を用いてベクトル1からベクトル2への回転を表すクォータニオンを作成する

変数

value_type w
 実数成分
value_type x
 虚数成分1
value_type y
 虚数成分2
value_type z
 虚数成分3

説明

template<class T>
class mist::quaternion< T >

クォータニオン(四元数)を扱うクラス

引数
T… 内部で用いるデータ型

コンストラクタとデストラクタ

template<class T>
template<class TT >
mist::quaternion< T >::quaternion ( const vector3< TT > &  axis,
value_type  theta 
)
inline

クォータニオンを用いた任意軸周りの回転

注意
右手系の場合は右ねじ回転,左手系の場合は左ねじ回転となるので注意!!
回転角度の単位は度を用いる(ラジアンではないので注意!!)
引数
[in]axis… 回転軸
[in]theta… 回転角度

参照先 mist::vector3< T >::x, mist::vector3< T >::y, と mist::vector3< T >::z.

template<class T>
template<class TT >
mist::quaternion< T >::quaternion ( vector3< TT >  dir,
vector3< TT >  up 
)
inline

カメラの視線方向と上向き方向を用いて,カメラの姿勢を表すクォータニオンを計算する

引数
[in]dir… 回転前のベクトル
[in]up… 回転後のベクトル

参照先 mist::quaternion< T >::rotate(), と mist::vector3< T >::unit().

関数

template<class T>
const quaternion mist::quaternion< T >::conjugate ( ) const
inline

共役クォータニオン

\[ \overline{ \mbox{\boldmath p} } = \left( p_w \;,\; -p_x \;,\; -p_y \;,\; -p_z \right)^T \]

template<class T>
template<class TT >
value_type mist::quaternion< T >::inner ( const quaternion< TT > &  q) const
inline

クォータニオンの内積

引数
[in]q… 右辺値

\[ p_w \times q_w + p_x \times q_x + p_y \times q_y + p_z \times q_z \]

参照先 mist::quaternion< T >::w, mist::quaternion< T >::x, mist::quaternion< T >::y, と mist::quaternion< T >::z.

参照元 mist::interpolate().

template<class T>
const quaternion mist::quaternion< T >::inv ( ) const
inline

逆クォータニオン

\[ \mbox{\boldmath p}^{-1} = \frac{ \overline{ \mbox{\boldmath p} } }{ \left\| \mbox{\boldmath p} \right\|^2 } \]

参照元 mist::quaternion< T >::operator/=().

template<class T>
float_type mist::quaternion< T >::length ( ) const
inline

クォータニオンのノルム

\[ \left\| \mbox{\boldmath p} \right\| = \sqrt{ p_w^2 + p_x^2 + p_y^2 + p_z^2 } \]

template<class T>
bool mist::quaternion< T >::operator!= ( const quaternion< T > &  q) const
inline

2つのクォータニオンが等しくないどうかを判定する

\[ \mbox{\boldmath p} \neq \mbox{\boldmath q} \rightarrow \overline{ p_w = q_w \; \wedge \; p_x = q_x \; \wedge \; p_y = q_y \; \wedge \; p_z = q_z } \]

引数
[in]q… 右辺値
戻り値
true… どれか1つでも等しくない場合
false… 全ての要素が等しい場合
template<class T>
template<class TT >
const quaternion& mist::quaternion< T >::operator*= ( const quaternion< TT > &  q)
inline

クォータニオンの掛け算

\[ \mbox{\boldmath p} \times \mbox{\boldmath q} = \left( p_w \times q_w - p_x \times q_x - p_y \times q_y - p_z \times q_z \;,\; p_w \times q_x + p_x \times q_w + p_y \times q_z - p_z \times q_y \;,\; p_w \times q_y + p_y \times q_w + p_z \times q_x - p_x \times q_z \;,\; p_w \times q_z + p_z \times q_w + p_x \times q_y - p_y \times q_x \right)^T \]

引数
[in]q… 右辺値
戻り値
掛け算結果

参照先 mist::quaternion< T >::w, mist::quaternion< T >::x, mist::quaternion< T >::y, と mist::quaternion< T >::z.

template<class T>
template<class TT >
const quaternion& mist::quaternion< T >::operator*= ( const TT &  a)
inline

クォータニオンへの実数成分の掛け算

\[ \mbox{\boldmath p} \times a = \left( p_w \times a \;,\; p_x \times a \;,\; p_y \times a \;,\; p_z \times a \right)^T \]

引数
[in]a… 実数成分
戻り値
掛け算結果
template<class T>
template<class TT >
const quaternion& mist::quaternion< T >::operator+= ( const quaternion< TT > &  q)
inline

クォータニオンの足し算

\[ \mbox{\boldmath p} + \mbox{\boldmath q} = \left( p_w + q_w \;,\; p_x + q_x \;,\; p_y + q_y \;,\; p_z + q_z \right)^T \]

引数
[in]q… 右辺値
戻り値
足し算結果

参照先 mist::quaternion< T >::w, mist::quaternion< T >::x, mist::quaternion< T >::y, と mist::quaternion< T >::z.

template<class T>
template<class TT >
const quaternion& mist::quaternion< T >::operator+= ( const TT &  a)
inline

クォータニオンへの実数成分の足し算

\[ \mbox{\boldmath p} + a = \left( p_w + a \;,\; p_x \;,\; p_y \;,\; p_z \right)^T \]

引数
[in]a… 実数成分
戻り値
足し算結果
template<class T>
template<class TT >
const quaternion& mist::quaternion< T >::operator-= ( const quaternion< TT > &  q)
inline

クォータニオンの引き算

\[ \mbox{\boldmath p} - \mbox{\boldmath q} = \left( p_w - q_w \;,\; p_x - q_x \;,\; p_y - q_y \;,\; p_z - q_z \right)^T \]

引数
[in]q… 右辺値
戻り値
引き算結果

参照先 mist::quaternion< T >::w, mist::quaternion< T >::x, mist::quaternion< T >::y, と mist::quaternion< T >::z.

template<class T>
template<class TT >
const quaternion& mist::quaternion< T >::operator-= ( const TT &  a)
inline

クォータニオンへの実数成分の引き算

\[ \mbox{\boldmath p} - a = \left( p_w - a \;,\; p_x \;,\; p_y \;,\; p_z \right)^T \]

引数
[in]a… 実数成分
戻り値
引き算結果
template<class T>
template<class TT >
const quaternion& mist::quaternion< T >::operator/= ( const quaternion< TT > &  q)
inline

クォータニオンの割り算

\[ \frac{ \mbox{\boldmath p} }{ \mbox{\boldmath q} } = \mbox{\boldmath p} \times \mbox{\boldmath q}^{-1} \]

引数
[in]q… 右辺値
戻り値
掛け算結果

参照先 mist::quaternion< T >::inv().

template<class T>
template<class TT >
const quaternion& mist::quaternion< T >::operator/= ( const TT &  a)
inline

クォータニオンを実数成分で割る

\[ \mbox{\boldmath p} \div a = \left( p_w \div a \;,\; p_x \div a \;,\; p_y \div a \;,\; p_z \div a \right)^T \]

引数
[in]a… 実数成分
戻り値
掛け算結果
template<class T>
bool mist::quaternion< T >::operator< ( const quaternion< T > &  q) const
inline

2つのベクトルの < を判定する

\[ \mbox{\boldmath p} < \mbox{\boldmath q} \rightarrow \overline{ p_w \ge q_w \; \wedge \; p_x \ge q_x \; \wedge \; p_y \ge q_y \; \wedge \; p_z \ge q_z } \]

引数
[in]q… 右辺値
戻り値
true… p < q の場合
false… p >= q の場合

参照先 mist::quaternion< T >::w, mist::quaternion< T >::x, mist::quaternion< T >::y, と mist::quaternion< T >::z.

template<class T>
bool mist::quaternion< T >::operator<= ( const quaternion< T > &  q) const
inline

2つのベクトルの <= を判定する

\[ \mbox{\boldmath p} \le \mbox{\boldmath q} \rightarrow p_w \le q_w \; \wedge \; p_x \le q_x \; \wedge \; p_y \le q_y \; \wedge \; p_z \le q_z \]

引数
[in]q… 右辺値
戻り値
true… p <= q の場合
false… p > q の場合
template<class T>
bool mist::quaternion< T >::operator== ( const quaternion< T > &  q) const
inline

2つのクォータニオンが同一かどうかを判定する

\[ \mbox{\boldmath p} == \mbox{\boldmath q} \rightarrow p_w == q_w \; \wedge \; p_x == q_x \; \wedge \; p_y == q_y \; \wedge \; p_z == q_z \]

引数
[in]q… 右辺値
戻り値
true… 全ての要素が等しい場合
false… どれか1つでも等しくない場合

参照先 mist::quaternion< T >::w, mist::quaternion< T >::x, mist::quaternion< T >::y, と mist::quaternion< T >::z.

template<class T>
bool mist::quaternion< T >::operator> ( const quaternion< T > &  q) const
inline

2つのベクトルの > を判定する

\[ \mbox{\boldmath p} > \mbox{\boldmath q} \rightarrow \overline{ p_w \le q_w \; \wedge \; p_x \le q_x \; \wedge \; p_y \le q_y \; \wedge \; p_z \le q_z } \]

引数
[in]q… 右辺値
戻り値
true… p > q の場合
false… p <= q の場合
template<class T>
bool mist::quaternion< T >::operator>= ( const quaternion< T > &  q) const
inline

2つのベクトルの >= を判定する

\[ \mbox{\boldmath p} \ge \mbox{\boldmath q} \rightarrow p_w \ge q_w \; \wedge \; p_x \ge q_x \; \wedge \; p_y \ge q_y \; \wedge \; p_z \ge q_z \]

引数
[in]q… 右辺値
戻り値
true… p >= q の場合
false… p < q の場合
template<class T>
template<class TT >
const vector3< TT > mist::quaternion< T >::rotate ( const vector3< TT > &  v) const
inline

クォータニオンを用いたベクトルの回転

引数
[in]v… 回転されるベクトル
戻り値
回転後のベクトル

参照先 mist::quaternion< T >::x, mist::vector3< T >::x, mist::quaternion< T >::y, mist::vector3< T >::y, mist::quaternion< T >::z, と mist::vector3< T >::z.

参照元 mist::quaternion< T >::quaternion().

template<class T>
template<class TT >
static quaternion mist::quaternion< T >::rotate ( vector3< TT >  v1,
vector3< TT >  v2 
)
inlinestatic

ベクトル1からベクトル2への回転を表すクォータニオンを作成する

引数
[in]v1… 回転前のベクトル
[in]v2… 回転後のベクトル
戻り値
回転を表すクォータニオン

参照先 mist::vector3< T >::inner(), mist::vector3< T >::outer(), と mist::vector3< T >::unit().

template<class T>
template<class TT >
static quaternion mist::quaternion< T >::rotate ( vector3< TT >  v1,
vector3< TT >  v2,
const vector3< TT > &  axis 
)
inlinestatic

指定した回転軸を用いてベクトル1からベクトル2への回転を表すクォータニオンを作成する

引数
[in]v1… 回転前のベクトル
[in]v2… 回転後のベクトル
[in]axis… 回転軸ベクトル
戻り値
回転を表すクォータニオン

参照先 mist::vector3< T >::inner(), mist::vector3< T >::outer(), と mist::vector3< T >::unit().

template<class T>
const quaternion mist::quaternion< T >::unit ( ) const
inline

単位クォータニオン

\[ \frac{ \mbox{\boldmath p} }{ \left\| \mbox{\boldmath p} \right\|^2 } \]

参照元 mist::interpolate().


このクラスの説明は次のファイルから生成されました:

Generated on Wed Nov 12 2014 19:44:29 for MIST by doxygen 1.8.1.2