42 #include <visp3/core/vpTranslationVector.h>
45 const unsigned int vpTranslationVector::constr_val_3 = 3;
55 const unsigned int index_0 = 0;
56 const unsigned int index_1 = 1;
57 const unsigned int index_2 = 2;
58 (*this)[index_0] = tx;
59 (*this)[index_1] = ty;
60 (*this)[index_2] = tz;
84 const unsigned int index_0 = 0;
85 const unsigned int index_1 = 1;
86 const unsigned int index_2 = 2;
87 (*this)[index_0] = p[index_0];
88 (*this)[index_1] = p[index_1];
89 (*this)[index_2] = p[index_2];
120 const unsigned int val_3 = 3;
121 if (v.
size() != val_3) {
123 "Cannot construct a translation vector from a "
124 "%d-dimension column vector",
157 const unsigned int index_0 = 0;
158 const unsigned int index_1 = 1;
159 const unsigned int index_2 = 2;
160 (*this)[index_0] = p[index_0];
161 (*this)[index_1] = p[index_1];
162 (*this)[index_2] = p[index_2];
177 const unsigned int index_0 = 0;
178 const unsigned int index_1 = 1;
179 const unsigned int index_2 = 2;
180 const unsigned int v_size = 3;
181 if (v.
size() != v_size) {
183 "Cannot build a translation vector from a %d-dimension column vector", v.
size()));
186 (*this)[index_0] = v[index_0];
187 (*this)[index_1] = v[index_1];
188 (*this)[index_2] = v[index_2];
214 const unsigned int index_0 = 0;
215 const unsigned int index_1 = 1;
216 const unsigned int index_2 = 2;
217 (*this)[index_0] = tx;
218 (*this)[index_1] = ty;
219 (*this)[index_2] = tz;
244 const unsigned int val_3 = 3;
245 for (
unsigned int i = 0; i < val_3; ++i) {
246 s[i] = (*this)[i] + tv[i];
274 const unsigned int val_3 = 3;
275 if (v.
size() != val_3) {
281 for (
unsigned int i = 0; i < val_3; ++i) {
282 s[i] = (*this)[i] + v[i];
310 const unsigned int val_3 = 3;
311 for (
unsigned int i = 0; i < val_3; ++i) {
312 sub[i] = (*this)[i] - tv[i];
335 for (
unsigned int i = 0; i <
dsize; ++i) {
361 for (
unsigned int i = 0; i <
dsize; ++i) {
380 unsigned int v_col = v.
getCols();
381 for (
unsigned int i = 0; i <
rowNum; ++i) {
382 for (
unsigned int j = 0; j < v_col; ++j) {
383 M[i][j] = (*this)[i] * v[j];
399 for (
unsigned int i = 0; i <
rowNum; ++i) {
414 for (
unsigned int i = 0; i <
rowNum; ++i) {
439 for (
unsigned int i = 0; i <
dsize; ++i) {
464 const unsigned int val_3 = 3;
465 if (tv.
size() != val_3) {
467 "Cannot initialize a translation vector from a "
468 "%d-dimension col vector",
471 unsigned int k = tv.
size();
500 unsigned int k = tv.
rowNum;
531 for (
int i = 0; i < val_3; ++i) {
538 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
562 if (list.size() >
size()) {
565 "Cannot set translation vector out of bounds. It has only %d values while you try to initialize with %d values",
566 size(), list.size()));
568 std::copy(list.begin(), list.end(),
data);
640 "Cannot set translation vector out of bounds. It has only %d values while you try to initialize with %d values",
666 const unsigned int index_0 = 0;
667 const unsigned int index_1 = 1;
668 const unsigned int index_2 = 2;
669 const unsigned int val_3 = 3;
671 M[index_0][index_0] = 0;
672 M[index_0][index_1] = -tv[index_2];
673 M[index_0][index_2] = tv[index_1];
674 M[index_1][index_0] = tv[index_2];
675 M[index_1][index_1] = 0;
676 M[index_1][index_2] = -tv[index_0];
677 M[index_2][index_0] = -tv[index_1];
678 M[index_2][index_1] = tv[index_0];
679 M[index_2][index_2] = 0;
757 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
769 double vpTranslationVector::euclideanNorm()
const {
return frobeniusNorm(); }
793 double sum_square = 0.0;
795 for (
unsigned int i = 0; i <
rowNum; ++i) {
814 size_t vec_m_size = vec_M.size();
815 for (
size_t i = 0; i < vec_m_size; ++i) {
816 meanT +=
static_cast<vpColVector>(vec_M[i].getTranslationVector());
818 meanT /=
static_cast<double>(vec_M.size());
835 size_t l_vec_t_size = vec_t.size();
836 for (
size_t i = 0; i < l_vec_t_size; ++i) {
839 meanT /=
static_cast<double>(vec_t.size());
Implementation of a generic 2D array used as base class for matrices and vectors.
unsigned int getCols() const
Type * data
Address of the first element of the data array.
double ** rowPtrs
Address of the first element of each rows.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int rowNum
Number of rows in the array.
unsigned int dsize
Current array size (rowNum * colNum)
unsigned int size() const
Return the number of elements of the 2D array.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
Implementation of an homogeneous matrix and operations on such kind of matrices.
void extract(vpRotationMatrix &R) const
Implementation of a matrix and operations on matrices.
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.
void set(double tx, double ty, double tz)
vpTranslationVector & operator=(const vpColVector &tv)
static vpTranslationVector mean(const std::vector< vpHomogeneousMatrix > &vec_M)
vpTranslationVector & buildFrom(const double &tx, const double &ty, const double &tz)
vpTranslationVector operator/(double x) const
vpTranslationVector & operator/=(double x)
vpTranslationVector & operator*=(double x)
vpMatrix operator*(const vpRowVector &v) const
double frobeniusNorm() const
vpTranslationVector operator-() const
vpTranslationVector operator+(const vpTranslationVector &tv) const
vpTranslationVector & operator<<(double val)
vpTranslationVector & operator,(double val)
static vpTranslationVector cross(const vpTranslationVector &a, const vpTranslationVector &b)
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true)