Visual Servoing Platform  version 3.6.1 under development (2024-03-04)
vpRotationVector.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  * Generic rotation vector (cannot be used as is !).
32  */
33 
34 #ifndef _vpRotationVector_h_
35 #define _vpRotationVector_h_
36 
43 #include <iostream>
44 #include <math.h>
45 #include <stdio.h>
46 
47 #include <visp3/core/vpArray2D.h>
48 
49 class vpRowVector;
50 class vpColVector;
51 
95 class VISP_EXPORT vpRotationVector : public vpArray2D<double>
96 {
97 public:
99  vpRotationVector() : vpArray2D<double>(), m_index(0) { }
100 
103  explicit vpRotationVector(unsigned int n) : vpArray2D<double>(n, 1), m_index(0) { }
104 
108  vpRotationVector(const vpRotationVector &v) : vpArray2D<double>(v), m_index(0) { }
109 
112 
117  inline double &operator[](unsigned int i) { return *(data + i); }
122  inline const double &operator[](unsigned int i) const { return *(data + i); }
123 
128  {
129  resize(v.size(), 1);
130  for (unsigned int i = 0; i < v.size(); i++) {
131  data[i] = v.data[i];
132  }
133  return *this;
134  }
135 
136  vpColVector operator*(double x) const;
137 
138  vpRotationVector &operator<<(double val);
139  vpRotationVector &operator,(double val);
140 
141  double sumSquare() const;
142 
143  // Transpose of the rotation vector.
144  vpRowVector t() const;
145 
146  std::vector<double> toStdVector() const;
147 
149 
150 protected:
151  unsigned int m_index; // index used for operator<< and operator, to fill a vector
152 };
153 
154 #ifndef DOXYGEN_SHOULD_SKIP_THIS
155 VISP_EXPORT
156 #endif
157 vpColVector operator*(const double &x, const vpRotationVector &v);
158 
159 #endif
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition: vpArray2D.h:125
Type * data
Address of the first element of the data array.
Definition: vpArray2D.h:138
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
Definition: vpArray2D.h:299
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:523
unsigned int size() const
Return the number of elements of the 2D array.
Definition: vpArray2D.h:286
vpArray2D< Type > t() const
Compute the transpose of the array.
Definition: vpArray2D.h:1055
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
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.
vpRotationVector(unsigned int n)
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:107
vpMatrix operator*(const double &x, const vpMatrix &A)