Visual Servoing Platform  version 3.5.1 under development (2023-03-14)
vpTranslationVector.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  * Translation vector.
33  *
34  * Authors:
35  * Eric Marchand
36  * Fabien Spindler
37  *
38  *****************************************************************************/
39 
40 #ifndef vpTRANSLATIONVECTOR_H
41 #define vpTRANSLATIONVECTOR_H
42 
48 #include <visp3/core/vpArray2D.h>
49 #include <visp3/core/vpHomogeneousMatrix.h>
50 #include <visp3/core/vpMatrix.h>
51 #include <visp3/core/vpPoseVector.h>
52 
119 class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
120 {
121 public:
126  vpTranslationVector() : vpArray2D<double>(3, 1), m_index(0){};
127  vpTranslationVector(double tx, double ty, double tz);
129  explicit vpTranslationVector(const vpHomogeneousMatrix &M);
130  explicit vpTranslationVector(const vpPoseVector &p);
131  explicit vpTranslationVector(const vpColVector &v);
132 
133  vpTranslationVector buildFrom(double tx, double ty, double tz);
134  vpTranslationVector buildFrom(const vpHomogeneousMatrix &M);
135  vpTranslationVector buildFrom(const vpPoseVector &p);
136  vpTranslationVector buildFrom(const vpColVector &v);
137 
138  vp_deprecated double euclideanNorm() const;
139  double frobeniusNorm() const;
140 
141  // operators
142 
143  // translation vectors additions c = a + b (a, b unchanged)
144  vpTranslationVector operator+(const vpTranslationVector &tv) const;
145  vpTranslationVector operator+(const vpColVector &v) const;
146  // translation vectors subtraction c = a - b (a, b unchanged)
147  vpTranslationVector operator-(const vpTranslationVector &tv) const;
148  // negate t = -a (t is unchanged)
149  vpTranslationVector operator-() const;
150  vpMatrix operator*(const vpRowVector &v) const;
151  // b = x * a (x=scalar)
152  vpTranslationVector operator*(double x) const;
153  vpTranslationVector &operator*=(double x);
154  vpTranslationVector operator/(double x) const;
155  vpTranslationVector &operator/=(double x);
156  // Copy operator. Allow operation such as A = v
159  vpTranslationVector &operator=(double x);
160 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
161  vpTranslationVector &operator=(const std::initializer_list<double> &list);
162 #endif
163 
165  inline double &operator[](unsigned int n) { return *(data + n); }
167  inline const double &operator[](unsigned int n) const { return *(data + n); }
168 
169  vpTranslationVector &operator<<(double val);
170  vpTranslationVector &operator,(double val);
171 
177  void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
178  {
179  (void)nrows;
180  (void)ncols;
181  (void)flagNullify;
182  throw(vpException(vpException::fatalError, "Cannot resize a translation vector"));
183  };
184 
185  void set(double tx, double ty, double tz);
186 
187  // Skew Symmetric matrix
188  vpMatrix skew() const;
189 
190  double sumSquare() const;
191 
192  vpRowVector t() const;
193 
194  static vpTranslationVector cross(const vpTranslationVector &a, const vpTranslationVector &b);
195  static vpTranslationVector mean(const std::vector<vpHomogeneousMatrix> &vec_M);
196  static vpTranslationVector mean(const std::vector<vpTranslationVector> &vec_t);
197  static vpMatrix skew(const vpTranslationVector &tv);
198  static void skew(const vpTranslationVector &tv, vpMatrix &M);
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:129
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:491
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:411
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
error that can be emited by ViSP classes.
Definition: vpException.h:72
@ fatalError
Fatal error.
Definition: vpException.h:96
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:152
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:116
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)
vpColVector operator*(const double &x, const vpColVector &v)