2D drawing functions
Main author: Maël Godard
This page lists all the 2D drawing functions available in Codac. Note that the functions described here on a Figure2D object also work on the DefaultFigure.
For example :
# On a figure
fig.draw_box([[2.2,2.5],[2.2,2.5]])
# On the DefaultFigure
DefaultFigure.draw_box([[2.2,2.5],[2.2,2.5]])
// On a figure
fig.draw_box({{2.2,2.5},{2.2,2.5}});
// On the DefaultFigure
DefaultFigure::draw_box({{2.2,2.5},{2.2,2.5}});
In addition to the arguments described here for every function, an optionnal argument of type StyleProperties can be added to choose the edge and fill color (by default black edge no fill). This object can be deduced from one or two Color objects, see this page for more information.
fig.draw_box([[2.2,2.5],[2.2,2.5]],Color.red()) # Red edge
fig.draw_box([[2.2,2.5],[2.2,2.5]],[Color.red()]) # Red edge
fig.draw_box([[2.2,2.5],[2.2,2.5]],[Color.red(),Color.blue()]) # Red edge and blue fill
fig.draw_box({{2.2,2.5},{2.2,2.5}},Color.red()); // Red edge
fig.draw_box({{2.2,2.5},{2.2,2.5}},{Color.red()}); // Red edge
fig.draw_box({{2.2,2.5},{2.2,2.5}},{Color.red(),Color.blue()}); // Red edge and blue fill
A line style and a layer can be added to the StyleProperties object, see the dedicated page for more information.
Overview of the functions
Below are the detailled available drawing functions. The shapes that can be drawn are:
- Geometric shapes
Point
Box
Circle
Ring
Line
Arrow
Polyline
Polygone
Parallelepiped
Pie
Ellipse
Ellipsoid
- Trajectories
Sampled Trajectory
Analytic Trajectory
- Vehicles
Tank
AUV
Motor Boat
- Paving
PavingOut (Paving with contractors)
PavingInOut (Paving with separators)
Subpaving
Geometric shapes
-
virtual void codac2::Figure2D::draw_point(const Vector &c, const StyleProperties &s = StyleProperties())
Draws a point on the figure.
- Parameters:
c – Coordinates of the point
s – Style of the point (edge color and fill color)
-
virtual void codac2::Figure2D::draw_box(const IntervalVector &x, const StyleProperties &s = StyleProperties())
Draws a box on the figure.
- Parameters:
x – Box to draw
s – Style of the box (edge color and fill color)
-
virtual void codac2::Figure2D::draw_circle(const Vector &c, double r, const StyleProperties &s = StyleProperties())
Draws a circle on the figure.
- Parameters:
c – Center of the circle
r – Radius of the circle
s – Style of the circle (edge color and fill color)
-
virtual void codac2::Figure2D::draw_ring(const Vector &c, const Interval &r, const StyleProperties &s = StyleProperties())
Draws a ring on the figure.
- Parameters:
c – Center of the ring
r – Inner and outer radius of the ring
s – Style of the ring (edge color and fill color)
-
void codac2::Figure2D::draw_line(const Vector &p1, const Vector &p2, const StyleProperties &s = StyleProperties())
Draws a line on the figure.
- Parameters:
p1 – First point of the line
p2 – Second point of the line
s – Style of the line (edge color)
-
void codac2::Figure2D::draw_arrow(const Vector &p1, const Vector &p2, float tip_length, const StyleProperties &s = StyleProperties())
Draws an arrow on the figure.
- Parameters:
p1 – First point of the arrow
p2 – Second point of the arrow
tip_length – Length of the tip of the arrow
s – Style of the arrow (edge color and fill color)
-
void codac2::Figure2D::draw_polyline(const std::vector<Vector> &x, const StyleProperties &s = StyleProperties())
Draws a polyline on the figure.
- Parameters:
x – Vector of the points of the polyline
s – Style of the polyline (edge color)
-
virtual void codac2::Figure2D::draw_polyline(const std::vector<Vector> &x, float tip_length, const StyleProperties &s = StyleProperties())
Draws a polyline on the figure.
- Parameters:
x – Vector of the points of the polyline
tip_length – Length of the tip of the arrow
s – Style of the polyline (edge color and fill color)
-
virtual void codac2::Figure2D::draw_polygon(const std::vector<Vector> &x, const StyleProperties &s = StyleProperties())
Draws a polygone on the figure.
- Parameters:
x – Vector of the points of the polygone
s – Style of the polygone (edge color and fill color)
-
void codac2::Figure2D::draw_polygon(const Polygon &x, const StyleProperties &s = StyleProperties())
Draws a
Polygon
object on the figure.- Parameters:
x – the
Polygon
object to be displayeds – Style of the polygone (edge color and fill color)
-
void codac2::Figure2D::draw_parallelepiped(const Vector &z, const Matrix &A, const StyleProperties &s = StyleProperties())
Draws a parallelepiped z+A*[-1,1]^2 on the figure.
- Parameters:
z – Coordinates of the center of the parallelepiped
A – Matrix of the parallelepiped
s – Style of the parallelepiped (edge color and fill color)
-
virtual void codac2::Figure2D::draw_pie(const Vector &c, const Interval &r, const Interval &theta, const StyleProperties &s = StyleProperties())
Draws a pie on the figure.
- Parameters:
c – Center of the pie
r – Inner and outer radius of the pie
theta – Start and end angle of the pie (in radians)
s – Style of the pie (edge color and fill color)
-
virtual void codac2::Figure2D::draw_ellipse(const Vector &c, const Vector &ab, double theta, const StyleProperties &s = StyleProperties())
Draws an ellipse on the figure.
- Parameters:
c – Center of the ellipse
ab – Half-lengths of the ellipse
theta – Rotation angle of the ellipse (in radians)
s – Style of the ellipse (edge color and fill color)
-
void codac2::Figure2D::draw_ellipsoid(const Ellipsoid &e, const StyleProperties &s = StyleProperties())
Draws an ellipsoid on the figure.
- Parameters:
e – Ellipsoid to draw
s – Style of the ellipsoid (edge color and fill color)
Trajectories
-
void codac2::Figure2D::draw_trajectory(const SampledTraj<Vector> &x, const StyleProperties &s = StyleProperties())
Draws a trajectory on the figure.
- Parameters:
x – SampledTraj to draw
s – Style of the trajectory (edge color)
-
void codac2::Figure2D::draw_trajectory(const AnalyticTraj<VectorType> &x, const StyleProperties &s = StyleProperties())
Draws a trajectory on the figure.
- Parameters:
x – AnalyticTraj to draw
s – Style of the trajectory (edge color)
Trajectories can be drawn with a ColorMap instead of the classic StyleProperties. This can be done by passing a ColorMap object as the second argument.
-
void codac2::Figure2D::draw_trajectory(const SampledTraj<Vector> &x, const ColorMap &cmap)
Draws a trajectory on the figure with a colormap.
- Parameters:
x – SampledTraj to plot
cmap – Colormap to use
-
void codac2::Figure2D::draw_trajectory(const AnalyticTraj<VectorType> &x, const ColorMap &cmap)
Draws a trajectory on the figure with a colormap.
- Parameters:
x – AnalyticTraj to plot
cmap – Colormap to use
Vehicles
-
virtual void codac2::Figure2D::draw_tank(const Vector &x, float size, const StyleProperties &s = StyleProperties())
Draws a tank on the figure.
- Parameters:
x – Coordinates of the tank
size – Size of the tank
s – Style of the tank (edge color and fill color)
-
virtual void codac2::Figure2D::draw_AUV(const Vector &x, float size, const StyleProperties &s = StyleProperties())
Draws an AUV on the figure.
- Parameters:
x – Coordinates of the AUV
size – Size of the AUV
s – Style of the AUV (edge color and fill color)
-
virtual void codac2::Figure2D::draw_motor_boat(const Vector &x, float size, const StyleProperties &s = StyleProperties())
Draws a motor boat on the figure.
- Parameters:
x – Coordinates of the motor boat
size – Size of the motor boat
s – Style of the motor boat (edge color and fill color)
Paving
-
void codac2::Figure2D::draw_paving(const PavingOut &p, const StyleProperties &bound_s = StyleProperties::boundary(), const StyleProperties &out_s = StyleProperties::outside())
Draws a paving on the figure.
- Parameters:
p – PavingOut to draw (result of a paving with contractors)
bound_s – Style of the boundary of the paving
out_s – Style of the outside of the paving
-
void codac2::Figure2D::draw_paving(const PavingInOut &p, const StyleProperties &bound_s = StyleProperties::boundary(), const StyleProperties &out_s = StyleProperties::outside(), const StyleProperties &in_s = StyleProperties::inside())
Draws a paving on the figure.
- Parameters:
p – PavingInOut to draw (result of a paving with separators)
bound_s – Style of the boundary of the paving
out_s – Style of the outside of the paving
in_s – Style of the inside of the paving