Class CVectorField2D

Inheritance Relationships

Base Types

Class Documentation

class CVectorField2D : public virtual mrpt::viz::CVisualObject, public mrpt::viz::VisualObjectParams_Lines, public mrpt::viz::VisualObjectParams_Points, public mrpt::viz::VisualObjectParams_Triangles

A 2D vector field representation, consisting of points and arrows drawn on a plane (invisible grid).

../../output_staging/generated/doxygen/xml/preview_CVectorField2D.png

See also

opengl::Scene

Public Functions

inline void clear()

Clear the matrices

inline void setPointColor(const float R, const float G, const float B, const float A = 1)

Set the point color in the range [0,1]

inline mrpt::img::TColorf getPointColor() const

Get the point color in the range [0,1]

inline void setVectorFieldColor(const float R, const float G, const float B, const float A = 1)

Set the arrow color in the range [0,1]

inline mrpt::img::TColorf getVectorFieldColor() const

Get the arrow color in the range [0,1]

inline void setGridCenterAndCellSize(const float center_x, const float center_y, const float cellsize_x, const float cellsize_y)

Set the coordinates of the grid on where the vector field will be drawn by setting its center and the cell size. The number of cells is marked by the content of xcomp and ycomp.

See also

xcomp, ycomp

inline void setGridLimits(const float xmin, const float xmax, const float ymin, const float ymax)

Set the coordinates of the grid on where the vector field will be drawn using x-y max and min values.

inline void getGridLimits(float &xmin, float &xmax, float &ymin, float &ymax) const

Get the coordinates of the grid on where the vector field is drawn using the max and min values.

inline void getVectorField(mrpt::math::CMatrixFloat &Matrix_x, mrpt::math::CMatrixFloat &Matrix_y) const

Get the vector field. Matrix_x stores the “x” component and Matrix_y stores the “y” component.

inline const mrpt::math::CMatrixFloat &getVectorField_x() const

Get the “x” component of the vector field, as a matrix where each entry represents a point in the 2D grid.

inline mrpt::math::CMatrixFloat &getVectorField_x()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

inline const mrpt::math::CMatrixFloat &getVectorField_y() const

Get the “y” component of the vector field, as a matrix where each entry represents a point in the 2D grid.

inline mrpt::math::CMatrixFloat &getVectorField_y()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

inline void setVectorField(mrpt::math::CMatrixFloat &Matrix_x, mrpt::math::CMatrixFloat &Matrix_y)

Set the vector field. Matrix_x contains the “x” component and Matrix_y contains the “y” component.

void adjustVectorFieldToGrid()

Adjust the vector field in the scene (vectors magnitude) according to the grid size.

inline void resize(size_t rows, size_t cols)

Resizes the set.

inline size_t cols() const

Returns the total count of rows used to represent the vector field.

inline size_t rows() const

Returns the total count of columns used to represent the vector field.

virtual void updateBuffers() const override

Called by the rendering system to update internal geometry buffers.

Derived classes should override this to populate their data buffers (triangles, points, lines) when the object geometry changes.

This is called automatically when hasToUpdateBuffers() returns true, which happens after notifyChange() was called.

The base implementation does nothing; derived classes should override.

Note

Thread safety: implementations should lock the appropriate mutexes when writing to shared buffers.

virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const override

Must be implemented by derived classes to provide the updated bounding box in the object local frame of coordinates. This will be called only once after each time the derived class reports to notifyChange() that the object geometry changed.

See also

getBoundingBox(), getBoundingBoxLocal(), getBoundingBoxLocalf()

CVectorField2D()

Constructor

CVectorField2D(mrpt::math::CMatrixFloat Matrix_x, mrpt::math::CMatrixFloat Matrix_y, float xmin = -1, float xmax = 1, float ymin = -1, float ymax = 1)

Constructor with a initial set of lines.

~CVectorField2D() override = default

Private, virtual destructor: only can be deleted from smart pointers.

Protected Attributes

mrpt::math::CMatrixF xcomp

X component of the vector field

mrpt::math::CMatrixF ycomp

Y component of the vector field

float xMin = {-1.0f}

Grid bounds

float xMax = {1.0f}
float yMin = {-1.0f}
float yMax = {1.0f}
mrpt::img::TColor m_point_color
mrpt::img::TColor m_field_color