122 Vertex(
const Point & point) : Point(point)
140 Point::operator=(vertex);
150 return static_cast<Vertex *
>(link);
158 return static_cast<const Vertex *
>(link);
170 <<
"There is an only vertex";
184 <<
"There is an only vertex";
253 if (point.get_x() <
leftmost.get_x())
259 if (point.get_y() <
lowest.get_y())
262 if (point.get_y() >
highest.get_y())
321 std::swap(
lowest, poly.lowest);
322 std::swap(
highest, poly.highest);
366 std::swap(
lowest, poly.lowest);
367 std::swap(
highest, poly.highest);
426 <<
"Polygon has not any vertex";
462 <<
"Polygon has less than two vertex";
470 if (this->is_in_last())
482 <<
"Segment iterator is in the last point and "
483 <<
"it is not closed";
501 if (&it.get_current_vertex() == &v)
513 <<
"Polygon has not any vertex";
524 <<
"Polygon has not any vertex";
559 <<
"polygon has less than two vertex";
572 <<
"polygon has less than two vertex";
613 <<
"Polygon is already closed";
619 if (point.is_colinear_with(
last_sg))
622 <<
"new vertex is inside of last polygon's segment";
651 <<
"new side intersects";
684 if (&it.get_current_vertex() == &v)
686 victim = &
const_cast<Vertex &
>(it.get_current_vertex());
691 <<
"Vertex does not belong to polygon";
713 <<
"Polygon is already closed";
723 for (it.next();
true; it.next_ne())
731 <<
"closing causes an intersection";
754 <<
"Polygon is not closed";
762 for ( ; it.
has_curr(); it.next_ne())
854 const double &
ang = 0)
858 <<
"Polygon sides is less than 3";
898 <<
"vertex " << std::to_string(i) <<
" is greater than "
968 <<
"Iterator has not current";
983 <<
"Iterator has not current";
994 <<
"Iterator has not current";
1033 <<
"Iterator has not current";
1047 <<
"Iterator has not current";
1058 <<
"Iterator has not current";
1089 for (
size_t i = 0; i < poly.
size(); ++i)
Exception handling system with formatted messages for Aleph-w.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
bool has_curr() const noexcept
Return true if the iterator has current item.
Doubly linked circular list node.
Dlink *& get_next() const noexcept
Return the link that is after this
Dlink * remove_next() noexcept
Remove the item that is after this
constexpr bool is_unitarian_or_empty() const noexcept
Return true if this (as header node) has zero or one element.
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
void append(Dlink *node) noexcept
Insert node before this.
void swap(Dlink *link) noexcept
Swap this with list whose header is link.
constexpr bool is_unitarian() const noexcept
Return true if this (as header node) has exactly one element.
Dlink *& get_prev() const noexcept
Return the link that is before this
Iterator over the edges (segments) of a polygon.
Segment_Iterator(const Polygon &__poly)
Construct segment iterator from a polygon.
Segment get_current_segment() const
Get the current segment (edge).
Polygon & poly
Reference to the polygon being iterated.
bool has_curr() const
Check if there is a current segment.
A general (irregular) 2D polygon defined by a sequence of vertices.
Polygon(const Polygon &poly)
Copy constructor.
Polygon(Polygon &&poly) noexcept
Move constructor.
bool __is_closed
True if the polygon has been closed.
Segment get_first_segment()
Get the first edge (segment) of the polygon.
Dlink vertex_list
Doubly-linked list of vertices.
void close()
Close the polygon.
Polygon & operator=(const Polygon &poly)
Copy assignment operator.
const Vertex & get_last_vertex() const
Get the last vertex of the polygon.
const Point & rightmost_point() const
Get the vertex with the maximum x-coordinate.
void copy_points(const Polygon &poly)
Copy all vertices from another polygon.
size_t num_vertex
Number of vertices in the polygon.
const bool & is_closed() const
Check if the polygon is closed.
Segment get_last_segment()
Get the last edge (segment) of the polygon.
void add_vertex(const Geom_Number &x, const Geom_Number &y)
Add a vertex using coordinates.
Point rightmost
Vertex with maximum x-coordinate.
void remove_vertex(const Vertex &v)
Remove a vertex from the polygon.
const Vertex & get_next_vertex(const Vertex &v) const
Get the vertex after the given vertex.
Point lowest
Vertex with minimum y-coordinate.
const size_t & size() const
Get the number of vertices.
Point highest
Vertex with maximum y-coordinate.
const Point & leftmost_point() const
Get the vertex with the minimum x-coordinate.
const Vertex & get_first_vertex() const
Get the first vertex of the polygon.
void add_vertex(const Point &point)
Add a vertex to the polygon.
Polygon()
Default constructor. Creates an empty, open polygon.
const Vertex & get_prev_vertex(const Vertex &v) const
Get the vertex before the given vertex.
~Polygon()
Destructor. Frees all vertices.
void copy_regular_polygon(const Regular_Polygon &poly)
Copy vertices from a regular polygon.
const Point & highest_point() const
Get the vertex with the maximum y-coordinate.
bool intersects_with(const Segment &sg)
Check if a segment intersects with any edge of the polygon.
Point leftmost
Vertex with minimum x-coordinate.
bool vertex_belong_polygon(const Vertex &v) const
Check if a vertex belongs to this polygon.
Polygon(const Regular_Polygon &poly)
Construct from a Regular_Polygon.
void delete_points()
Delete all vertices and reset the polygon state.
bool contains_to(const Point &p)
Check if a point is inside the polygon.
const Point & lowest_point() const
Get the vertex with the minimum y-coordinate.
void update_extreme_points(const Point &point)
Update extreme points after adding a new vertex.
Polygon(const Triangle &tr)
Construct a polygon from a Triangle.
Iterator over the edges (segments) of a regular polygon.
void next_ne() noexcept
Advance to next segment (no exception on overflow).
const Regular_Polygon & poly
Reference to the polygon.
const Segment get_current_segment() const
Get the current segment (edge).
Segment_Iterator(const Regular_Polygon &__poly)
Construct segment iterator from a regular polygon.
size_t curr
Current segment index.
void next()
Advance to next segment.
bool has_curr() const
Check if there is a current segment.
void prev()
Move to previous segment.
Iterator over the vertices of a regular polygon.
Vertex_Iterator(const Regular_Polygon &__poly)
Construct iterator from a regular polygon.
void prev()
Move to previous vertex.
bool has_curr() const
Check if there is a current vertex.
const Regular_Polygon & poly
Reference to the polygon.
void next_ne() noexcept
Advance to next vertex (no exception on overflow).
Vertex & get_current_vertex()
Get the current vertex.
void next()
Advance to next vertex.
Vertex vertex
Cache for compatibility with Polygon::Vertex_Iterator.
size_t curr
Current vertex index.
A regular polygon defined by center, side length, and vertex count.
const Point get_first_vertex() const
Get the first vertex (index 0).
const Point & get_center() const
Get the center point.
double beta
Central angle between adjacent vertices (2π/n)
double side_size
Length of each side.
Point highest_point() const
Get the highest point of the bounding circle.
Point leftmost_point() const
Get the leftmost point of the bounding circle.
Point rightmost_point() const
Get the rightmost point of the bounding circle.
double angle
Rotation angle in radians.
const Point get_last_vertex() const
Get the last vertex (index size()-1).
Point center
Center point of the polygon.
const size_t & size() const
Get the number of vertices.
Segment get_first_segment() const
Get the first segment (edge).
const double & get_side_size() const
Get the side length.
size_t num_vertex
Number of vertices (sides)
Point lowest_point() const
Get the lowest point of the bounding circle.
Regular_Polygon(const Point &c, const double &side_sz, const size_t &n, const double &ang=0)
Construct a regular polygon.
Segment get_last_segment() const
Get the last segment (closing edge).
const Point get_vertex(const size_t &i) const
Get the i-th vertex of the polygon.
Regular_Polygon()
Default constructor. Creates an invalid empty polygon.
bool is_closed() const
Check if the polygon is closed.
double r
Circumradius (distance from center to vertices)
const double & radius() const
Get the circumradius.
Fundamental segment defined by two points.
const Point & get_tgt_point() const
void rotate(const double &angle)
Rotate the segment by angle (radians) around the source point.
A vertex in a polygon's doubly-linked vertex list.
static Vertex * dlink_to_vertex(Dlink *link)
Convert a Dlink pointer to a Vertex pointer.
Vertex(const Vertex &vertex)
Copy constructor.
Vertex & operator=(const Vertex &vertex)
Copy assignment operator.
Vertex()
Default constructor. Creates a vertex at origin (0, 0).
const Vertex & next_vertex() const
Get the next vertex in the polygon.
const Vertex & prev_vertex() const
Get the previous vertex in the polygon.
Vertex(const Point &point)
Construct a vertex from a Point.
static const Vertex * dlink_to_vertex(const Dlink *link)
Convert a const Dlink pointer to a const Vertex pointer.
Doubly linked circular list implementation.
__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.
auto get_curr() const
Return the current tuple (bounds-checked).
DynList< T > maps(const C &c, Op op)
Classic map operation.
2D point and geometric utilities.
Iterator over the vertices of a polygon.
Vertex_Iterator(const Polygon &poly)
Construct iterator from a polygon.
Vertex & get_current_vertex()
Get the current vertex.
void test(unsigned long n, gsl_rng *r)