| 1 |
/* +------------------------------------------------------------------------+ |
| 2 |
| Mobile Robot Programming Toolkit (MRPT) | |
| 3 |
| https://www.mrpt.org/ | |
| 4 |
| | |
| 5 |
| Copyright (c) 2005-2026, 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 |
// |
| 12 |
#include <mrpt/opengl/CEllipsoidRangeBearing2D.h> |
| 13 |
#include <mrpt/serialization/CArchive.h> |
| 14 |
|
| 15 |
using namespace mrpt; |
| 16 |
using namespace mrpt::opengl; |
| 17 |
using namespace mrpt::math; |
| 18 |
using namespace std; |
| 19 |
|
| 20 |
IMPLEMENTS_SERIALIZABLE(CEllipsoidRangeBearing2D, CRenderizableShaderWireFrame, mrpt::opengl) |
| 21 |
|
| 22 |
/*--------------------------------------------------------------- |
| 23 |
transformFromParameterSpace |
| 24 |
---------------------------------------------------------------*/ |
| 25 |
void CEllipsoidRangeBearing2D::transformFromParameterSpace( |
| 26 |
const std::vector<BASE::array_parameter_t>& in_pts, |
| 27 |
std::vector<BASE::array_point_t>& out_pts) const |
| 28 |
{ |
| 29 |
MRPT_START |
| 30 |
|
| 31 |
// (range,bearing) --> (x,y) |
| 32 |
const size_t N = in_pts.size(); |
| 33 |
out_pts.resize(N); |
| 34 |
for (size_t i = 0; i < N; i++) |
| 35 |
{ |
| 36 |
const float range = in_pts[i][0]; |
| 37 |
const float bearing = in_pts[i][1]; |
| 38 |
out_pts[i][0] = range * cosf(bearing); |
| 39 |
out_pts[i][1] = range * sinf(bearing); |
| 40 |
} |
| 41 |
|
| 42 |
MRPT_END |
| 43 |
} |
| 44 |
|
| 45 |
uint8_t CEllipsoidRangeBearing2D::serializeGetVersion() const { return 0; } |
| 46 |
void CEllipsoidRangeBearing2D::serializeTo(mrpt::serialization::CArchive& out) const |
| 47 |
{ |
| 48 |
writeToStreamRender(out); |
| 49 |
BASE::thisclass_writeToStream(out); |
| 50 |
} |
| 51 |
|
| 52 |
void CEllipsoidRangeBearing2D::serializeFrom(mrpt::serialization::CArchive& in, uint8_t version) |
| 53 |
{ |
| 54 |
switch (version) |
| 55 |
{ |
| 56 |
case 0: |
| 57 |
{ |
| 58 |
readFromStreamRender(in); |
| 59 |
BASE::thisclass_readFromStream(in); |
| 60 |
} |
| 61 |
break; |
| 62 |
default: |
| 63 |
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version); |
| 64 |
}; |
| 65 |
CRenderizable::notifyChange(); |
| 66 |
} |