codac 2.0.0
Loading...
Searching...
No Matches
codac2_Figure3D.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <string>
13#include <memory>
14#include <fstream>
17#include "codac2_Paving.h"
18#include "codac2_Vector.h"
19#include "codac2_Matrix.h"
21#include "codac2_Ellipsoid.h"
23
24namespace codac2
25{
26
34 {
35 public:
36
42 Figure3D(const std::string& name);
43
48
54 const std::string& name() const;
55
56
57 // Geometric shapes
58
69 void draw_triangle(const Vector &c, const Matrix &A,
70 const Vector &p1, const Vector &p2, const Vector &p3,
71 const StyleProperties& style = { Color::dark_gray(0.5) });
72
81 void draw_triangle(const Vector &p1, const Vector &p2, const Vector &p3,
82 const StyleProperties& style = { Color::dark_gray(0.5) });
83
93 void draw_polygon(const Vector &c, const Matrix &A, const std::vector<Vector> &l,
94 const StyleProperties& style = { Color::dark_gray(0.5) });
95
106 void draw_parallelogram(const Vector &c, const Matrix &A,
107 const Vector &p, const Vector &v1, const Vector &v2,
108 const StyleProperties& style = { Color::dark_gray(0.5) });
109
116 void draw_parallelepiped(const Parallelepiped& p, const StyleProperties& style = { Color::dark_gray(0.5) });
117
124 void draw_zonotope(const Zonotope& z, const StyleProperties& style = { Color::dark_gray(0.5) });
125
132 void draw_box(const IntervalVector& x, const StyleProperties& style = { Color::dark_gray(0.5) });
133
134
143 void draw_arrow(const Vector &c, const Matrix& A, const StyleProperties& style = { Color::dark_gray(0.5) });
144
150 void draw_axes(double size = 1.0);
151
164 void draw_surface(const Vector &c, const Matrix &A,
165 const Interval &Ip1, double dp1,
166 const Interval &Ip2, double dp2,
167 std::function<Vector(double,double)> f,
168 const StyleProperties& style = { Color::dark_gray(0.5) });
169
177 void draw_sphere(const Vector &c, const Matrix &A,
178 const StyleProperties& style = { Color::dark_gray(0.5) });
179
187 const StyleProperties& style = { Color::dark_gray(0.5) });
188
196 void draw_car(const Vector &c, const Matrix &A,
197 const StyleProperties& style = { Color::yellow(0.5) });
198
207 void draw_plane(const Vector &c, const Matrix &A, bool yaw_is_up=true,
208 const StyleProperties& style = { Color::dark_gray(0.8) });
209
210
211 // Pavings
212
219 void draw_paving(const PavingOut& p,
220 const StyleProperties& bound_style = { Color::yellow(0.5) });
221
229 void draw_paving(const PavingInOut& p,
230 const StyleProperties& bound_style = { Color::yellow(0.3), "paving_bound" },
231 const StyleProperties& in_style = { Color::green(0.5) , "paving_in" });
232
239 template<typename P>
240 inline void draw_subpaving(const Subpaving<P>& p, const StyleProperties& style = StyleProperties())
241 {
242 for(const auto& pi : p.boxes())
243 draw_box(pi, style);
244 }
245
246 private:
255 size_t move_write_v(const Vector &c, const Matrix &A, const Vector &p);
256
262 void set_color_internal(const Color &c);
263
271 void set_style_internal(const StyleProperties& style);
272
273 protected:
274
275 const std::string _name;
276 std::ofstream _file;
277 size_t vertex_count = 0;
278 bool lock_style=false;
279 };
280}
Ellipsoid representation.
Definition codac2_Ellipsoid.h:43
void draw_sphere(const Vector &c, const Matrix &A, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a sphere (ellipsoid)
void draw_box(const IntervalVector &x, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a box on the figure.
void draw_polygon(const Vector &c, const Matrix &A, const std::vector< Vector > &l, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a `‘star-shaped’' polygon as a sequence of adjacent triangles (l[0],l[k],l[k+1]) with k>=1.
void draw_triangle(const Vector &p1, const Vector &p2, const Vector &p3, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a triangle, shorter version.
void draw_triangle(const Vector &c, const Matrix &A, const Vector &p1, const Vector &p2, const Vector &p3, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a triangle.
void draw_surface(const Vector &c, const Matrix &A, const Interval &Ip1, double dp1, const Interval &Ip2, double dp2, std::function< Vector(double, double)> f, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a parametric surface.
const std::string & name() const
Getter for the name of the figure.
void draw_axes(double size=1.0)
Draws the (x,y,z) axes on the figure in red, green and blue.
void draw_ellipsoid(const Ellipsoid &e, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws an ellipsoid (from the Ellipsoid class)
~Figure3D()
Destructor for the Figure3D class.
void draw_paving(const PavingInOut &p, const StyleProperties &bound_style={ Color::yellow(0.3), "paving_bound" }, const StyleProperties &in_style={ Color::green(0.5), "paving_in" })
Draws a paving on the figure (Only the boundary and the inside is drawn).
void draw_plane(const Vector &c, const Matrix &A, bool yaw_is_up=true, const StyleProperties &style={ Color::dark_gray(0.8) })
Draws a (paper) plane.
Figure3D(const std::string &name)
Creates a new Figure3D object, with a given name.
void draw_zonotope(const Zonotope &z, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a zonotope z+sum_i [-1,1] A_i on the figure.
void draw_paving(const PavingOut &p, const StyleProperties &bound_style={ Color::yellow(0.5) })
Draws a paving on the figure (Only the boundary is drawn).
void draw_parallelepiped(const Parallelepiped &p, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a parallelepiped z+A*[-1,1]^3 on the figure.
void draw_car(const Vector &c, const Matrix &A, const StyleProperties &style={ Color::yellow(0.5) })
Draws a car, with blue windscreen.
void draw_subpaving(const Subpaving< P > &p, const StyleProperties &style=StyleProperties())
Draws a subpaving on the figure.
Definition codac2_Figure3D.h:240
void draw_arrow(const Vector &c, const Matrix &A, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws an arrow (box c + A * ([0,1],[-0.01,0.01],[-0.01,0.01]) and a tip at the end)
void draw_parallelogram(const Vector &c, const Matrix &A, const Vector &p, const Vector &v1, const Vector &v2, const StyleProperties &style={ Color::dark_gray(0.5) })
Draws a parallelogram c + A (p + [-1,1]*v1 + [-1,1]*v2)
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
Class representing a parallelepiped .
Definition codac2_Parallelepiped.h:30
Class representing a zonotope .
Definition codac2_Zonotope.h:29
Definition codac2_OctaSym.h:21
Eigen::Matrix< double,-1, 1 > Vector
Alias for a dynamically-sized column vector of doubles.
Definition codac2_Vector.h:24
Eigen::Matrix< Interval,-1, 1 > IntervalVector
Alias for a dynamic-size column vector of intervals.
Definition codac2_IntervalVector.h:25
Eigen::Matrix< double,-1,-1 > Matrix
Alias for a dynamic-size matrix of doubles.
Definition codac2_Matrix.h:26
Color structure, in RGBA or HSVA format.
Definition codac2_Color.h:44
Style properties structure, to specify the style of a shape.
Definition codac2_StyleProperties.h:26