MRPT  2.0.1
CEllipsoid2D.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 "opengl-precomp.h" // Precompiled header
11 
15 
16 using namespace mrpt;
17 using namespace mrpt::opengl;
18 using namespace mrpt::math;
19 using namespace std;
20 
23 
25  const std::vector<BASE::array_parameter_t>& in_pts,
26  std::vector<BASE::array_point_t>& out_pts) const
27 {
28  // Euclidean space:
29  out_pts = in_pts;
30 }
31 
32 uint8_t CEllipsoid2D::serializeGetVersion() const { return 0; }
34 {
35  writeToStreamRender(out);
36  out << m_cov << m_drawSolid3D << m_quantiles << (uint32_t)m_numSegments
37  << m_lineWidth;
38 }
39 
41  mrpt::serialization::CArchive& in, uint8_t version)
42 {
43  switch (version)
44  {
45  case 0:
46  {
47  readFromStreamRender(in);
48  in >> m_cov;
49  in >> m_drawSolid3D >> m_quantiles;
50  m_numSegments = in.ReadAs<uint32_t>();
51  in >> m_lineWidth;
52 
53  // Update cov. matrix cache:
54  setCovMatrix(m_cov);
55  }
56  break;
57  default:
59  };
61 }
62 
63 #if 0
64 static bool quickSolveEqn(double a, double b_2, double c, double& t)
65 {
66  double delta = square(b_2) - a * c;
67  if (delta == 0)
68  return (t = -b_2 / a) >= 0;
69  else if (delta > 0)
70  {
71  delta = sqrt(delta);
72  if ((t = (-b_2 - delta) / a) >= 0)
73  return true;
74  else
75  return (t = (-b_2 + delta) / a) >= 0;
76  }
77  else
78  return false;
79 }
80 #endif
81 
82 bool CEllipsoid2D::traceRay(const mrpt::poses::CPose3D& o, double& dist) const
83 {
84 #if 0 // Update, someday...
85  if (m_cov.rows() != 3) return false;
86  TLine3D lin, lin2;
87  createFromPoseX((o - this->m_pose).asTPose(), lin);
88  lin.unitarize(); // By adding this line, distance from any point of the
89  // line to its base is exactly equal to the "t".
90  for (size_t i = 0; i < 3; i++)
91  {
92  lin2.pBase[i] = 0;
93  lin2.director[i] = 0;
94  for (size_t j = 0; j < 3; j++)
95  {
96  double vji = m_eigVec(j, i);
97  lin2.pBase[i] += vji * lin.pBase[j];
98  lin2.director[i] += vji * lin.director[j];
99  }
100  }
101  double a = 0, b_2 = 0, c = -square(m_quantiles);
102  for (size_t i = 0; i < 3; i++)
103  {
104  double ev = m_eigVal(i, i);
105  a += square(lin2.director[i] / ev);
106  b_2 += lin2.director[i] * lin2.pBase[i] / square(ev);
107  c += square(lin2.pBase[i] / ev);
108  }
109  return quickSolveEqn(a, b_2, c, dist);
110 #endif
111  return false;
112 }
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
TPoint3D pBase
Base point.
Definition: TLine3D.h:23
STL namespace.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
This base provides a set of functions for maths stuff.
std::array< double, 3 > director
Director vector.
Definition: TLine3D.h:25
void transformFromParameterSpace(const std::vector< BASE::array_parameter_t > &in_pts, std::vector< BASE::array_point_t > &out_pts) const override
To be implemented by derived classes: maps, using some arbitrary space transformation, a list of points defining an ellipsoid in parameter space into their corresponding points in 2D/3D space.
STORED_TYPE ReadAs()
De-serialize a variable and returns it by value.
Definition: CArchive.h:155
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
return_t square(const num_t x)
Inline function for the square of a number.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A 2D ellipse on the XY plane, centered at the origin of this object pose.
Definition: CEllipsoid2D.h:39
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
void createFromPoseX(const mrpt::math::TPose3D &p, TLine3D &r)
Gets a 3D line corresponding to the X axis in a given pose.
Definition: geometry.cpp:917
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::vision::TStereoCalibResults out
void unitarize()
Unitarize director vector.
Definition: TLine3D.cpp:56
This file implements matrix/vector text and binary serialization.
Renderizable generic renderer for objects using the wireframe shader.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
IMPLEMENTS_SERIALIZABLE(CEllipsoid2D, CRenderizableShaderWireFrame, mrpt::opengl) void CEllipsoid2D
3D line, represented by a base point and a director vector.
Definition: TLine3D.h:19



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020