Visual Servoing Platform  version 3.6.1 under development (2024-03-28)
vpTranslationVector.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  * Translation vector.
32  */
33 
34 #ifndef vpTRANSLATIONVECTOR_H
35 #define vpTRANSLATIONVECTOR_H
36 
42 #include <visp3/core/vpArray2D.h>
43 #include <visp3/core/vpHomogeneousMatrix.h>
44 #include <visp3/core/vpMatrix.h>
45 #include <visp3/core/vpPoseVector.h>
46 
111 class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
112 {
113 public:
118  vpTranslationVector() : vpArray2D<double>(3, 1), m_index(0) { }
119  vpTranslationVector(double tx, double ty, double tz);
121  explicit vpTranslationVector(const vpHomogeneousMatrix &M);
122  explicit vpTranslationVector(const vpPoseVector &p);
123  explicit vpTranslationVector(const vpColVector &v);
124 
125  vpTranslationVector buildFrom(double tx, double ty, double tz);
126  vpTranslationVector buildFrom(const vpHomogeneousMatrix &M);
127  vpTranslationVector buildFrom(const vpPoseVector &p);
128  vpTranslationVector buildFrom(const vpColVector &v);
129 
130  double frobeniusNorm() const;
131 
132  // operators
133 
134  // translation vectors additions c = a + b (a, b unchanged)
135  vpTranslationVector operator+(const vpTranslationVector &tv) const;
136  vpTranslationVector operator+(const vpColVector &v) const;
137  // translation vectors subtraction c = a - b (a, b unchanged)
138  vpTranslationVector operator-(const vpTranslationVector &tv) const;
139  // negate t = -a (t is unchanged)
140  vpTranslationVector operator-() const;
141  vpMatrix operator*(const vpRowVector &v) const;
142  // b = x * a (x=scalar)
143  vpTranslationVector operator*(double x) const;
144  vpTranslationVector &operator*=(double x);
145  vpTranslationVector operator/(double x) const;
146  vpTranslationVector &operator/=(double x);
147  // Copy operator. Allow operation such as A = v
150  vpTranslationVector &operator=(double x);
151 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
152  vpTranslationVector &operator=(const std::initializer_list<double> &list);
153 #endif
154 
156  inline double &operator[](unsigned int n) { return *(data + n); }
158  inline const double &operator[](unsigned int n) const { return *(data + n); }
159 
160  vpTranslationVector &operator<<(double val);
161  vpTranslationVector &operator,(double val);
162 
168  void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
169  {
170  (void)nrows;
171  (void)ncols;
172  (void)flagNullify;
173  throw(vpException(vpException::fatalError, "Cannot resize a translation vector"));
174  }
175 
176  void set(double tx, double ty, double tz);
177 
178  // Skew Symmetric matrix
179  vpMatrix skew() const;
180 
181  double sumSquare() const;
182 
183  vpRowVector t() const;
184 
185  static vpTranslationVector cross(const vpTranslationVector &a, const vpTranslationVector &b);
186  static vpTranslationVector mean(const std::vector<vpHomogeneousMatrix> &vec_M);
187  static vpTranslationVector mean(const std::vector<vpTranslationVector> &vec_t);
188  static vpMatrix skew(const vpTranslationVector &tv);
189  static void skew(const vpTranslationVector &tv, vpMatrix &M);
190 
191 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
196  vp_deprecated double euclideanNorm() const;
197  //}
198 #endif
199 
200 protected:
201  unsigned int m_index; // index used for operator<< and operator, to fill a vector
202 };
203 
204 #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:547
vpArray2D< Type > t() const
Compute the transpose of the array.
Definition: vpArray2D.h:1079
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:459
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
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 row vector and the associated operations.
Definition: vpRowVector.h:107
Class that consider the case of a translation vector.
double & operator[](unsigned int n)
Operator that allows to set a value of an element : t[i] = x.
const double & operator[](unsigned int n) const
Operator that allows to get the value of an element : x = t[i].
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true)
vpMatrix operator*(const double &x, const vpMatrix &A)