|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
An axis-aligned ellipse. More...
#include <point.H>
Public Member Functions | |
| Ellipse (Point center, const Geom_Number &hr, const Geom_Number &vr) | |
| Constructs an ellipse. | |
| Ellipse (const Ellipse &e)=default | |
| Copy constructor. | |
| Ellipse () | |
| Default constructor. | |
| bool | operator== (const Ellipse &e) const noexcept |
| Checks for exact equality. | |
| bool | operator!= (const Ellipse &e) const noexcept |
| Checks for inequality. | |
| const Point & | get_center () const |
| Gets the center point of the ellipse. | |
| const Geom_Number & | get_hradius () const |
| Gets the horizontal radius. | |
| const Geom_Number & | get_vradius () const |
| Gets the vertical radius. | |
| Geom_Number | area () const |
| Calculates the area of the ellipse. | |
| Geom_Number | perimeter () const |
| Approximates the perimeter of the ellipse. | |
| Point | sample (const Geom_Number &angle) const |
| Samples a point on the ellipse's boundary at a given angle. | |
| std::string | to_string () const |
| Returns a string representation of the ellipse. | |
| Point | highest_point () const |
| Gets the highest point on the ellipse boundary. | |
| Point | lowest_point () const |
| Gets the lowest point on the ellipse boundary. | |
| Point | leftmost_point () const |
| Gets the leftmost point on the ellipse boundary. | |
| Point | rightmost_point () const |
| Gets the rightmost point on the ellipse boundary. | |
| void | compute_tangents (Segment &s1, Segment &s2, const Geom_Number &m) const |
| Computes the two tangent segments to this ellipse with a given slope. | |
| bool | intersects_with (const Segment &s) const |
| Checks if a segment intersects the ellipse. | |
| bool | contains (const Point &p) const |
| Checks if a point lies inside or on the boundary of this ellipse. | |
| bool | contains_to (const Point &p) const |
| bool | intersects_with (const Point &p) const |
| Checks if a point lies exactly on the ellipse boundary. | |
| Segment | intersection_with (const Segment &sg) const |
| Computes the intersection segment between a line segment and this ellipse. | |
Public Member Functions inherited from Aleph::Geom_Object | |
| Geom_Object ()=default | |
| virtual | ~Geom_Object ()=default |
Static Public Member Functions | |
| static bool | is_clockwise () |
| Returns the orientation of the ellipse. | |
Private Member Functions | |
| void | validate_positive_radii () const |
| Validates that radii are positive. | |
| Geom_Number | compute_radius (const Point &p) const |
| Computes the ellipse equation value for a point. | |
Static Private Member Functions | |
| static bool | in_unit_interval (const Geom_Number &t) |
Helper to check if a parameter t is in the [0, 1] interval. | |
Private Attributes | |
| Point | center_ |
| Geom_Number | hr_ |
| Geom_Number | vr_ |
Friends | |
| class | Point |
An axis-aligned ellipse.
Represents an axis-aligned ellipse centered at a point with a horizontal and a vertical radius. Provides methods for calculating geometric properties and handling intersections.
|
inline |
Constructs an ellipse.
| center | The center point of the ellipse. |
| hr | The horizontal radius. |
| vr | The vertical radius. |
| std::domain_error | if either radius is not positive. |
Definition at line 2102 of file point.H.
References validate_positive_radii().
|
inline |
|
inline |
Calculates the area of the ellipse.
Definition at line 2162 of file point.H.
References Aleph::geom_pi(), hr_, validate_positive_radii(), and vr_.
|
inlineprivate |
Computes the ellipse equation value for a point.
Calculates (x-xc)^2/hr^2 + (y-yc)^2/vr^2.
| p | The point to evaluate. |
Definition at line 2344 of file point.H.
References center_, Aleph::Point::get_x(), Aleph::Point::get_y(), hr_, validate_positive_radii(), and vr_.
Referenced by contains(), and intersects_with().
|
inline |
Computes the two tangent segments to this ellipse with a given slope.
| [out] | s1 | The first tangent segment. |
| [out] | s2 | The second tangent segment. |
| [in] | m | The slope of the tangents. |
Definition at line 2263 of file point.H.
References ah_domain_error_if, Aleph::blossom_maximum_cardinality_matching(), center_, hr_, m, Point, Aleph::square_root(), validate_positive_radii(), and vr_.
Checks if a point lies inside or on the boundary of this ellipse.
| p | The point to check. |
true if the point is contained within the ellipse. Definition at line 2363 of file point.H.
References compute_radius().
Referenced by contains_to(), Aleph::Point::is_inside(), TEST_F(), and TEST_F().
Gets the center point of the ellipse.
Definition at line 2143 of file point.H.
References center_.
Referenced by Aleph::Tikz_Plane::draw_ellipse(), and Eepic_Plane::draw_ellipse().
|
inline |
Gets the horizontal radius.
Definition at line 2148 of file point.H.
References hr_.
Referenced by Aleph::Tikz_Plane::draw_ellipse(), Eepic_Plane::draw_ellipse(), and TEST_F().
|
inline |
Gets the vertical radius.
Definition at line 2153 of file point.H.
References vr_.
Referenced by Aleph::Tikz_Plane::draw_ellipse(), Eepic_Plane::draw_ellipse(), and TEST_F().
|
inline |
Gets the highest point on the ellipse boundary.
Definition at line 2234 of file point.H.
References center_, Aleph::Point::get_x(), Aleph::Point::get_y(), and vr_.
Referenced by Aleph::Tikz_Plane::bbox_of().
|
inlinestaticprivate |
Helper to check if a parameter t is in the [0, 1] interval.
Definition at line 2218 of file point.H.
References Aleph::and.
Referenced by intersects_with().
Computes the intersection segment between a line segment and this ellipse.
| sg | The segment to intersect with. |
Segment representing the portion of sg inside the ellipse. If tangent, the segment is degenerate (a point). | std::domain_error | if there is no intersection. |
Definition at line 2391 of file point.H.
References ah_domain_error_if, Aleph::Segment::at(), Aleph::blossom_maximum_cardinality_matching(), center_, Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), Aleph::Point::get_x(), Aleph::Point::get_y(), hr_, root(), Aleph::square_root(), validate_positive_radii(), and vr_.
Referenced by Aleph::Segment::intersection_with(), Aleph::RotatedEllipse::intersection_with(), TEST_F(), TEST_F(), and TEST_F().
Checks if a point lies exactly on the ellipse boundary.
| p | The point to check. |
true if the point is on the boundary. Definition at line 2379 of file point.H.
References compute_radius().
Checks if a segment intersects the ellipse.
Treats the ellipse as a closed filled region and solves the quadratic equation for boundary crossings when necessary.
| s | The segment to check. |
true if the segment and ellipse share at least one point. Definition at line 2298 of file point.H.
References Aleph::blossom_maximum_cardinality_matching(), center_, Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), Aleph::Point::get_x(), Aleph::Point::get_y(), hr_, in_unit_interval(), root(), Aleph::square_root(), validate_positive_radii(), and vr_.
Referenced by Aleph::Point::intersects_with(), Aleph::Segment::intersects_with(), Aleph::RotatedEllipse::intersects_with(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inline |
Gets the leftmost point on the ellipse boundary.
Definition at line 2246 of file point.H.
References center_, Aleph::Point::get_x(), Aleph::Point::get_y(), and hr_.
Referenced by Aleph::Tikz_Plane::bbox_of().
|
inline |
Gets the lowest point on the ellipse boundary.
Definition at line 2240 of file point.H.
References center_, Aleph::Point::get_x(), Aleph::Point::get_y(), and vr_.
Referenced by Aleph::Tikz_Plane::bbox_of().
Checks for inequality.
| e | The other ellipse. |
true if center or radii are different. Definition at line 2137 of file point.H.
References Aleph::blossom_maximum_cardinality_matching().
|
inline |
Approximates the perimeter of the ellipse.
Uses Ramanujan's second approximation formula for the perimeter.
Definition at line 2173 of file point.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::geom_pi(), h, hr_, Aleph::square_root(), validate_positive_radii(), and vr_.
|
inline |
Gets the rightmost point on the ellipse boundary.
Definition at line 2252 of file point.H.
References center_, Aleph::Point::get_x(), Aleph::Point::get_y(), and hr_.
Referenced by Aleph::Tikz_Plane::bbox_of().
|
inline |
Samples a point on the ellipse's boundary at a given angle.
| angle | The parametric angle in radians. |
Point on the ellipse's boundary. Definition at line 2188 of file point.H.
References Aleph::blossom_maximum_cardinality_matching(), center_, Aleph::cosinus(), Aleph::Point::get_x(), Aleph::Point::get_y(), hr_, Aleph::sinus(), validate_positive_radii(), and vr_.
|
inline |
Returns a string representation of the ellipse.
std::string describing the ellipse's properties. Definition at line 2198 of file point.H.
References center_, Aleph::geom_number_to_double(), hr_, Aleph::Point::to_string(), and vr_.
Referenced by Aleph::operator<<().
|
inlineprivate |
Validates that radii are positive.
| std::domain_error | if either radius is not > 0. |
Definition at line 2210 of file point.H.
References ah_domain_error_if, Aleph::blossom_maximum_cardinality_matching(), hr_, and vr_.
Referenced by Ellipse(), area(), compute_radius(), compute_tangents(), intersection_with(), intersects_with(), perimeter(), and sample().
Definition at line 2077 of file point.H.
Referenced by compute_tangents().
|
private |
Definition at line 2089 of file point.H.
Referenced by compute_radius(), compute_tangents(), get_center(), highest_point(), intersection_with(), intersects_with(), leftmost_point(), lowest_point(), operator==(), rightmost_point(), sample(), and to_string().
|
private |
Definition at line 2091 of file point.H.
Referenced by area(), compute_radius(), compute_tangents(), get_hradius(), intersection_with(), intersects_with(), leftmost_point(), operator==(), perimeter(), rightmost_point(), sample(), to_string(), and validate_positive_radii().
|
private |
Definition at line 2092 of file point.H.
Referenced by area(), compute_radius(), compute_tangents(), get_vradius(), highest_point(), intersection_with(), intersects_with(), lowest_point(), operator==(), perimeter(), sample(), to_string(), and validate_positive_radii().