Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testTranslationVector.cpp
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
* Test some vpColVector functionalities.
32
*/
33
39
40
#include <cmath>
41
#include <vector>
42
43
#include <visp3/core/vpTranslationVector.h>
44
45
#ifdef ENABLE_VISP_NAMESPACE
46
using namespace
VISP_NAMESPACE_NAME
;
47
#endif
48
49
bool
test(
const
std::string &s,
const
vpArray2D<double>
&A,
const
std::vector<double> &bench);
50
51
bool
test(
const
std::string &s,
const
vpArray2D<double>
&A,
const
std::vector<double> &bench)
52
{
53
static
unsigned
int
cpt = 0;
54
std::cout <<
"** Test "
<< ++cpt << std::endl;
55
std::cout <<
s
<<
"("
<< A.
getRows
() <<
","
<< A.
getCols
() <<
") ="
<< A << std::endl;
56
if
(bench.size() != A.
size
()) {
57
std::cout <<
"Test fails: bad size wrt bench"
<< std::endl;
58
return
false
;
59
}
60
for
(
unsigned
int
i = 0;
i
< A.
size
();
i
++) {
61
if
(std::fabs(A.
data
[i] - bench[i]) > std::fabs(A.
data
[i]) * std::numeric_limits<double>::epsilon()) {
62
std::cout <<
"Test fails: bad content"
<< std::endl;
63
return
false
;
64
}
65
}
66
67
return
true
;
68
}
69
70
int
main()
71
{
72
int
err = 1;
73
{
74
vpTranslationVector
t
;
75
std::vector<double> bench(3, 0);
76
if
(test(
"t"
, t, bench) ==
false
)
77
return
err;
78
}
79
{
80
vpTranslationVector
t1
(1, 2, 3);
81
std::vector<double> bench(3);
82
bench[0] = 1;
83
bench[1] = 2;
84
bench[2] = 3;
85
if
(test(
"t1"
, t1, bench) ==
false
)
86
return
err;
87
88
vpTranslationVector
t2(4, 5, 6);
89
bench[0] = 4;
90
bench[1] = 5;
91
bench[2] = 6;
92
if
(test(
"t2"
, t2, bench) ==
false
)
93
return
err;
94
95
vpTranslationVector
t3 =
t1
+ t2;
96
bench[0] = 5;
97
bench[1] = 7;
98
bench[2] = 9;
99
if
(test(
"t3"
, t3, bench) ==
false
)
100
return
err;
101
102
vpMatrix
skew = t3.
skew
();
103
std::vector<double> bench1(9, 0);
104
bench1[1] = -9;
105
bench1[2] = 7;
106
bench1[3] = 9;
107
bench1[5] = -5;
108
bench1[6] = -7;
109
bench1[7] = 5;
110
if
(test(
"skew"
, skew, bench1) ==
false
)
111
return
err;
112
113
vpTranslationVector
t4;
114
t4.
set
(-1, -2, -3);
115
bench[0] = -1;
116
bench[1] = -2;
117
bench[2] = -3;
118
if
(test(
"t4"
, t4, bench) ==
false
)
119
return
err;
120
121
vpTranslationVector
t5 = t4 * 2;
122
bench[0] = -2;
123
bench[1] = -4;
124
bench[2] = -6;
125
if
(test(
"t5"
, t5, bench) ==
false
)
126
return
err;
127
128
vpTranslationVector
t6 =
vpTranslationVector::cross
(t4, t5);
129
bench[0] = 0;
130
bench[1] = 0;
131
bench[2] = 0;
132
if
(test(
"t6"
, t6, bench) ==
false
)
133
return
err;
134
}
135
std::cout <<
"All tests succeed"
<< std::endl;
136
return
EXIT_SUCCESS;
137
}
vpArray2D
Implementation of a generic 2D array used as base class for matrices and vectors.
Definition
vpArray2D.h:146
vpArray2D::getCols
unsigned int getCols() const
Definition
vpArray2D.h:423
vpArray2D::data
Type * data
Address of the first element of the data array.
Definition
vpArray2D.h:149
vpArray2D::size
unsigned int size() const
Return the number of elements of the 2D array.
Definition
vpArray2D.h:435
vpArray2D::getRows
unsigned int getRows() const
Definition
vpArray2D.h:433
vpMatrix
Implementation of a matrix and operations on matrices.
Definition
vpMatrix.h:175
vpTranslationVector
Class that consider the case of a translation vector.
Definition
vpTranslationVector.h:119
vpTranslationVector::set
void set(double tx, double ty, double tz)
Definition
vpTranslationVector.cpp:217
vpTranslationVector::skew
vpMatrix skew() const
Definition
vpTranslationVector.cpp:730
vpTranslationVector::cross
static vpTranslationVector cross(const vpTranslationVector &a, const vpTranslationVector &b)
Definition
vpTranslationVector.cpp:747
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
pbvs-four-points.t
t
Definition
pbvs-four-points.py:220
realsense-rbt.t1
t1
Definition
realsense-rbt.py:214
yolo-centering-task-afma6.i
i
Definition
yolo-centering-task-afma6.py:329
yolo-centering-task-afma6.s
s
Definition
yolo-centering-task-afma6.py:260
modules
core
test
math
testTranslationVector.cpp
Generated by
1.17.0