MRPT  2.0.4
TPose3DQuat.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9
10 #include "math-precomp.h" // Precompiled headers
11
12 #include <mrpt/core/bits_math.h> // square
13 #include <mrpt/math/TPose3DQuat.h>
14 #include <cmath>
15
16 using namespace mrpt::math;
17
18 static_assert(std::is_trivially_copyable_v<TPose3DQuat>);
19
20 void TPose3DQuat::fromString(const std::string& s)
21 {
22  CMatrixDouble m;
23  if (!m.fromMatlabStringFormat(s))
24  THROW_EXCEPTION("Malformed expression in ::fromString");
25  ASSERTMSG_(
26  m.rows() == 1 && m.cols() == 7, "Wrong size of vector in ::fromString");
27  for (int i = 0; i < m.cols(); i++) (*this)[i] = m(0, i);
28 }
29
30 double TPose3DQuat::norm() const
31 {
32  return std::sqrt(mrpt::square(x) + mrpt::square(y) + mrpt::square(z));
33 }
double norm() const
Pose&#39;s spatial coordinates (x,y,z) norm.
Definition: TPose3DQuat.cpp:30
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
void fromString(const std::string &s)
Set the current object value from a string generated by &#39;asString&#39; (eg: "[0.02 1.04 -0...
Definition: TPose3DQuat.cpp:20
This base provides a set of functions for maths stuff.
double x
Translation in x,y,z.
Definition: TPose3DQuat.h:27
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:108
bool fromMatlabStringFormat(const std::string &s, mrpt::optional_ref< std::ostream > dump_errors_here=std::nullopt)
Reads a matrix from a string in Matlab-like format, for example: "[1 0 2; 0 4 -1]" The string must st...
size_type rows() const
Number of rows in the matrix.
size_type cols() const
Number of columns in the matrix.
return_t square(const num_t x)
Inline function for the square of a number.

 Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 02a75dd25 Thu Jun 4 01:49:55 2020 +0200 at jue jun 4 02:00:12 CEST 2020