FineKernelToolKit  2.8.10
FK/Quaternion.h
説明を見る。
00001 /****************************************************************************
00002  *
00003  *  Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved.
00004  *
00005  *  Redistribution and use in source and binary forms,
00006  *  with or without modification, are permitted provided that the
00007  *  following conditions are met:
00008  *
00009  *      - Redistributions of source code must retain the above
00010  *          copyright notice, this list of conditions and the
00011  *          following disclaimer.
00012  *
00013  *      - Redistributions in binary form must reproduce the above
00014  *          copyright notice, this list of conditions and the
00015  *          following disclaimer in the documentation and/or
00016  *          other materials provided with the distribution.
00017  *
00018  *      - Neither the name of the copyright holders nor the names
00019  *          of its contributors may be used to endorse or promote
00020  *          products derived from this software without specific
00021  *          prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00030  *  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00031  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00032  *  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00033  *  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE. 
00035  *
00036  ****************************************************************************/
00037 /****************************************************************************
00038  *
00039  *  Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved.
00040  *
00041  *  本ソフトウェアおよびソースコードのライセンスは、基本的に
00042  *  「修正 BSD ライセンス」に従います。以下にその詳細を記します。
00043  *
00044  *  ソースコード形式かバイナリ形式か、変更するかしないかを問わず、
00045  *  以下の条件を満たす場合に限り、再頒布および使用が許可されます。
00046  *
00047  *  - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、
00048  *      および下記免責条項を含めること。
00049  *
00050  *  - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の
00051  *      資料に、上記の著作権表示、本条件一覧、および下記免責条項を
00052  *      含めること。
00053  *
00054  *  - 書面による特別の許可なしに、本ソフトウェアから派生した製品の
00055  *      宣伝または販売促進に、本ソフトウェアの著作権者の名前または
00056  *      コントリビューターの名前を使用してはならない。
00057  *
00058  *  本ソフトウェアは、著作権者およびコントリビューターによって「現
00059  *  状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、
00060  *  および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ
00061  *  に限定されない、いかなる保証もないものとします。著作権者もコン
00062  *  トリビューターも、事由のいかんを問わず、損害発生の原因いかんを
00063  *  問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その
00064  *  他の)不法行為であるかを問わず、仮にそのような損害が発生する可
00065  *  能性を知らされていたとしても、本ソフトウェアの使用によって発生
00066  *  した(代替品または代用サービスの調達、使用の喪失、データの喪失、
00067  *  利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、
00068  *  間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
00069  *  ついて、一切責任を負わないものとします。
00070  *
00071  ****************************************************************************/
00072 #ifndef __FK_QUATERNION_HEADER__
00073 #define __FK_QUATERNION_HEADER__
00074 
00075 #include <FK/Vector.h>
00076 #include <FK/Angle.h>
00077 #include <FK/Matrix.h>
00078 
00080 
00113 class fk_Quaternion {
00114  public:
00115     double      s; 
00116     fk_Vector   v; 
00117 
00119 
00123     fk_Quaternion(void);
00124 
00126 
00139     fk_Quaternion(double s, double x, double y, double z);
00140 
00142 
00153     fk_Quaternion(const double s, const fk_Vector &v);
00154 
00156     fk_Quaternion(const fk_Quaternion &);
00157 
00159     //@(
00160 
00162 
00173     fk_Quaternion &     operator -(void) const;
00174 
00176 
00189     fk_Quaternion &     operator ~(void) const;
00190 
00192 
00211     fk_Quaternion &     operator !(void) const;
00212 
00213     //@)
00214 
00216     //@(
00217 
00219 
00232     bool                operator ==(const fk_Quaternion &) const;
00233 
00235 
00248     bool                operator !=(const fk_Quaternion &) const;
00249 
00250     //@)
00251 
00253     //@(
00254 
00256     fk_Quaternion &     operator =(const fk_Quaternion &);
00257 
00259 
00278     fk_Quaternion &     operator *=(const fk_Quaternion &);
00279 
00281 
00295     fk_Quaternion &     operator *=(double);
00296 
00298 
00312     fk_Quaternion &     operator /=(double);
00313 
00315 
00329     fk_Quaternion &     operator +=(const fk_Quaternion &);
00330 
00332 
00346     fk_Quaternion &     operator -=(const fk_Quaternion &);
00347 
00348     //@)
00349 
00351     //@(
00352 
00354 
00357     void        init(void);
00358 
00360 
00374     void        set(double s, double x, double y, double z);
00375 
00377 
00390     void        set(double s, const fk_Vector &v);
00391 
00393 
00412     void        setRotate(double theta, double x, double y, double z);
00413 
00415 
00432     void        setRotate(double theta, const fk_Vector &V);
00433 
00435 
00444     void        makeEuler(double h, double p, double b);
00445 
00447 
00454     void        makeEuler(const fk_Angle &angle);
00455 
00457 
00464     fk_Angle &  getEuler(void) const;
00465 
00467 
00476     double      norm(void) const;
00477 
00479 
00488     double      abs(void) const;
00489 
00491 
00497     bool        normalize(void);
00498 
00500 
00509     void        conj(void);             // 共役化
00510 
00512 
00529     bool        inverse(void);          // 逆元化
00530 
00532 
00536     fk_Matrix & conv(void) const;
00537 
00538     //@)
00539 
00541     //@(
00542     friend fk_Quaternion    operator *(const fk_Quaternion &,
00543                                        const fk_Quaternion &);
00544     friend fk_Quaternion    operator +(const fk_Quaternion &,
00545                                        const fk_Quaternion &);
00546     friend fk_Quaternion    operator -(const fk_Quaternion &,
00547                                        const fk_Quaternion &);
00548 
00549     friend fk_Quaternion    operator *(const fk_Quaternion &, double);
00550     friend fk_Quaternion    operator *(double, const fk_Quaternion &);
00551     friend fk_Quaternion    operator /(const fk_Quaternion &, double);
00552 
00553     friend fk_Vector        operator *(const fk_Quaternion &,
00554                                        const fk_Vector &);
00555 
00556     friend double           operator ^(const fk_Quaternion &,
00557                                        const fk_Quaternion &);
00558     //@)
00559 };
00560 
00562 
00588 fk_Quaternion   operator *(const fk_Quaternion &, const fk_Quaternion &);
00589 
00591 
00600 fk_Quaternion   operator +(const fk_Quaternion &, const fk_Quaternion &);
00601 
00603 
00612 fk_Quaternion   operator -(const fk_Quaternion &, const fk_Quaternion &);
00613 
00615 
00626 fk_Quaternion   operator *(const fk_Quaternion &, double);
00627 
00629 
00640 fk_Quaternion   operator *(double, const fk_Quaternion &);
00641 
00643 
00652 fk_Quaternion   operator /(const fk_Quaternion &, double);
00653 
00655 
00671 fk_Vector       operator *(const fk_Quaternion &, const fk_Vector &);
00672 
00674 
00698 double          operator ^(const fk_Quaternion &, const fk_Quaternion &);
00699 
00700 fk_Quaternion & fk_Q_Inter_Linear(const fk_Quaternion &,
00701                                   const fk_Quaternion &, double);
00702 
00703 fk_Quaternion & fk_Q_Inter_Sphere(const fk_Quaternion &,
00704                                   const fk_Quaternion &, double);
00705 
00706 #endif // !__FK_QUATERNION_HEADER__
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型 列挙型の値 フレンド マクロ定義