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 |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
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 }
mrpt::math::TPose3DQuat::norm
double norm() const
Pose's spatial coordinates (x,y,z) norm.
Definition: TPose3DQuat.cpp:30
mrpt::math::TPose3DQuat::x
double x
Translation in x,y,z.
Definition: TPose3DQuat.h:27
mrpt::math::MatrixVectorBase::fromMatlabStringFormat
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...
Definition: MatrixVectorBase_impl.h:24
math-precomp.h
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
mrpt::math::TPose3DQuat::y
double y
Definition: TPose3DQuat.h:27
TPose3DQuat.h
mrpt::square
return_t square(const num_t x)
Inline function for the square of a number.
Definition: core/include/mrpt/core/bits_math.h:23
mrpt::math::TPose3DQuat::z
double z
Definition: TPose3DQuat.h:27
ASSERTMSG_
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:108
bits_math.h
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:11
mrpt::math::CMatrixDynamic::cols
size_type cols() const
Number of columns in the matrix.
Definition: CMatrixDynamic.h:340
mrpt::math::TPose3DQuat::fromString
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
Definition: TPose3DQuat.cpp:20
mrpt::math::CMatrixDynamic< double >
mrpt::math::CMatrixDynamic::rows
size_type rows() const
Number of rows in the matrix.
Definition: CMatrixDynamic.h:337



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sat Jun 27 14:00:59 UTC 2020