codac 1.5.6
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"
22
23namespace codac2
24{
25
33 {
34 public:
35
41 Figure3D(const std::string& name);
42
47
53 const std::string& name() const;
54
55
56 // Geometric shapes
57
68 void draw_triangle(const Vector &c, const Matrix &A,
69 const Vector &p1, const Vector &p2,
70 const Vector &p3,
71 const StyleProperties& s = { Color::dark_gray(0.5) });
72
81 void draw_triangle(const Vector &p1, const Vector &p2,
82 const Vector &p3,
83 const StyleProperties& s = { Color::dark_gray(0.5) });
84
94 void draw_polygon(const Vector &c, const Matrix &A,
95 const std::vector<Vector> &l,
96 const StyleProperties& s = { Color::dark_gray(0.5) });
97
98
109 void draw_parallelogram(const Vector &c, const Matrix &A,
110 const Vector &p, const Vector &v1, const Vector &v2,
111 const StyleProperties& s = { Color::dark_gray(0.5) });
112
120 void draw_parallelepiped(const Vector& z, const Matrix& A, const StyleProperties& s = { Color::dark_gray(0.5) });
121
129 void draw_zonotope(const Vector& z, const std::vector<Vector>& A, const StyleProperties& s = { Color::dark_gray(0.5) });
130
137 void draw_box(const IntervalVector& x, const StyleProperties& s = { Color::dark_gray(0.5) });
138
139
148 void draw_arrow(const Vector &c, const Matrix& A, const StyleProperties& s = { Color::dark_gray(0.5) });
149
150
156 void draw_axes(double size = 1.0);
157
170 void draw_surface(const Vector &c, const Matrix &A,
171 const Interval &Ip1, double dp1,
172 const Interval &Ip2, double dp2,
173 std::function<Vector(double,double)> f,
174 const StyleProperties& s = { Color::dark_gray(0.5) });
175
183 void draw_sphere(const Vector &c, const Matrix &A,
184 const StyleProperties& s = { Color::dark_gray(0.5) });
185
193 const StyleProperties& s = { Color::dark_gray(0.5) });
194
202 void draw_car(const Vector &c, const Matrix &A,
203 const StyleProperties& s = { Color::yellow(0.5) });
204
213 void draw_plane(const Vector &c, const Matrix &A, bool yaw_is_up=true,
214 const StyleProperties& s = { Color::dark_gray(0.8) });
215
216
217 // Pavings
218
225 void draw_paving(const PavingOut& p,
226 const StyleProperties& bound_s = { Color::yellow(0.5) });
227
235 void draw_paving(const PavingInOut& p,
236 const StyleProperties& bound_s = { Color::yellow(0.3), "paving_bound" },
237 const StyleProperties& in_s = { Color::green(0.5) , "paving_in" });
238
245 template<typename P>
246 inline void draw_subpaving(const Subpaving<P>& p, const StyleProperties& s = StyleProperties())
247 {
248 for(const auto& pi : p.boxes())
249 draw_box(pi, s);
250 }
251
252 private:
261 size_t move_write_v(const Vector &c, const Matrix &A, const Vector &p);
262
268 void set_color_internal(const Color &c);
269
277 void set_style_internal(const StyleProperties& s);
278
279 protected:
280
281 const std::string _name;
282 std::ofstream _file;
283 size_t vertex_count = 0;
284 bool lock_style=false;
285 };
286}
Ellipsoid representation.
Definition codac2_Ellipsoid.h:43
void draw_zonotope(const Vector &z, const std::vector< Vector > &A, const StyleProperties &s={ 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_s={ Color::yellow(0.5) })
Draws a paving on the figure (Only the boundary is drawn).
void draw_box(const IntervalVector &x, const StyleProperties &s={ Color::dark_gray(0.5) })
Draws a box on the figure.
const std::string & name() const
Getter for the name of the figure.
void draw_ellipsoid(const Ellipsoid &e, const StyleProperties &s={ Color::dark_gray(0.5) })
Draws an ellipsoid (from the Ellipsoid class)
void draw_axes(double size=1.0)
Draws the (x,y,z) axes on the figure in red, green and blue.
void draw_triangle(const Vector &c, const Matrix &A, const Vector &p1, const Vector &p2, const Vector &p3, const StyleProperties &s={ Color::dark_gray(0.5) })
Draws a triangle.
~Figure3D()
Destructor for the Figure3D class.
void draw_subpaving(const Subpaving< P > &p, const StyleProperties &s=StyleProperties())
Draws a subpaving on the figure.
Definition codac2_Figure3D.h:246
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 &s={ Color::dark_gray(0.5) })
Draws a parametric surface.
void draw_plane(const Vector &c, const Matrix &A, bool yaw_is_up=true, const StyleProperties &s={ Color::dark_gray(0.8) })
Draws a (paper) plane.
void draw_car(const Vector &c, const Matrix &A, const StyleProperties &s={ Color::yellow(0.5) })
Draws a car, with blue windscreen.
void draw_triangle(const Vector &p1, const Vector &p2, const Vector &p3, const StyleProperties &s={ Color::dark_gray(0.5) })
Draws a triangle, shorter version.
Figure3D(const std::string &name)
Creates a new Figure3D object, with a given name.
void draw_polygon(const Vector &c, const Matrix &A, const std::vector< Vector > &l, const StyleProperties &s={ 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_parallelepiped(const Vector &z, const Matrix &A, const StyleProperties &s={ Color::dark_gray(0.5) })
Draws a parallelepiped z+A*[-1,1]^3 on the figure.
void draw_parallelogram(const Vector &c, const Matrix &A, const Vector &p, const Vector &v1, const Vector &v2, const StyleProperties &s={ Color::dark_gray(0.5) })
Draws a parallelogram c + A (p + [-1,1]*v1 + [-1,1]*v2)
void draw_arrow(const Vector &c, const Matrix &A, const StyleProperties &s={ 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_sphere(const Vector &c, const Matrix &A, const StyleProperties &s={ Color::dark_gray(0.5) })
Draws a sphere (ellipsoid)
void draw_paving(const PavingInOut &p, const StyleProperties &bound_s={ Color::yellow(0.3), "paving_bound" }, const StyleProperties &in_s={ Color::green(0.5), "paving_in" })
Draws a paving on the figure (Only the boundary and the inside is drawn).
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:62
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