Matrix4.hh
00001 /* 00002 * Copyright 2011 Nate Koenig & Andrew Howard 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 #ifndef MATRIX4_HH 00018 #define MATRIX4_HH 00019 00020 #include <iostream> 00021 #include <assert.h> 00022 00023 #include "math/Vector3.hh" 00024 #include "math/Matrix3.hh" 00025 00026 namespace gazebo 00027 { 00028 namespace math 00029 { 00032 00034 class Matrix4 00035 { 00037 public: Matrix4(); 00038 00041 public: Matrix4(const Matrix4 &m); 00042 00060 public: Matrix4(double _v00, double _v01, double _v02, double _v03, 00061 double _v10, double _v11, double _v12, double _v13, 00062 double _v20, double _v21, double _v22, double _v23, 00063 double _v30, double _v31, double _v32, double _v33); 00064 00066 public: virtual ~Matrix4(); 00067 00085 public: void Set(double _v00, double _v01, double _v02, double _v03, 00086 double _v10, double _v11, double _v12, double _v13, 00087 double _v20, double _v21, double _v22, double _v23, 00088 double _v30, double _v31, double _v32, double _v33); 00089 00090 00091 00094 public: void SetTranslate(const Vector3 &_t); 00095 00098 public: void SetScale(const Vector3 &_s); 00099 00102 public: bool IsAffine() const; 00103 00107 public: Vector3 TransformAffine( const Vector3 &_v ) const; 00108 00112 public: const Matrix4 &operator=( const Matrix4 &_mat ); 00113 00117 public: const Matrix4 & operator=( const Matrix3 &_mat ); 00118 00122 public: Matrix4 operator*(const Matrix4 &_mat) const; 00123 00127 public: Matrix4 operator*(const Matrix3 &_mat) const; 00128 00129 00133 public: Vector3 operator*(const Vector3 &_vec) const; 00134 00135 public: inline double *operator [] (size_t _row) 00136 { 00137 assert( _row < 4 ); 00138 return this->m[_row]; 00139 } 00140 00141 public: inline const double *operator [] (size_t _row) const 00142 { 00143 assert( _row < 4 ); 00144 return this->m[_row]; 00145 } 00146 00150 public: friend std::ostream &operator<<( std::ostream &_out, 00151 const gazebo::math::Matrix4 &_m ) 00152 { 00153 for (int i=0; i < 4; i++) 00154 { 00155 for (int j=0; j < 4; j++) 00156 { 00157 _out << _m.m[i][j] << " "; 00158 } 00159 _out << "\n"; 00160 } 00161 00162 return _out; 00163 } 00164 00166 public: static const Matrix4 IDENTITY; 00167 00169 public: static const Matrix4 ZERO; 00170 00172 protected: double m[4][4]; 00173 }; 00175 } 00176 } 00177 #endif

1.7.5.1