Visual Servoing Platform  version 3.6.1 under development (2024-07-27)
vpRotationVector.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2024 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  * Generic rotation vector (cannot be used as is !).
32  */
33 
40 #ifndef VP_ROTATION_VECTOR_H
41 #define VP_ROTATION_VECTOR_H
42 
43 #include <iostream>
44 #include <math.h>
45 #include <stdio.h>
46 
47 #include <visp3/core/vpConfig.h>
48 #include <visp3/core/vpArray2D.h>
49 
51 
52 class vpRowVector;
53 class vpColVector;
54 
102 class VISP_EXPORT vpRotationVector : public vpArray2D<double>
103 {
104 public:
106  vpRotationVector() : vpArray2D<double>(), m_index(0) { }
107 
110  VP_EXPLICIT vpRotationVector(unsigned int n) : vpArray2D<double>(n, 1), m_index(0) { }
111 
115  vpRotationVector(const vpRotationVector &v) : vpArray2D<double>(v), m_index(0) { }
116 
119 
124  inline double &operator[](unsigned int i) { return *(data + i); }
129  inline const double &operator[](unsigned int i) const { return *(data + i); }
130 
135  {
136  resize(v.size(), 1);
137  unsigned int v_size = v.size();
138  for (unsigned int i = 0; i < v_size; ++i) {
139  data[i] = v.data[i];
140  }
141  return *this;
142  }
143 
144  vpColVector operator*(double x) const;
145 
146  vpRotationVector &operator<<(double val);
147  vpRotationVector &operator,(double val);
148 
149  double sumSquare() const;
150 
151  // Transpose of the rotation vector.
152  vpRowVector t() const;
153 
154  std::vector<double> toStdVector() const;
155 
157 
158 protected:
159  unsigned int m_index; // index used for operator<< and operator, to fill a vector
160 };
161 
162 #ifndef DOXYGEN_SHOULD_SKIP_THIS
163 VISP_EXPORT
164 #endif
165 VISP_NAMESPACE_ADDRESSING vpColVector operator*(const double &x, const VISP_NAMESPACE_ADDRESSING vpRotationVector &v);
166 END_VISP_NAMESPACE
167 #endif
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition: vpArray2D.h:145
Type * data
Address of the first element of the data array.
Definition: vpArray2D.h:148
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
Definition: vpArray2D.h:362
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:611
unsigned int size() const
Return the number of elements of the 2D array.
Definition: vpArray2D.h:349
vpArray2D< Type > t() const
Compute the transpose of the array.
Definition: vpArray2D.h:1163
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
vpColVector operator*(const double &x, const vpColVector &v)
Implementation of a generic rotation vector.
vpRotationVector(const vpRotationVector &v)
vpRotationVector & operator=(const vpRotationVector &v)
double & operator[](unsigned int i)
const double & operator[](unsigned int i) const
unsigned int m_index
vpRotationVector()
Constructor that constructs a 0-size rotation vector.
VP_EXPLICIT vpRotationVector(unsigned int n)
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:124
vpMatrix operator*(const double &x, const vpMatrix &A)