FineKernelToolKit  2.9.0
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型 列挙型の値 フレンド マクロ定義 ページ
Matrix.h
説明を見る。
1 /****************************************************************************
2  *
3  * Copyright (c) 1999-2014, Fine Kernel Project, All rights reserved.
4  *
5  * Redistribution and use in source and binary forms,
6  * with or without modification, are permitted provided that the
7  * following conditions are met:
8  *
9  * - Redistributions of source code must retain the above
10  * copyright notice, this list of conditions and the
11  * following disclaimer.
12  *
13  * - Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the
15  * following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * - Neither the name of the copyright holders nor the names
19  * of its contributors may be used to endorse or promote
20  * products derived from this software without specific
21  * prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  ****************************************************************************/
37 /****************************************************************************
38  *
39  * Copyright (c) 1999-2014, Fine Kernel Project, All rights reserved.
40  *
41  * 本ソフトウェアおよびソースコードのライセンスは、基本的に
42  * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。
43  *
44  * ソースコード形式かバイナリ形式か、変更するかしないかを問わず、
45  * 以下の条件を満たす場合に限り、再頒布および使用が許可されます。
46  *
47  * - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、
48  * および下記免責条項を含めること。
49  *
50  * - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の
51  * 資料に、上記の著作権表示、本条件一覧、および下記免責条項を
52  * 含めること。
53  *
54  * - 書面による特別の許可なしに、本ソフトウェアから派生した製品の
55  * 宣伝または販売促進に、本ソフトウェアの著作権者の名前または
56  * コントリビューターの名前を使用してはならない。
57  *
58  * 本ソフトウェアは、著作権者およびコントリビューターによって「現
59  * 状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、
60  * および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ
61  * に限定されない、いかなる保証もないものとします。著作権者もコン
62  * トリビューターも、事由のいかんを問わず、損害発生の原因いかんを
63  * 問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その
64  * 他の)不法行為であるかを問わず、仮にそのような損害が発生する可
65  * 能性を知らされていたとしても、本ソフトウェアの使用によって発生
66  * した(代替品または代用サービスの調達、使用の喪失、データの喪失、
67  * 利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、
68  * 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
69  * ついて、一切責任を負わないものとします。
70  *
71  ****************************************************************************/
72 #ifndef __FK_MATRIX_HEADER__
73 #define __FK_MATRIX_HEADER__
74 
75 #include <FK/Vector.h>
76 #include <FK/Angle.h>
77 
78 const double FK_MATRIX_EPS = 1.0e-12;
79 const double FK_MATRIX_EPS2 = 1.0e-16;
80 
81 
82 
84 
115  friend class fk_Matrix;
116  friend class fk_Vector;
117  friend class fk_HVector;
118 
119  protected:
120 
121 #ifndef FK_DOXYGEN_USER_PROCESS
122 
123  double m[4][4];
124  void MultVec(fk_HVector &, const fk_HVector &) const;
125 
126 #endif
127 
128  public:
129 
131 
134  fk_OrthoMatrix(void);
135 
138 
140 
141 
143 
150  fk_OrthoMatrix operator !(void) const;
151 
153 
198  double * operator [](int);
199 
201 
203 
204 
206 
218  bool operator ==(const fk_OrthoMatrix &) const;
219 
221 
233  bool operator !=(const fk_OrthoMatrix &) const;
235 
237 
238 
241 
243 
259 
261 
263 
264 
268  void init(void);
269 
271 
286  void set(int row, int col, double value);
287 
289 
304  void setRow(int row, const fk_Vector &vec);
305 
307 
322  void setRow(int row, const fk_HVector &vec);
323 
325 
340  void setCol(int col, const fk_Vector &vec);
341 
343 
358  void setCol(int col, const fk_HVector &vec);
359 
361 
367  fk_HVector getRow(int row);
368 
370 
376  fk_HVector getCol(int col);
377 
379 
386  bool inverse(void);
387 
389 
394  void negate(void);
395 
397 
402  void makeRot(double rad, fk_Axis axis);
403 
405 
411  void makeTrans(double x, double y, double z);
412 
414 
418  void makeTrans(const fk_Vector &v);
419 
421 
428  void makeEuler(double h, double p, double b);
429 
431 
436  void makeEuler(const fk_Angle &angle);
438 
439 #ifndef FK_DOXYGEN_USER_PROCESS
440 
441  void Print(std::string = "") const;
442 
443 #endif
444 
446 
447  friend fk_HVector operator *(const fk_OrthoMatrix &,
448  const fk_HVector &);
450  const fk_OrthoMatrix &);
451  friend fk_Matrix operator *(const fk_Matrix &, const fk_OrthoMatrix &);
452  friend fk_Matrix operator *(const fk_OrthoMatrix &, const fk_Matrix &);
453  friend fk_Matrix operator +(const fk_Matrix &, const fk_OrthoMatrix &);
454  friend fk_Matrix operator +(const fk_OrthoMatrix &, const fk_Matrix &);
455  friend fk_Matrix operator -(const fk_Matrix &, const fk_OrthoMatrix &);
456  friend fk_Matrix operator -(const fk_OrthoMatrix &, const fk_Matrix &);
458 };
459 
460 
462 
473  const fk_HVector &);
475 
488  const fk_OrthoMatrix &);
489 
491 
503 fk_Matrix operator *(const fk_Matrix &, const fk_OrthoMatrix &);
504 
506 
518 fk_Matrix operator *(const fk_OrthoMatrix &, const fk_Matrix &);
519 
521 
531 fk_Matrix operator +(const fk_Matrix &, const fk_OrthoMatrix &);
532 
534 
544 fk_Matrix operator +(const fk_OrthoMatrix &, const fk_Matrix &);
545 
547 
557 fk_Matrix operator -(const fk_Matrix &, const fk_OrthoMatrix &);
558 
560 
570 fk_Matrix operator -(const fk_OrthoMatrix &, const fk_Matrix &);
571 
572 
573 
575 
586 class fk_Matrix : public fk_OrthoMatrix {
587 
588  friend class fk_Vector;
589  friend class fk_HVector;
590 
591  public:
592 
594 
597  fk_Matrix(void);
598 
600  fk_Matrix(const fk_Matrix &);
601 
603 
604 
613  fk_Matrix operator !(void) const;
614 
616 
618 
619 
632  bool operator ==(const fk_Matrix &) const;
633 
635 
647  bool operator !=(const fk_Matrix &) const;
648 
650 
652 
653 
655  fk_Matrix & operator =(const fk_Matrix &);
656 
659 
661 
671  fk_Matrix & operator +=(const fk_Matrix &);
672 
674 
679 
681 
691  fk_Matrix & operator -=(const fk_Matrix &);
692 
694 
699 
701 
716  fk_Matrix & operator *=(const fk_Matrix &);
717 
719 
724 
726 
728 
729 
731 
737  bool isRegular(void) const;
738 
740 
747  bool isSingular(void) const;
748 
750 
757  bool inverse(void);
758 
760 
766  void makeScale(double x, double y, double z);
767 
769 
774  void makeScale(const fk_Vector &v);
775 
777 
779 
780  friend fk_HVector operator *(const fk_Matrix &, const fk_HVector &);
781  friend fk_Matrix operator *(const fk_Matrix &, const fk_Matrix &);
782  friend fk_Matrix operator *(double, const fk_Matrix &);
783  friend fk_Matrix operator *(const fk_Matrix &, double);
784  friend fk_Matrix operator +(const fk_Matrix &, const fk_Matrix &);
785  friend fk_Matrix operator -(const fk_Matrix &, const fk_Matrix &);
787 };
788 
790 
800 fk_HVector operator *(const fk_Matrix &, const fk_HVector &);
801 
803 
815 fk_Matrix operator *(const fk_Matrix &, const fk_Matrix &);
816 
818 
826 fk_Matrix operator *(double, const fk_Matrix &);
827 
829 
837 fk_Matrix operator *(const fk_Matrix &, double);
838 
840 
850 fk_Matrix operator +(const fk_Matrix &, const fk_Matrix &);
851 
853 
863 fk_Matrix operator -(const fk_Matrix &, const fk_Matrix &);
864 
865 
866 #endif /* !__FK_MATRIX_HEADER__ */
fk_Matrix operator!(void) const
逆行列取得演算子
一般4元正方行列を管理するクラス
Definition: Matrix.h:586
fk_HVector getRow(int row)
行ベクトル成分取得関数
double * operator[](int)
成分参照演算子
void makeScale(double x, double y, double z)
拡大縮小行列生成関数1
void makeEuler(double h, double p, double b)
オイラー角回転行列生成関数1
bool operator==(const fk_Matrix &) const
同値比較演算子
fk_Matrix & operator=(const fk_Matrix &)
単純代入演算子
fk_GenMatrix operator-(const fk_GenMatrix &, const fk_GenMatrix &)
行列差二項演算子
fk_OrthoMatrix & operator*=(const fk_OrthoMatrix &)
行列積代入演算子
fk_OrthoMatrix operator!(void) const
逆行列取得演算子
fk_Matrix(void)
コンストラクタ
オイラー角を表すクラス
Definition: Angle.h:90
void init(void)
単位行列化関数
friend fk_Matrix operator-(const fk_Matrix &, const fk_Matrix &)
行列差二項演算子
3次元ベクトルを管理するクラス
Definition: Vector.h:110
fk_Axis
座標軸を表す列挙型
Definition: Vector.h:82
bool operator==(const fk_OrthoMatrix &) const
同値比較演算子
double y
y成分
Definition: Vector.h:114
bool operator!=(const fk_OrthoMatrix &) const
異値比較演算子
fk_GenVector operator*(const fk_GenMatrix &, const fk_GenVector &)
ベクトル変換二項演算子
double z
z成分
Definition: Vector.h:115
bool isRegular(void) const
正則判定関数
void setCol(int col, const fk_Vector &vec)
列ベクトル成分設定関数1
4次元ベクトルを管理するクラス
Definition: Vector.h:542
friend fk_Matrix operator+(const fk_Matrix &, const fk_OrthoMatrix &)
行列和二項演算子1
4元正方直交行列を管理するクラス
Definition: Matrix.h:114
void makeRot(double rad, fk_Axis axis)
座標軸回転行列生成関数
double x
x成分
Definition: Vector.h:113
fk_Matrix & operator*=(const fk_Matrix &)
行列積代入演算子1
void makeTrans(double x, double y, double z)
平行移動行列生成関数1
bool inverse(void)
逆行列化関数
friend fk_Matrix operator-(const fk_Matrix &, const fk_OrthoMatrix &)
行列差二項演算子1
friend fk_HVector operator*(const fk_OrthoMatrix &, const fk_HVector &)
ベクトル変換二項演算子
void setRow(int row, const fk_Vector &vec)
行ベクトル成分設定関数1
fk_Matrix & operator+=(const fk_Matrix &)
行列和代入演算子1
void set(int row, int col, double value)
成分設定関数
const double FK_MATRIX_EPS
行列演算用誤差1
Definition: Matrix.h:78
bool inverse(void)
逆行列化関数
fk_OrthoMatrix & operator=(const fk_OrthoMatrix &)
単純代入演算子
fk_OrthoMatrix(void)
コンストラクタ
bool isSingular(void) const
特異判定関数
fk_GenMatrix operator+(const fk_GenMatrix &, const fk_GenMatrix &)
行列和二項演算子
friend fk_Matrix operator+(const fk_Matrix &, const fk_Matrix &)
行列和二項演算子
friend fk_HVector operator*(const fk_Matrix &, const fk_HVector &)
ベクトル変換二項演算子
bool operator!=(const fk_Matrix &) const
異値比較演算子
fk_Matrix & operator-=(const fk_Matrix &)
行列差代入演算子1
void negate(void)
転置化関数
fk_HVector getCol(int col)
列ベクトル成分取得関数
const double FK_MATRIX_EPS2
行列演算用誤差2
Definition: Matrix.h:79