Aleph-w
3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tikz_visibility_calipers_example.cc
Go to the documentation of this file.
1
#include <fstream>
2
#include <iostream>
3
#include <string>
4
5
#include <
tikzgeom_scene.H
>
6
7
using namespace
Aleph
;
8
9
namespace
10
{
11
12
Polygon
make_convex_for_calipers
()
13
{
14
Polygon
p;
15
p.
add_vertex
(
Point
(-12, -6));
16
p.
add_vertex
(
Point
(12, -8));
17
p.
add_vertex
(
Point
(17, 3));
18
p.
add_vertex
(
Point
(6, 14));
19
p.
add_vertex
(
Point
(-10, 11));
20
p.
close
();
21
return
p;
22
}
23
24
Polygon
make_visibility_room
()
25
{
26
Polygon
p;
27
p.
add_vertex
(
Point
(0, 0));
28
p.
add_vertex
(
Point
(22, 0));
29
p.
add_vertex
(
Point
(22, 20));
30
p.
add_vertex
(
Point
(12, 20));
31
p.
add_vertex
(
Point
(12, 9));
32
p.
add_vertex
(
Point
(8, 9));
33
p.
add_vertex
(
Point
(8, 20));
34
p.
add_vertex
(
Point
(0, 20));
35
p.
close
();
36
return
p;
37
}
38
39
}
// namespace
40
41
int
main
(
int
argc
,
char
*
argv
[])
42
{
43
const
std::string
output_path
=
44
argc
> 1 ?
argv
[1] :
"tikz_visibility_calipers_example.tex"
;
45
46
std::ofstream
out
(
output_path
);
47
if
(
not
out
)
48
{
49
std::cerr <<
"Cannot open output file: "
<<
output_path
<<
'\n'
;
50
return
1;
51
}
52
53
Tikz_Scene
scene
(220, 120, 5, 5,
true
);
54
scene
.put_cartesian_axis();
55
scene
.set_point_radius_mm(0.7);
56
57
const
Polygon
convex
=
make_convex_for_calipers
();
58
const
auto
rc
=
scene
.visualize_rotating_calipers(
convex
);
59
60
const
Polygon
room
=
make_visibility_room
();
61
const
Point
query(3, 17);
62
const
Polygon
vis
=
scene
.visualize_visibility_polygon(
room
, query);
63
64
scene
.add(
Text
(
Point
(-15, 24),
65
"Rotating calipers: diameter^2="
+
66
std::to_string(
geom_number_to_double
(
rc
.diameter.distance_squared))),
67
make_tikz_draw_style
(
"black"
),
68
Tikz_Plane::Layer_Overlay
);
69
70
scene
.add(
Text
(
Point
(-15, 21),
71
"Visibility polygon vertices="
+ std::to_string(
vis
.size())),
72
make_tikz_draw_style
(
"black"
),
73
Tikz_Plane::Layer_Overlay
);
74
75
scene
.draw_standalone(
out
);
76
77
std::cout <<
"Generated "
<<
output_path
<<
'\n'
;
78
std::cout <<
"Compile with: pdflatex "
<<
output_path
<<
'\n'
;
79
return
0;
80
}
main
int main()
Definition
bench_gol_1024.cc:57
out
size_t size_t int32_t * out
Definition
ca-c-api.h:120
Aleph::Point
Represents a point with rectangular coordinates in a 2D plane.
Definition
point.H:221
Aleph::Polygon
A general (irregular) 2D polygon defined by a sequence of vertices.
Definition
polygon.H:247
Aleph::Polygon::add_vertex
void add_vertex(const Point &point)
Add a vertex to the polygon.
Definition
polygon.H:678
Aleph::Polygon::close
void close()
Close the polygon.
Definition
polygon.H:843
Aleph::Text
Represents a text string positioned at a 2D point.
Definition
point.H:2817
Aleph::Tikz_Plane::Layer_Overlay
static constexpr int Layer_Overlay
Definition
tikzgeom.H:205
Aleph::Tikz_Scene
High-level scene wrapper to compose objects and algorithm visualizations.
Definition
tikzgeom_scene.H:97
Aleph::blossom_maximum_cardinality_matching
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition
Blossom.H:466
Aleph
Main namespace for Aleph-w library functions.
Definition
ah-arena.H:89
Aleph::geom_number_to_double
double geom_number_to_double(const Geom_Number &n)
Converts a Geom_Number to its double precision representation.
Definition
point.H:120
Aleph::make_tikz_draw_style
Tikz_Style make_tikz_draw_style(const std::string &draw_color)
Create a basic draw style with a custom color.
Definition
tikzgeom.H:172
tikzgeom_scene.H
High-level scene management for TikZ geometry visualization.
Examples
tikz_visibility_calipers_example.cc
Generated by
1.9.8