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 2012 Open Source Robotics Foundation
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 
33  class Matrix3
34  {
36  public: Matrix3();
37 
40  public: Matrix3(const Matrix3 &_m);
41 
52  public: Matrix3(double _v00, double _v01, double _v02,
53  double _v10, double _v11, double _v12,
54  double _v20, double _v21, double _v22);
55 
57  public: virtual ~Matrix3();
58 
63  public: void SetFromAxes(const Vector3 &_xAxis,
64  const Vector3 &_yAxis,
65  const Vector3 &_zAxis);
66 
67 
71  public: void SetFromAxis(const Vector3 &_axis, double _angle);
72 
76  public: void SetCol(unsigned int _c, const Vector3 &_v);
77 
81  public: bool operator==(const Matrix3 &_m) const;
82 
86  public: inline const double *operator[](size_t _row) const
87  {
88  assert(_row < 3);
89  return this->m[_row];
90  }
91 
95  public: inline double *operator[](size_t _row)
96  {
97  assert(_row < 3);
98  return this->m[_row];
99  }
100 
101 
106  public: friend std::ostream &operator<<(std::ostream &_out,
107  const gazebo::math::Matrix3 &_m)
108  {
109  for (int i = 0; i < 3; i++)
110  {
111  for (int j = 0; j < 3; j++)
112  {
113  _out << _m.m[i][j] << " ";
114  }
115  _out << "\n";
116  }
117 
118  return _out;
119  }
120 
122  protected: double m[3][3];
123 
124  friend class Matrix4;
125  };
127  }
128 }
129 #endif
130 
131 
132