Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
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 
71 class VISP_EXPORT vpRotationMatrix : public vpArray2D<double>
72 {
73 public:
76  explicit vpRotationMatrix(const vpHomogeneousMatrix &M);
77  explicit vpRotationMatrix(const vpThetaUVector &r);
78  explicit vpRotationMatrix(const vpPoseVector &p);
79  explicit vpRotationMatrix(const vpRzyzVector &r);
80  explicit vpRotationMatrix(const vpRxyzVector &r);
81  explicit vpRotationMatrix(const vpRzyxVector &r);
82  explicit vpRotationMatrix(const vpQuaternionVector &q);
83  explicit vpRotationMatrix(const vpMatrix &R);
84  vpRotationMatrix(const double tux, const double tuy, const double tuz);
88  virtual ~vpRotationMatrix(){};
89 
90  vpRotationMatrix buildFrom(const vpHomogeneousMatrix &M);
91  vpRotationMatrix buildFrom(const vpThetaUVector &v);
92  vpRotationMatrix buildFrom(const vpPoseVector &p);
93  vpRotationMatrix buildFrom(const vpRzyzVector &v);
94  vpRotationMatrix buildFrom(const vpRxyzVector &v);
95  vpRotationMatrix buildFrom(const vpRzyxVector &v);
96  vpRotationMatrix buildFrom(const vpQuaternionVector &q);
97  vpRotationMatrix buildFrom(const double tux, const double tuy, const double tuz);
98 
99  void eye();
100 
101  vpColVector getCol(const unsigned int j) const;
102  vpThetaUVector getThetaUVector();
103 
104  vpRotationMatrix inverse() const;
105  void inverse(vpRotationMatrix &R) const;
106 
107  bool isARotationMatrix() const;
108 
109  // copy operator from vpRotationMatrix
111  // copy operator from vpMatrix (handle with care)
113  // operation c = A * b (A is unchanged)
115  // operation C = A * B (A is unchanged)
116  vpRotationMatrix operator*(const vpRotationMatrix &R) const;
117  // operation C = A * B (A is unchanged)
118  vpMatrix operator*(const vpMatrix &M) const;
119  // operation v2 = A * v1 (A is unchanged)
120  vpColVector operator*(const vpColVector &v) const;
121  vpRotationMatrix operator*(const double x) const;
122  vpRotationMatrix &operator*=(const double x);
123 
124  void printVector();
125 
131  void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify = true)
132  {
133  (void)nrows;
134  (void)ncols;
135  (void)flagNullify;
136  throw(vpException(vpException::fatalError, "Cannot resize a rotation matrix"));
137  };
138 
139  // transpose
140  vpRotationMatrix t() const;
141 
142  static vpRotationMatrix mean(const std::vector<vpHomogeneousMatrix> &vec_M);
143  static vpRotationMatrix mean(const std::vector<vpRotationMatrix> &vec_R);
144 
145 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
146 
154  vp_deprecated void init(){};
158  vp_deprecated void setIdentity();
160 #endif
161 
162 private:
163  static const double threshold;
164 };
165 
166 #ifndef DOXYGEN_SHOULD_SKIP_THIS
167 VISP_EXPORT
168 #endif
169 vpRotationMatrix operator*(const double &x, const vpRotationMatrix &R);
170 
171 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:247
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 vase class of matrices and vectors.
Definition: vpArray2D.h:70
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRzyxVector.h:158
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()
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
Implementation of a rotation vector as quaternion angle minimal representation.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:92
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRxyzVector.h:156
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRzyzVector.h:154
Class that consider the case of a translation vector.
Implementation of a rotation vector as axis-angle minimal representation.