22 void
CDisk::onUpdateBuffers_Triangles()
32 const float dAng = 2 *
M_PIf / m_nSlices;
35 std::vector<mrpt::math::TPoint2Df> circle(m_nSlices);
36 for (
unsigned int i = 0; i < m_nSlices; i++, a += dAng)
42 const float r0 = m_radiusIn, r1 = m_radiusOut;
44 if (std::abs(r0) < 1e-6f)
47 for (
unsigned int i = 0; i < m_nSlices; i++)
49 const auto ip = (i + 1) % m_nSlices;
51 TPoint3Df(r1 * circle[i].x, r1 * circle[i].y, .0f),
52 TPoint3Df(r1 * circle[ip].x, r1 * circle[ip].y, .0f),
59 for (
unsigned int i = 0; i < m_nSlices; i++)
61 const auto ip = (i + 1) % m_nSlices;
63 TPoint3Df(r1 * circle[i].x, r1 * circle[i].y, .0f),
64 TPoint3Df(r1 * circle[ip].x, r1 * circle[ip].y, .0f),
65 TPoint3Df(r0 * circle[i].x, r0 * circle[i].y, .0f));
68 TPoint3Df(r1 * circle[ip].x, r1 * circle[ip].y, .0f),
69 TPoint3Df(r0 * circle[ip].x, r0 * circle[ip].y, .0f),
70 TPoint3Df(r0 * circle[i].x, r0 * circle[i].y, .0f));
75 for (
auto& t : tris) t.setColor(m_color);
81 writeToStreamRender(
out);
82 out << m_radiusIn << m_radiusOut;
93 readFromStreamRender(in);
94 in >> m_radiusIn >> m_radiusOut;
118 CPose3D transf = this->m_pose - o;
119 double x = transf.
x(), y = transf.
y(), z = transf.z(), w = transf.
yaw(),
121 double coef = sin(w) * sin(r) + cos(w) * sin(p) * cos(r);
127 if (coef == 0)
return false;
131 dist = x + (y * (sin(p) * sin(w) * cos(r) - cos(w) * sin(r)) +
132 z * cos(p) * cos(r)) /
134 if (dist < 0)
return false;
136 double d2 = (x - dist) * (x - dist) + y * y + z * z;
137 return d2 >= (m_radiusIn * m_radiusIn) && d2 <= (m_radiusOut * m_radiusOut);
146 bb_min.x = -std::max(m_radiusIn, m_radiusOut);
150 bb_max.x = std::max(m_radiusIn, m_radiusOut);
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
The base class of 3D objects that can be directly rendered through OpenGL.
double pitch() const
Get the PITCH angle (in radians)
double yaw() const
Get the YAW angle (in radians)
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
A planar disk in the XY plane.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
double x() const
Common members of all points & poses classes.
double roll() const
Get the ROLL angle (in radians)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::vision::TStereoCalibResults out
#define ASSERT_ABOVE_(__A, __B)
The namespace for 3D scene representation and rendering.
TPoint3D_< float > TPoint3Df
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.