|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Chaikin corner-cutting subdivision for polygon smoothing. More...
#include <geom_algorithms.H>
Public Member Functions | |
| Array< Point > | operator() (const Array< Point > &polyline, size_t iterations, const Geom_Number &ratio=Geom_Number(1, 4)) const |
| Smooth an open polyline. | |
| Array< Point > | operator() (const DynList< Point > &polyline, size_t iterations, const Geom_Number &ratio=Geom_Number(1, 4)) const |
| Overload accepting DynList. | |
Static Public Member Functions | |
| static Polygon | smooth_polygon (const Polygon &poly, size_t iterations, const Geom_Number &ratio=Geom_Number(1, 4)) |
| Smooth a closed polygon. | |
Static Private Member Functions | |
| static Array< Point > | smooth_open_once (const Array< Point > &pts, const Geom_Number &r) |
| static Array< Point > | smooth_closed_once (const Array< Point > &pts, const Geom_Number &r) |
Chaikin corner-cutting subdivision for polygon smoothing.
Each iteration replaces every edge (P_i, P_{i+1}) with two new points at fractions ratio and 1 - ratio along the edge. After k iterations the result converges toward a quadratic B-spline curve.
Complexity: O(n * 2^k) where n = input size, k = iterations.
Definition at line 12805 of file geom_algorithms.H.
|
inline |
Smooth an open polyline.
First and last vertices are preserved.
| polyline | Ordered sequence of vertices. |
| iterations | Number of subdivision iterations (>= 1). |
| ratio | Cutting fraction in (0, 0.5). Default 1/4. |
Definition at line 12857 of file geom_algorithms.H.
References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), k, and smooth_open_once().
|
inline |
Overload accepting DynList.
Definition at line 12872 of file geom_algorithms.H.
References Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), and Aleph::HTList::Iterator::has_curr().
|
inlinestaticprivate |
Definition at line 12828 of file geom_algorithms.H.
References Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), and r.
Referenced by smooth_polygon().
|
inlinestaticprivate |
Definition at line 12808 of file geom_algorithms.H.
References Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), and r.
Referenced by operator()().
|
inlinestatic |
Smooth a closed polygon.
All vertices participate in corner cutting (cyclic).
| poly | The closed polygon. |
| iterations | Number of subdivision iterations (>= 1). |
| ratio | Cutting fraction in (0, 0.5). Default 1/4. |
Definition at line 12893 of file geom_algorithms.H.
References Aleph::Polygon::add_vertex(), ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), Aleph::GeomPolygonUtils::extract_vertices(), k, and smooth_closed_once().
Referenced by main(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Aleph::visualize_chaikin_smoothing().