Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
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 substraction 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 
172 
178  void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
179  {
180  (void)nrows;
181  (void)ncols;
182  (void)flagNullify;
183  throw(vpException(vpException::fatalError, "Cannot resize a translation vector"));
184  };
185 
186  void set(double tx, double ty, double tz);
187 
188  // Skew Symmetric matrix
189  vpMatrix skew() const;
190 
191  double sumSquare() const;
192 
193  vpRowVector t() const;
194 
195  static vpTranslationVector cross(const vpTranslationVector &a, const vpTranslationVector &b);
196  static vpTranslationVector mean(const std::vector<vpHomogeneousMatrix> &vec_M);
197  static vpTranslationVector mean(const std::vector<vpTranslationVector> &vec_t);
198  static vpMatrix skew(const vpTranslationVector &tv);
199  static void skew(const vpTranslationVector &tv, vpMatrix &M);
200 
201 protected:
202  unsigned int m_index; // index used for operator<< and operator, to fill a vector
203 };
204 
205 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:414
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:115
error that can be emited by ViSP classes.
Definition: vpException.h:71
double & operator[](unsigned int n)
Operator that allows to set a value of an element : t[i] = x.
Implementation of a generic 2D array used as base class for matrices and vectors. ...
Definition: vpArray2D.h:131
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true)
vpColVector operator*(const double &x, const vpColVector &v)
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:494
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:151
const double & operator[](unsigned int n) const
Operator that allows to get the value of an element : x = t[i].
Class that consider the case of a translation vector.