Visual Servoing Platform  version 3.6.1 under development (2024-02-13)
vpRotationMatrix.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Rotation matrix.
32  */
33 
34 #ifndef _vpRotationMatrix_h_
35 #define _vpRotationMatrix_h_
36 
42 #include <visp3/core/vpArray2D.h>
43 #include <visp3/core/vpHomogeneousMatrix.h>
44 #include <visp3/core/vpPoseVector.h>
45 #include <visp3/core/vpQuaternionVector.h>
46 #include <visp3/core/vpRxyzVector.h>
47 #include <visp3/core/vpRzyxVector.h>
48 #include <visp3/core/vpRzyzVector.h>
49 #include <visp3/core/vpThetaUVector.h>
50 #include <visp3/core/vpTranslationVector.h>
51 
115 class VISP_EXPORT vpRotationMatrix : public vpArray2D<double>
116 {
117 public:
120  explicit vpRotationMatrix(const vpHomogeneousMatrix &M);
121  explicit vpRotationMatrix(const vpThetaUVector &r);
122  explicit vpRotationMatrix(const vpPoseVector &p);
123  explicit vpRotationMatrix(const vpRzyzVector &r);
124  explicit vpRotationMatrix(const vpRxyzVector &r);
125  explicit vpRotationMatrix(const vpRzyxVector &r);
126  explicit vpRotationMatrix(const vpQuaternionVector &q);
127  explicit vpRotationMatrix(const vpMatrix &R);
128  vpRotationMatrix(double tux, double tuy, double tuz);
129 
130 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
131  explicit vpRotationMatrix(const std::initializer_list<double> &list);
132 #endif
133 
134  vpRotationMatrix buildFrom(const vpHomogeneousMatrix &M);
135  vpRotationMatrix buildFrom(const vpThetaUVector &v);
136  vpRotationMatrix buildFrom(const vpPoseVector &p);
137  vpRotationMatrix buildFrom(const vpRzyzVector &v);
138  vpRotationMatrix buildFrom(const vpRxyzVector &v);
139  vpRotationMatrix buildFrom(const vpRzyxVector &v);
140  vpRotationMatrix buildFrom(const vpQuaternionVector &q);
141  vpRotationMatrix buildFrom(double tux, double tuy, double tuz);
142 
143  void eye();
144 
145  vpColVector getCol(unsigned int j) const;
146  vpThetaUVector getThetaUVector();
147 
148  vpRotationMatrix inverse() const;
149  void inverse(vpRotationMatrix &R) const;
150 
151  bool isARotationMatrix(double threshold = 1e-6) const;
152 
153  // copy operator from vpRotationMatrix
155  // copy operator from vpMatrix (handle with care)
157 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
158  vpRotationMatrix &operator=(const std::initializer_list<double> &list);
159 #endif
160  // operation c = A * b (A is unchanged)
162  // operation C = A * B (A is unchanged)
164  // operation C = A * B (A is unchanged)
166  vpMatrix operator*(const vpMatrix &M) const;
167  // operation v2 = A * v1 (A is unchanged)
168  vpColVector operator*(const vpColVector &v) const;
169  vpRotationMatrix operator*(double x) const;
170  vpRotationMatrix &operator*=(double x);
171 
172  vpRotationMatrix &operator<<(double val);
173  vpRotationMatrix &operator,(double val);
174 
175  void orthogonalize();
176 
177  void printVector();
178 
184  void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
185  {
186  (void)nrows;
187  (void)ncols;
188  (void)flagNullify;
189  throw(vpException(vpException::fatalError, "Cannot resize a rotation matrix"));
190  }
191 
192  // transpose
193  vpRotationMatrix t() const;
194 
195  static vpRotationMatrix mean(const std::vector<vpHomogeneousMatrix> &vec_M);
196  static vpRotationMatrix mean(const std::vector<vpRotationMatrix> &vec_R);
197 
198 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
207  vp_deprecated void init() { }
211  vp_deprecated void setIdentity();
213 #endif
214 
215 protected:
216  unsigned int m_index;
217 };
218 
219 #ifndef DOXYGEN_SHOULD_SKIP_THIS
220 VISP_EXPORT
221 #endif
222 vpRotationMatrix operator*(const double &x, const vpRotationMatrix &R);
223 
224 #endif
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition: vpArray2D.h:125
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:523
vpArray2D< Type > t() const
Compute the transpose of the array.
Definition: vpArray2D.h:1055
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:439
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
vpColVector operator*(const double &x, const vpColVector &v)
error that can be emitted by ViSP classes.
Definition: vpException.h:59
@ fatalError
Fatal error.
Definition: vpException.h:84
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:189
Implementation of a rotation vector as quaternion angle minimal representation.
Implementation of a rotation matrix and operations on such kind of matrices.
unsigned int m_index
vp_deprecated void init()
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true)
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRxyzVector.h:176
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRzyxVector.h:177
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRzyzVector.h:175
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.
vpMatrix operator*(const double &x, const vpMatrix &A)