Visual Servoing Platform  version 3.0.0
vpTranslationVector.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Authors:
34  * Eric Marchand
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
39 
40 
41 #ifndef vpTRANSLATIONVECTOR_H
42 #define vpTRANSLATIONVECTOR_H
43 
49 #include <visp3/core/vpArray2D.h>
50 #include <visp3/core/vpMatrix.h>
51 #include <visp3/core/vpHomogeneousMatrix.h>
52 #include <visp3/core/vpPoseVector.h>
53 
54 
93 class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
94 {
95 public:
96 
101  vpTranslationVector() : vpArray2D<double>(3, 1) {};
102  vpTranslationVector(const double tx, const double ty, const double tz) ;
106 
107  vpTranslationVector buildFrom(const double tx, const double ty, const double tz) ;
108  vpTranslationVector buildFrom(const vpHomogeneousMatrix& M) ;
109  vpTranslationVector buildFrom(const vpPoseVector& p) ;
110 
111  double euclideanNorm() const;
112 
113  // operators
114 
115  // translation vectors additions c = a + b (a, b unchanged)
116  vpTranslationVector operator+(const vpTranslationVector &tv) 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
129 
130  vpTranslationVector &operator=(double x) ;
131 
133  inline double &operator [](unsigned int n) { return *(data + n); }
135  inline const double &operator [](unsigned int n) const { return *(data+n); }
136 
142  void resize(const unsigned int nrows, const unsigned int ncols,
143  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,
161  const vpTranslationVector &b) ;
162  static vpMatrix skew(const vpTranslationVector &tv) ;
163  static void skew(const vpTranslationVector &tv, vpMatrix &M) ;
164 } ;
165 
166 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:92
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition: vpArray2D.h:239
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of row vector and the associated operations.
Definition: vpRowVector.h:70
error that can be emited by ViSP classes.
Definition: vpException.h:73
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)
Type * operator[](unsigned int i)
Set element using A[i][j] = x.
Definition: vpArray2D.h:259
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:93
Class that consider the case of a translation vector.