Visual Servoing Platform  version 3.6.1 under development (2024-12-17)
vpTranslationVector.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  * Translation vector.
32  */
33 
39 #ifndef VP_TRANSLATION_VECTOR_H
40 #define VP_TRANSLATION_VECTOR_H
41 
42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpArray2D.h>
44 #include <visp3/core/vpHomogeneousMatrix.h>
45 #include <visp3/core/vpPoseVector.h>
46 
47 BEGIN_VISP_NAMESPACE
48 class vpMatrix;
49 
118 class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
119 {
120 public:
125  vpTranslationVector() : vpArray2D<double>(3, 1), m_index(0) { }
126  vpTranslationVector(double tx, double ty, double tz);
128  VP_EXPLICIT vpTranslationVector(const vpHomogeneousMatrix &M);
129  VP_EXPLICIT vpTranslationVector(const vpPoseVector &p);
130  VP_EXPLICIT vpTranslationVector(const vpColVector &v);
131 
132  vpTranslationVector &buildFrom(const double &tx, const double &ty, const double &tz);
133  vpTranslationVector &buildFrom(const vpHomogeneousMatrix &M);
134  vpTranslationVector &buildFrom(const vpPoseVector &p);
135  vpTranslationVector &buildFrom(const vpColVector &v);
136 
137  double frobeniusNorm() const;
138 
139  // operators
140 
141  // translation vectors additions c = a + b (a, b unchanged)
142  vpTranslationVector operator+(const vpTranslationVector &tv) const;
143  vpTranslationVector operator+(const vpColVector &v) const;
144  // translation vectors subtraction c = a - b (a, b unchanged)
145  vpTranslationVector operator-(const vpTranslationVector &tv) const;
146  // negate t = -a (t is unchanged)
147  vpTranslationVector operator-() const;
148  vpMatrix operator*(const vpRowVector &v) const;
149  // b = x * a (x=scalar)
150  vpTranslationVector operator*(double x) const;
151  vpTranslationVector &operator*=(double x);
152  vpTranslationVector operator/(double x) const;
153  vpTranslationVector &operator/=(double x);
154  // Copy operator. Allow operation such as A = v
157  vpTranslationVector &operator=(double x);
158 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
159  vpTranslationVector &operator=(const std::initializer_list<double> &list);
160 #endif
161 
163  inline double &operator[](unsigned int n) { return *(data + n); }
165  inline const double &operator[](unsigned int n) const { return *(data + n); }
166 
167  vpTranslationVector &operator<<(double val);
168  vpTranslationVector &operator,(double val);
169 
175  void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
176  {
177  (void)nrows;
178  (void)ncols;
179  (void)flagNullify;
180  throw(vpException(vpException::fatalError, "Cannot resize a translation vector"));
181  }
182 
183  void set(double tx, double ty, double tz);
184 
185  // Skew Symmetric matrix
186  vpMatrix skew() const;
187 
188  double sumSquare() const;
189 
190  vpRowVector t() const;
191 
192  static vpTranslationVector cross(const vpTranslationVector &a, const vpTranslationVector &b);
193  static vpTranslationVector mean(const std::vector<vpHomogeneousMatrix> &vec_M);
194  static vpTranslationVector mean(const std::vector<vpTranslationVector> &vec_t);
195  static vpMatrix skew(const vpTranslationVector &tv);
196  static void skew(const vpTranslationVector &tv, vpMatrix &M);
197 
198 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
203  VP_DEPRECATED double euclideanNorm() const;
204  //}
205 #endif
206 
207 protected:
208  unsigned int m_index; // index used for operator<< and operator, to fill a vector
209 private:
210  static const unsigned int constr_val_3;
211 };
212 END_VISP_NAMESPACE
213 #endif
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition: vpArray2D.h:145
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition: vpArray2D.h:614
vpArray2D< Type > t() const
Compute the transpose of the array.
Definition: vpArray2D.h:1166
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:526
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
error that can be emitted by ViSP classes.
Definition: vpException.h:60
@ fatalError
Fatal error.
Definition: vpException.h:72
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:203
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:124
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)