Visual Servoing Platform  version 3.1.0
vpTranslationVector.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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 
91 class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
92 {
93 public:
98  vpTranslationVector() : vpArray2D<double>(3, 1){};
99  vpTranslationVector(const double tx, const double ty, const double tz);
101  explicit vpTranslationVector(const vpHomogeneousMatrix &M);
102  explicit vpTranslationVector(const vpPoseVector &p);
103  explicit vpTranslationVector(const vpColVector &v);
104 
105  vpTranslationVector buildFrom(const double tx, const double ty, const double tz);
106  vpTranslationVector buildFrom(const vpHomogeneousMatrix &M);
107  vpTranslationVector buildFrom(const vpPoseVector &p);
108  vpTranslationVector buildFrom(const vpColVector &v);
109 
110  double euclideanNorm() const;
111 
112  // operators
113 
114  // translation vectors additions c = a + b (a, b unchanged)
115  vpTranslationVector operator+(const vpTranslationVector &tv) const;
116  vpTranslationVector operator+(const vpColVector &v) const;
117  // translation vectors substraction c = a - b (a, b unchanged)
118  vpTranslationVector operator-(const vpTranslationVector &tv) const;
119  // negate t = -a (t is unchanged)
120  vpTranslationVector operator-() const;
121  vpMatrix operator*(const vpRowVector &v) const;
122  // b = x * a (x=scalar)
123  vpTranslationVector operator*(const double x) const;
124  vpTranslationVector &operator*=(double x);
125  vpTranslationVector operator/(const double x) const;
126  vpTranslationVector &operator/=(double x);
127  // Copy operator. Allow operation such as A = v
130 
131  vpTranslationVector &operator=(double x);
132 
134  inline double &operator[](unsigned int n) { return *(data + n); }
136  inline const double &operator[](unsigned int n) const { return *(data + n); }
137 
143  void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify = true)
144  {
145  (void)nrows;
146  (void)ncols;
147  (void)flagNullify;
148  throw(vpException(vpException::fatalError, "Cannot resize a translation vector"));
149  };
150 
151  void set(const double tx, const double ty, const double tz);
152 
153  // Skew Symmetric matrix
154  vpMatrix skew() const;
155 
156  double sumSquare() const;
157 
158  vpRowVector t() const;
159 
160  static vpTranslationVector cross(const vpTranslationVector &a, const vpTranslationVector &b);
161  static vpMatrix skew(const vpTranslationVector &tv);
162  static void skew(const vpTranslationVector &tv, vpMatrix &M);
163 };
164 
165 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:244
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:72
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 vase class of matrices and vectors.
Definition: vpArray2D.h:70
vpColVector operator*(const double &x, const vpColVector &v)
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:92
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.