Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpRotationMatrix.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Rotation matrix.
33  *
34  * Authors:
35  * Eric Marchand
36  *
37  *****************************************************************************/
38 
39 #ifndef vpROTATIONMATRIX_H
40 #define vpROTATIONMATRIX_H
41 
47 #include <visp3/core/vpArray2D.h>
48 #include <visp3/core/vpHomogeneousMatrix.h>
49 #include <visp3/core/vpPoseVector.h>
50 #include <visp3/core/vpQuaternionVector.h>
51 #include <visp3/core/vpRxyzVector.h>
52 #include <visp3/core/vpRzyxVector.h>
53 #include <visp3/core/vpRzyzVector.h>
54 #include <visp3/core/vpThetaUVector.h>
55 #include <visp3/core/vpTranslationVector.h>
56 
122 class VISP_EXPORT vpRotationMatrix : public vpArray2D<double>
123 {
124 public:
127  explicit vpRotationMatrix(const vpHomogeneousMatrix &M);
128  explicit vpRotationMatrix(const vpThetaUVector &r);
129  explicit vpRotationMatrix(const vpPoseVector &p);
130  explicit vpRotationMatrix(const vpRzyzVector &r);
131  explicit vpRotationMatrix(const vpRxyzVector &r);
132  explicit vpRotationMatrix(const vpRzyxVector &r);
133  explicit vpRotationMatrix(const vpQuaternionVector &q);
134  explicit vpRotationMatrix(const vpMatrix &R);
135  vpRotationMatrix(double tux, double tuy, double tuz);
136 
137 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
138  explicit vpRotationMatrix(const std::initializer_list<double> &list);
139 #endif
140 
144  virtual ~vpRotationMatrix(){};
145 
146  vpRotationMatrix buildFrom(const vpHomogeneousMatrix &M);
147  vpRotationMatrix buildFrom(const vpThetaUVector &v);
148  vpRotationMatrix buildFrom(const vpPoseVector &p);
149  vpRotationMatrix buildFrom(const vpRzyzVector &v);
150  vpRotationMatrix buildFrom(const vpRxyzVector &v);
151  vpRotationMatrix buildFrom(const vpRzyxVector &v);
152  vpRotationMatrix buildFrom(const vpQuaternionVector &q);
153  vpRotationMatrix buildFrom(double tux, double tuy, double tuz);
154 
155  void eye();
156 
157  vpColVector getCol(unsigned int j) const;
158  vpThetaUVector getThetaUVector();
159 
160  vpRotationMatrix inverse() const;
161  void inverse(vpRotationMatrix &R) const;
162 
163  bool isARotationMatrix() const;
164 
165  // copy operator from vpRotationMatrix
167  // copy operator from vpMatrix (handle with care)
169 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
170  vpRotationMatrix& operator=(const std::initializer_list<double> &list);
171 #endif
172  // operation c = A * b (A is unchanged)
174  // operation C = A * B (A is unchanged)
175  vpRotationMatrix operator*(const vpRotationMatrix &R) const;
176  // operation C = A * B (A is unchanged)
177  vpMatrix operator*(const vpMatrix &M) const;
178  // operation v2 = A * v1 (A is unchanged)
179  vpColVector operator*(const vpColVector &v) const;
180  vpRotationMatrix operator*(double x) const;
181  vpRotationMatrix &operator*=(double x);
182 
183  vpRotationMatrix& operator<<(double val);
184  vpRotationMatrix& operator,(double val);
185 
186 
187  void printVector();
188 
194  void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
195  {
196  (void)nrows;
197  (void)ncols;
198  (void)flagNullify;
199  throw(vpException(vpException::fatalError, "Cannot resize a rotation matrix"));
200  };
201 
202  // transpose
203  vpRotationMatrix t() const;
204 
205  static vpRotationMatrix mean(const std::vector<vpHomogeneousMatrix> &vec_M);
206  static vpRotationMatrix mean(const std::vector<vpRotationMatrix> &vec_R);
207 
208 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
209 
217  vp_deprecated void init(){};
221  vp_deprecated void setIdentity();
223 #endif
224 
225 private:
226  static const double threshold;
227 
228 protected:
229  unsigned int m_index;
230 };
231 
232 #ifndef DOXYGEN_SHOULD_SKIP_THIS
233 VISP_EXPORT
234 #endif
235 vpRotationMatrix operator*(const double &x, const vpRotationMatrix &R);
236 
237 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:414
Implementation of an homogeneous matrix and operations on such kind of matrices.
error that can be emited by ViSP classes.
Definition: vpException.h:71
Implementation of a generic 2D array used as base class for matrices and vectors. ...
Definition: vpArray2D.h:131
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRzyxVector.h:185
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true)
Implementation of a rotation matrix and operations on such kind of matrices.
virtual ~vpRotationMatrix()
vpColVector operator*(const double &x, const vpColVector &v)
vp_deprecated void init()
Implementation of a rotation vector as quaternion angle minimal representation.
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:494
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:151
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRxyzVector.h:183
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRzyzVector.h:182
unsigned int m_index
Class that consider the case of a translation vector.
Implementation of a rotation vector as axis-angle minimal representation.