Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpTranslationVector.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2023 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
34#ifndef vpTRANSLATIONVECTOR_H
35#define vpTRANSLATIONVECTOR_H
36
42#include <visp3/core/vpArray2D.h>
43#include <visp3/core/vpHomogeneousMatrix.h>
44#include <visp3/core/vpMatrix.h>
45#include <visp3/core/vpPoseVector.h>
46
113class VISP_EXPORT vpTranslationVector : public vpArray2D<double>
114{
115public:
120 vpTranslationVector() : vpArray2D<double>(3, 1), m_index(0) { };
121 vpTranslationVector(double tx, double ty, double tz);
123 explicit vpTranslationVector(const vpHomogeneousMatrix &M);
124 explicit vpTranslationVector(const vpPoseVector &p);
125 explicit vpTranslationVector(const vpColVector &v);
126
127 vpTranslationVector buildFrom(double tx, double ty, double tz);
128 vpTranslationVector buildFrom(const vpHomogeneousMatrix &M);
129 vpTranslationVector buildFrom(const vpPoseVector &p);
130 vpTranslationVector buildFrom(const vpColVector &v);
131
132 double frobeniusNorm() const;
133
134 // operators
135
136 // translation vectors additions c = a + b (a, b unchanged)
137 vpTranslationVector operator+(const vpTranslationVector &tv) const;
138 vpTranslationVector operator+(const vpColVector &v) const;
139 // translation vectors subtraction c = a - b (a, b unchanged)
140 vpTranslationVector operator-(const vpTranslationVector &tv) const;
141 // negate t = -a (t is unchanged)
142 vpTranslationVector operator-() const;
143 vpMatrix operator*(const vpRowVector &v) const;
144 // b = x * a (x=scalar)
145 vpTranslationVector operator*(double x) const;
146 vpTranslationVector &operator*=(double x);
147 vpTranslationVector operator/(double x) const;
148 vpTranslationVector &operator/=(double x);
149 // Copy operator. Allow operation such as A = v
153#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
154 vpTranslationVector &operator=(const std::initializer_list<double> &list);
155#endif
156
158 inline double &operator[](unsigned int n) { return *(data + n); }
160 inline const double &operator[](unsigned int n) const { return *(data + n); }
161
162 vpTranslationVector &operator<<(double val);
163 vpTranslationVector &operator,(double val);
164
170 void resize(unsigned int nrows, unsigned int ncols, bool flagNullify = true)
171 {
172 (void)nrows;
173 (void)ncols;
174 (void)flagNullify;
175 throw(vpException(vpException::fatalError, "Cannot resize a translation vector"));
176 };
177
178 void set(double tx, double ty, double tz);
179
180 // Skew Symmetric matrix
181 vpMatrix skew() const;
182
183 double sumSquare() const;
184
185 vpRowVector t() const;
186
187 static vpTranslationVector cross(const vpTranslationVector &a, const vpTranslationVector &b);
188 static vpTranslationVector mean(const std::vector<vpHomogeneousMatrix> &vec_M);
189 static vpTranslationVector mean(const std::vector<vpTranslationVector> &vec_t);
190 static vpMatrix skew(const vpTranslationVector &tv);
191 static void skew(const vpTranslationVector &tv, vpMatrix &M);
192
193#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
198 vp_deprecated double euclideanNorm() const;
199 //}
200#endif
201
202protected:
203 unsigned int m_index; // index used for operator<< and operator, to fill a vector
204};
205
206#endif
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition vpArray2D.h:131
vpArray2D< Type > & operator=(Type x)
Set all the elements of the array to x.
Definition vpArray2D.h:445
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
Definition vpArray2D.h:529
vpArray2D< Type > t() const
Compute the transpose of the array.
Definition vpArray2D.h:1059
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
Definition vpException.h:59
@ fatalError
Fatal error.
Definition vpException.h:84
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:152
Implementation of a pose vector and operations on poses.
Implementation of row vector and the associated operations.
Class that consider the case of a translation vector.
const double & operator[](unsigned int n) const
Operator that allows to get the value of an element : x = t[i].
double & operator[](unsigned int n)
Operator that allows to set a value of an element : t[i] = x.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true)
vpColVector operator*(const double &x, const vpColVector &v)