44#include <visp3/core/vpException.h>
45#include <visp3/core/vpMath.h>
46#include <visp3/core/vpMatrixException.h>
47#include <visp3/core/vpPoseVector.h>
51const unsigned int vpPoseVector::constr_value_6 = 6;
82 const unsigned int index_0 = 0;
83 const unsigned int index_1 = 1;
84 const unsigned int index_2 = 2;
85 const unsigned int index_3 = 3;
86 const unsigned int index_4 = 4;
87 const unsigned int index_5 = 5;
88 (*this)[index_0] = tx;
89 (*this)[index_1] = ty;
90 (*this)[index_2] = tz;
92 (*this)[index_3] = tux;
93 (*this)[index_4] = tuy;
94 (*this)[index_5] = tuz;
160 const unsigned int index_0 = 0;
161 const unsigned int index_1 = 1;
162 const unsigned int index_2 = 2;
163 const unsigned int index_3 = 3;
164 const unsigned int index_4 = 4;
165 const unsigned int index_5 = 5;
166 (*this)[index_0] = tx;
167 (*this)[index_1] = ty;
168 (*this)[index_2] = tz;
170 (*this)[index_3] = tux;
171 (*this)[index_4] = tuy;
172 (*this)[index_5] = tuz;
195 const unsigned int index_0 = 0;
196 const unsigned int index_1 = 1;
197 const unsigned int index_2 = 2;
198 const unsigned int index_3 = 3;
199 const unsigned int index_4 = 4;
200 const unsigned int index_5 = 5;
201 (*this)[index_0] = tx;
202 (*this)[index_1] = ty;
203 (*this)[index_2] = tz;
205 (*this)[index_3] = tux;
206 (*this)[index_4] = tuy;
207 (*this)[index_5] = tuz;
245 const unsigned int val_3 = 3;
246 const unsigned int index_3 = 3;
247 for (
unsigned int i = 0; i < val_3; ++i) {
249 (*this)[i + index_3] = tu[i];
281 const unsigned int index_0 = 0;
282 const unsigned int index_1 = 1;
283 const unsigned int index_2 = 2;
284 tv[index_0] = (*this)[index_0];
285 tv[index_1] = (*this)[index_1];
286 tv[index_2] = (*this)[index_2];
294 const unsigned int index_0 = 0;
295 const unsigned int index_1 = 1;
296 const unsigned int index_2 = 2;
297 const unsigned int index_3 = 3;
298 const unsigned int index_4 = 4;
299 const unsigned int index_5 = 5;
300 tu[index_0] = (*this)[index_3];
301 tu[index_1] = (*this)[index_4];
302 tu[index_2] = (*this)[index_5];
317 const unsigned int index_3 = 3;
318 const unsigned int index_4 = 4;
319 const unsigned int index_5 = 5;
320 R.buildFrom((*
this)[index_3], (*
this)[index_4], (*
this)[index_5]);
328 const unsigned int index_0 = 0;
329 const unsigned int index_1 = 1;
330 const unsigned int index_2 = 2;
378 const unsigned int nparam = 6;
379 const unsigned int nparam_t = 3;
380 for (
unsigned int i = 0; i < nparam; ++i) {
382 std::cout << (*this)[i] <<
" ";
388 std::cout << std::endl;
425 const unsigned int nparam = 6;
426 for (
unsigned int i = 0; i < nparam; ++i) {
442 memcpy(v.data,
data,
rowNum *
sizeof(
double));
467 typedef std::string::size_type size_type;
472 std::vector<std::string> values(m * n);
473 std::ostringstream oss;
474 std::ostringstream ossFixed;
475 std::ios_base::fmtflags original_flags = oss.flags();
478 ossFixed.setf(std::ios::fixed, std::ios::floatfield);
480 size_type maxBefore = 0;
481 size_type maxAfter = 0;
483 for (
unsigned int i = 0; i < m; ++i) {
486 if (oss.str().find(
"e") != std::string::npos) {
488 ossFixed << (*this)[i];
489 oss.str(ossFixed.str());
492 values[i] = oss.str();
493 size_type thislen = values[i].size();
494 size_type p = values[i].find(
'.');
496 if (p == std::string::npos) {
506 size_type totalLength = length;
510 maxAfter = std::min<size_type>(maxAfter, totalLength - maxBefore);
521 s <<
"[" << m <<
"," << n <<
"]=\n";
523 for (
unsigned int i = 0; i < m; ++i) {
525 size_type p = values[i].find(
'.');
526 s.setf(std::ios::right, std::ios::adjustfield);
527 s.width(
static_cast<std::streamsize
>(maxBefore));
528 s << values[i].substr(0, p).c_str();
531 s.setf(std::ios::left, std::ios::adjustfield);
532 if (p != std::string::npos) {
533 s.width(
static_cast<std::streamsize
>(maxAfter));
534 s << values[i].substr(p, maxAfter).c_str();
537 assert(maxAfter > 1);
538 s.width(
static_cast<std::streamsize
>(maxAfter));
548 s.flags(original_flags);
550 return static_cast<int>(maxBefore + maxAfter);
559 std::vector<double> v(this->
size());
561 unsigned int this_size = this->
size();
562 for (
unsigned int i = 0; i < this_size; ++i) {
568#ifdef VISP_HAVE_NLOHMANN_JSON
569#include <visp3/core/vpJsonParsing.h>
571void vpPoseVector::convert_to_json(nlohmann::json &j)
const
577void vpPoseVector::parse_json(
const nlohmann::json &j)
579#ifdef ENABLE_VISP_NAMESPACE
580 using namespace VISP_NAMESPACE_NAME;
583 if (
j.is_object() &&
j.contains(
"type")) {
584 const bool converted = convertFromTypeAndBuildFrom<vpPoseVector, vpHomogeneousMatrix>(j, *
this);
594 throw vpException(
vpException::badValue,
"From JSON, tried to read something that is not a 6D pose vector");
Implementation of a generic 2D array used as base class for matrices and vectors.
unsigned int getCols() const
unsigned int size() const
unsigned int getRows() const
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
Implementation of an homogeneous matrix and operations on such kind of matrices.
void extract(vpRotationMatrix &R) const
static Type maximum(const Type &a, const Type &b)
static double deg(double rad)
vpTranslationVector getTranslationVector() const
std::vector< double > toStdVector() const
void load(std::ifstream &f)
void save(std::ofstream &f) const
friend void from_json(const nlohmann::json &j, vpPoseVector &cam)
static const std::string jsonTypeName
friend void to_json(nlohmann::json &j, const vpPoseVector &cam)
void extract(vpRotationMatrix &R) const
void set(double tx, double ty, double tz, double tux, double tuy, double tuz)
vpThetaUVector getThetaUVector() const
vpPoseVector & buildFrom(const double &tx, const double &ty, const double &tz, const double &tux, const double &tuy, const double &tuz)
vpRotationMatrix getRotationMatrix() const
Implementation of a rotation vector as quaternion angle minimal representation.
vpQuaternionVector & buildFrom(const double &qx, const double &qy, const double &qz, const double &qw)
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of row vector and the associated operations.
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.