All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Matrix3.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef MATRIX3_HH
18 #define MATRIX3_HH
19 
20 #include <assert.h>
21 
22 #include "math/Vector3.hh"
23 
24 namespace gazebo
25 {
26  namespace math
27  {
30 
32  class Matrix3
33  {
35  public: Matrix3();
36 
39  public: Matrix3(const Matrix3 &_m);
40 
51  public: Matrix3(double _v00, double _v01, double _v02,
52  double _v10, double _v11, double _v12,
53  double _v20, double _v21, double _v22);
54 
56  public: virtual ~Matrix3();
57 
62  public: void SetFromAxes(const Vector3 &_xAxis,
63  const Vector3 &_yAxis,
64  const Vector3 &_zAxis);
65 
66 
70  public: void SetFromAxis(const Vector3 &_axis, double _angle);
71 
75  public: void SetCol(unsigned int _c, const Vector3 &_v);
76 
80  public: bool operator==(const Matrix3 &_m) const;
81 
85  public: inline const double *operator[](size_t _row) const
86  {
87  assert(_row < 3);
88  return this->m[_row];
89  }
90 
94  public: inline double *operator[](size_t _row)
95  {
96  assert(_row < 3);
97  return this->m[_row];
98  }
99 
100 
105  public: friend std::ostream &operator<<(std::ostream &_out,
106  const gazebo::math::Matrix3 &_m)
107  {
108  for (int i = 0; i < 3; i++)
109  {
110  for (int j = 0; j < 3; j++)
111  {
112  _out << _m.m[i][j] << " ";
113  }
114  _out << "\n";
115  }
116 
117  return _out;
118  }
119 
121  protected: double m[3][3];
122 
123  friend class Matrix4;
124  };
126  }
127 }
128 #endif
129 
130 
131