37 m_point_color = m_color;
38 m_field_color = m_color;
44 float ymin,
float ymax)
45 : m_LineWidth(1.0), m_pointSize(1.0), m_antiAliasing(true)
62 #if MRPT_HAS_OPENGL_GLUT 90 for (
unsigned int i = 0; i <
xcomp.cols(); i++)
91 for (
unsigned int j = 0; j <
xcomp.rows(); j++)
101 for (
unsigned int i = 0; i <
xcomp.cols(); i++)
102 for (
unsigned int j = 0; j <
xcomp.rows(); j++)
107 yMin + j * y_cell_size +
ycomp(j, i), 0);
114 for (
unsigned int i = 0; i <
xcomp.cols(); i++)
115 for (
unsigned int j = 0; j <
xcomp.rows(); j++)
117 const float tri_side =
120 const float ang = ::atan2(
ycomp(j, i),
xcomp(j, i)) - 1.5708;
122 -sin(ang) * 0.866 * tri_side +
xMin + i * x_cell_size +
124 cos(ang) * 0.866 * tri_side +
yMin + j * y_cell_size +
128 cos(ang) * 0.5 * tri_side +
xMin + i * x_cell_size +
130 sin(ang) * 0.5 * tri_side +
yMin + j * y_cell_size +
134 -cos(ang) * 0.5 * tri_side +
xMin + i * x_cell_size +
136 -sin(ang) * 0.5 * tri_side +
yMin + j * y_cell_size +
204 const float x_cell_size = (
xMax -
xMin) / (
xcomp.cols() - 1);
205 const float y_cell_size = (
yMax -
yMin) / (
ycomp.rows() - 1);
207 for (
unsigned int i = 0; i <
xcomp.cols(); i++)
208 for (
unsigned int j = 0; j <
xcomp.rows(); j++)
210 const float tri_side =
213 const float ang = ::atan2(
ycomp(j, i),
xcomp(j, i)) - 1.5708;
215 if (-sin(ang) * 0.866 * tri_side +
xMin + i * x_cell_size +
218 bb_min.
x = -sin(ang) * 0.866 * tri_side +
xMin +
219 i * x_cell_size +
xcomp(j, i);
221 if (cos(ang) * 0.866 * tri_side +
yMin + j * y_cell_size +
224 bb_min.
y = cos(ang) * 0.866 * tri_side +
yMin +
225 j * y_cell_size +
ycomp(j, i);
227 if (-sin(ang) * 0.866 * tri_side +
xMin + i * x_cell_size +
230 bb_max.
x = -sin(ang) * 0.866 * tri_side +
xMin +
231 i * x_cell_size +
xcomp(j, i);
233 if (cos(ang) * 0.866 * tri_side +
yMin + j * y_cell_size +
236 bb_max.
y = cos(ang) * 0.866 * tri_side +
yMin +
237 j * y_cell_size +
ycomp(j, i);
249 const float ratio_xp =
251 const float ratio_xn =
253 const float ratio_yp =
255 const float ratio_yn =
257 const float norm_factor =
258 0.85 / max(max(ratio_xp, abs(ratio_xn)), max(ratio_yp, abs(ratio_yn)));
260 xcomp *= norm_factor;
261 ycomp *= norm_factor;
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
mrpt::math::CMatrix ycomp
Y component of the vector field.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
mrpt::img::TColor m_point_color
#define GL_ONE_MINUS_SRC_ALPHA
mrpt::math::CMatrix xcomp
X component of the vector field.
GLAPI void GLAPIENTRY glPopAttrib(void)
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
A renderizable object suitable for rendering with OpenGL's display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define ASSERT_(f)
Defines an assertion mechanism.
#define GL_COLOR_BUFFER_BIT
This base provides a set of functions for maths stuff.
void writeToStreamRender(mrpt::serialization::CArchive &out) const
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
A 2D vector field representation, consisting of points and arrows drawn on a plane (invisible grid)...
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
CVectorField2D()
Constructor.
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...
mrpt::img::TColor m_color
Color components in the range [0,255].
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
bool m_antiAliasing
By default is true.
Virtual base class for "archives": classes abstracting I/O streams.
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
The namespace for 3D scene representation and rendering.
void adjustVectorFieldToGrid()
Adjust the vector field in the scene (vectors magnitude) according to the grid size.
GLAPI void GLAPIENTRY glEnd(void)
A matrix of dynamic size.
float m_pointSize
By default is 1.0.
void render_dl() const override
Render.
mrpt::img::TColor m_field_color
GLAPI void GLAPIENTRY glDisable(GLenum cap)
void readFromStreamRender(mrpt::serialization::CArchive &in)
float m_LineWidth
By default is 1.0.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.