FineKernelToolKit
2.8.10
|
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_MATRIX_HEADER__ 00073 #define __FK_MATRIX_HEADER__ 00074 00075 #include <FK/Vector.h> 00076 #include <FK/Angle.h> 00077 00078 const double FK_MATRIX_EPS = 1.0e-12; 00079 const double FK_MATRIX_EPS2 = 1.0e-16; 00080 00081 00082 00084 00114 class fk_OrthoMatrix { 00115 friend class fk_Matrix; 00116 friend class fk_Vector; 00117 friend class fk_HVector; 00118 00119 protected: 00120 00121 #ifndef FK_DOXYGEN_USER_PROCESS 00122 00123 double m[4][4]; 00124 void MultVec(fk_HVector &, const fk_HVector &) const; 00125 00126 #endif 00127 00128 public: 00129 00131 00134 fk_OrthoMatrix(void); 00135 00137 fk_OrthoMatrix(const fk_OrthoMatrix &); 00138 00140 //@( 00141 00143 00152 fk_OrthoMatrix operator !(void) const; 00153 00155 00202 double * operator [](int); 00203 00204 //@) 00205 00207 //@( 00208 00210 00224 bool operator ==(const fk_OrthoMatrix &) const; 00225 00227 00241 bool operator !=(const fk_OrthoMatrix &) const; 00242 //@) 00243 00245 //@( 00246 00248 fk_OrthoMatrix & operator =(const fk_OrthoMatrix &); 00249 00251 00270 fk_OrthoMatrix & operator *=(const fk_OrthoMatrix &); 00271 00272 //@) 00273 00275 //@( 00277 00280 void init(void); 00281 00283 00298 void set(int row, int col, double value); 00299 00301 00318 void setRow(int row, const fk_Vector &vec); 00319 00321 00338 void setRow(int row, const fk_HVector &vec); 00339 00341 00358 void setCol(int col, const fk_Vector &vec); 00359 00361 00378 void setCol(int col, const fk_HVector &vec); 00379 00381 00387 fk_HVector getRow(int row); 00388 00390 00396 fk_HVector getCol(int col); 00397 00399 00406 bool inverse(void); 00407 00409 00414 void negate(void); 00415 00417 00422 void makeRot(double rad, fk_Axis axis); 00423 00425 00431 void makeTrans(double x, double y, double z); 00432 00434 00438 void makeTrans(const fk_Vector &v); 00439 00441 00448 void makeEuler(double h, double p, double b); 00449 00451 00456 void makeEuler(const fk_Angle &angle); 00457 //@) 00458 00459 #ifndef FK_DOXYGEN_USER_PROCESS 00460 00461 void Print(std::string = "") const; 00462 00463 #endif 00464 00466 //@( 00467 friend fk_HVector operator *(const fk_OrthoMatrix &, 00468 const fk_HVector &); 00469 friend fk_OrthoMatrix operator *(const fk_OrthoMatrix &, 00470 const fk_OrthoMatrix &); 00471 friend fk_Matrix operator *(const fk_Matrix &, const fk_OrthoMatrix &); 00472 friend fk_Matrix operator *(const fk_OrthoMatrix &, const fk_Matrix &); 00473 friend fk_Matrix operator +(const fk_Matrix &, const fk_OrthoMatrix &); 00474 friend fk_Matrix operator +(const fk_OrthoMatrix &, const fk_Matrix &); 00475 friend fk_Matrix operator -(const fk_Matrix &, const fk_OrthoMatrix &); 00476 friend fk_Matrix operator -(const fk_OrthoMatrix &, const fk_Matrix &); 00477 //@) 00478 }; 00479 00480 00482 00494 fk_HVector operator *(const fk_OrthoMatrix &, 00495 const fk_HVector &); 00497 00511 fk_OrthoMatrix operator *(const fk_OrthoMatrix &, 00512 const fk_OrthoMatrix &); 00513 00515 00529 fk_Matrix operator *(const fk_Matrix &, const fk_OrthoMatrix &); 00530 00532 00546 fk_Matrix operator *(const fk_OrthoMatrix &, const fk_Matrix &); 00547 00549 00561 fk_Matrix operator +(const fk_Matrix &, const fk_OrthoMatrix &); 00562 00564 00576 fk_Matrix operator +(const fk_OrthoMatrix &, const fk_Matrix &); 00577 00579 00591 fk_Matrix operator -(const fk_Matrix &, const fk_OrthoMatrix &); 00592 00594 00606 fk_Matrix operator -(const fk_OrthoMatrix &, const fk_Matrix &); 00607 00608 00609 00611 00622 class fk_Matrix : public fk_OrthoMatrix { 00623 00624 friend class fk_Vector; 00625 friend class fk_HVector; 00626 00627 public: 00628 00630 00633 fk_Matrix(void); 00634 00636 fk_Matrix(const fk_Matrix &); 00637 00639 //@( 00641 00651 fk_Matrix operator !(void) const; 00652 00653 //@) 00654 00656 //@( 00658 00672 bool operator ==(const fk_Matrix &) const; 00673 00675 00689 bool operator !=(const fk_Matrix &) const; 00690 00691 //@) 00692 00694 //@( 00695 00697 fk_Matrix & operator =(const fk_Matrix &); 00698 00700 fk_Matrix & operator =(const fk_OrthoMatrix &); 00701 00703 00717 fk_Matrix & operator +=(const fk_Matrix &); 00718 00720 00724 fk_Matrix & operator +=(const fk_OrthoMatrix &); 00725 00727 00741 fk_Matrix & operator -=(const fk_Matrix &); 00742 00744 00748 fk_Matrix & operator -=(const fk_OrthoMatrix &); 00749 00751 00770 fk_Matrix & operator *=(const fk_Matrix &); 00771 00773 00777 fk_Matrix & operator *=(const fk_OrthoMatrix &); 00778 00779 //@) 00780 00782 //@( 00783 00785 00791 bool isRegular(void) const; 00792 00794 00801 bool isSingular(void) const; 00802 00804 00811 bool inverse(void); 00812 00814 00820 void makeScale(double x, double y, double z); 00821 00823 00828 void makeScale(const fk_Vector &v); 00829 00830 //@) 00831 00833 //@( 00834 friend fk_HVector operator *(const fk_Matrix &, const fk_HVector &); 00835 friend fk_Matrix operator *(const fk_Matrix &, const fk_Matrix &); 00836 friend fk_Matrix operator +(const fk_Matrix &, const fk_Matrix &); 00837 friend fk_Matrix operator -(const fk_Matrix &, const fk_Matrix &); 00838 //@) 00839 }; 00840 00842 00854 fk_HVector operator *(const fk_Matrix &, const fk_HVector &); 00855 00857 00871 fk_Matrix operator *(const fk_Matrix &, const fk_Matrix &); 00872 00874 00886 fk_Matrix operator +(const fk_Matrix &, const fk_Matrix &); 00887 00889 00901 fk_Matrix operator -(const fk_Matrix &, const fk_Matrix &); 00902 00903 00904 #endif /* !__FK_MATRIX_HEADER__ */