62 const double R = 5.0,
r = 2.0;
63 for (
int i = 0; i < 5; ++i)
77 cout <<
"=== L-shape ===" <<
endl;
78 cout <<
"Original: " <<
L.size() <<
" vertices, area = "
83 cout <<
"Outward d=1: " <<
L_out1.polygons(0).size() <<
" vertices, area = "
88 cout <<
"Outward d=2: " <<
L_out2.polygons(0).size() <<
" vertices, area = "
93 cout <<
"Inward d=-0.5: " <<
L_in.polygons(0).size() <<
" vertices, area = "
97 cout <<
"\n=== Star ===" <<
endl;
98 cout <<
"Original: " <<
star.size() <<
" vertices, area = "
102 if (!
S_out.is_empty())
105 for (
size_t i = 0; i <
S_out.size(); ++i)
107 cout <<
"Outward d=0.5: " <<
S_out.size() <<
" polygon(s), total area = "
112 cout <<
"\n=== Miter vs Bevel (L-shape, d=1) ===" <<
endl;
115 if (!
miter.is_empty())
116 cout <<
"Miter: " <<
miter.polygons(0).size() <<
" vertices, area = "
118 if (!
bevel.is_empty())
119 cout <<
"Bevel: " <<
bevel.polygons(0).size() <<
" vertices, area = "
123 const string filename =
"polygon_offset_output.tex";
124 ofstream
out(filename);
127 cerr <<
"Cannot open " << filename <<
endl;
131 out <<
"\\documentclass[border=5mm]{standalone}\n"
132 <<
"\\usepackage{tikz}\n"
133 <<
"\\begin{document}\n";
140 out <<
"% Original L-shape\n";
142 out <<
"\n\\hspace{1cm}\n";
152 out <<
"% Outward d=1\n";
154 out <<
"\n\\hspace{1cm}\n";
164 out <<
"% Outward d=2\n";
166 out <<
"\n\\hspace{1cm}\n";
170 if (!
L_in.is_empty())
176 out <<
"% Inward d=-0.5\n";
181 out <<
"\\end{document}\n";
183 cout <<
"\nTikZ output written to " << filename <<
endl;
static Geom_Number signed_double_area(const Array< Point > &verts)
Compute twice the signed area (shoelace formula without division).
Represents a point with rectangular coordinates in a 2D plane.
Offset (inflate/deflate) an arbitrary simple polygon.
A general (irregular) 2D polygon defined by a sequence of vertices.
void add_vertex(const Point &point)
Add a vertex to the polygon.
2D TikZ canvas storing geometry objects and emitting LaTeX output.
void draw(std::ostream &output, const bool squarize=true) const
Emit a complete tikzpicture with all inserted objects.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_cos_function > > cos(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_sin_function > > sin(const __gmp_expr< T, U > &expr)
Main namespace for Aleph-w library functions.
void put_in_plane(Tikz_Plane &plane, const Geom &geom_obj)
Insert any supported geometry type in a Tikz_Plane.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
void put_polygon_vertices(Tikz_Plane &plane, const Polygon &poly, const Tikz_Style &style=tikz_points_style(), const int layer=Tikz_Plane::Layer_Overlay)
Inserts the vertices of a polygon as styled points.
mpq_class Geom_Number
Numeric type used by the geometry module.
Tikz_Style tikz_wire_style(const std::string &color="black", const bool dashed=false, const bool with_arrow=false)
Creates a style optimized for wireframe segments and polygons.
Tikz_Style tikz_points_style(const std::string &color="black", const double opacity=-1.0)
Creates a style optimized for point clouds.
static Geom_Number poly_area(const Polygon &p)
Helpers to visualize computational-geometry algorithm results in TikZ.