|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
An ellipse with arbitrary rotation. More...
#include <point.H>
Classes | |
| struct | ExtremalPoints |
| Holds the four axis-extremal points of a rotated ellipse. More... | |
Public Member Functions | |
| RotatedEllipse (Point center, const Geom_Number &a, const Geom_Number &b, const Geom_Number &cos_theta, const Geom_Number &sin_theta) | |
| Constructs a rotated ellipse. | |
| RotatedEllipse (Point center, const Geom_Number &a, const Geom_Number &b) | |
| Constructs an axis-aligned ellipse (rotation angle is 0). | |
| RotatedEllipse () | |
| Default constructor. | |
| RotatedEllipse (const RotatedEllipse &)=default | |
| RotatedEllipse & | operator= (const RotatedEllipse &)=default |
| bool | operator== (const RotatedEllipse &e) const noexcept |
| Checks for exact equality between two rotated ellipses. | |
| bool | operator!= (const RotatedEllipse &e) const noexcept |
| Checks for inequality between two rotated ellipses. | |
| const Point & | get_center () const |
| Gets the center point. | |
| const Geom_Number & | get_a () const |
| Gets the semi-axis 'a' (local x-axis radius). | |
| const Geom_Number & | get_b () const |
| Gets the semi-axis 'b' (local y-axis radius). | |
| const Geom_Number & | get_cos () const |
| Gets the cosine of the rotation angle. | |
| const Geom_Number & | get_sin () const |
| Gets the sine of the rotation angle. | |
| Geom_Number | area () const |
| Calculates the area of the ellipse. | |
| Geom_Number | radius_value (const Point &p) const |
| Evaluates the ellipse equation for a given point. | |
| bool | contains (const Point &p) const |
| Checks if a point lies inside or on the ellipse. | |
| bool | strictly_contains (const Point &p) const |
| Checks if a point lies strictly inside the ellipse. | |
| bool | on_boundary (const Point &p) const |
| Checks if a point lies exactly on the ellipse boundary. | |
| Point | sample (const Geom_Number &cos_t, const Geom_Number &sin_t) const |
| Samples a point on the ellipse boundary from a parametric angle. | |
| Point | sample (const Geom_Number &t) const |
Samples a point on the ellipse boundary for a parameter t. | |
| bool | intersects_with (const Segment &s) const |
| Checks if a segment intersects this rotated ellipse. | |
| Segment | intersection_with (const Segment &s) const |
Computes the intersection segment between s and this ellipse. | |
| std::string | to_string () const |
| ExtremalPoints | extremal_points () const |
| Computes the four axis-extremal points of the rotated ellipse. | |
Public Member Functions inherited from Aleph::Geom_Object | |
| Geom_Object ()=default | |
| virtual | ~Geom_Object ()=default |
Private Member Functions | |
| Point | to_local (const Point &p) const |
| Transforms a world point to the ellipse's local, unrotated frame. | |
| Point | to_world (const Point &p) const |
| Transforms a point from the ellipse's local frame back to world coordinates. | |
| void | validate_positive_radii () const |
| Validates that semi-axes are positive. | |
| void | normalize_rotation () |
| Normalizes the rotation (cos, sin) vector to ensure it's a unit vector. | |
Private Attributes | |
| Point | center_ |
| Geom_Number | a_ |
| Geom_Number | b_ |
| Geom_Number | cos_th_ |
| Geom_Number | sin_th_ |
An ellipse with arbitrary rotation.
Extends the axis-aligned Ellipse by adding a rotation angle. The implicit equation in the rotated frame is:
`((x' - cx)² / a²) + ((y' - cy)² / b²) = 1`
where ‘(x’, y')are coordinates rotated by-θ` around the center.
Since exact trigonometry is often not possible with rational numbers, the rotation is specified by its cosine and sine as exact Geom_Number values. The user is responsible for providing these values.
|
inline |
Constructs a rotated ellipse.
| center | The center point. |
| a | The semi-axis length along the ellipse's local x-axis. |
| b | The semi-axis length along the ellipse's local y-axis. |
| cos_theta | The cosine of the rotation angle. |
| sin_theta | The sine of the rotation angle. |
Definition at line 2473 of file point.H.
References normalize_rotation(), and validate_positive_radii().
|
inline |
Constructs an axis-aligned ellipse (rotation angle is 0).
| center | The center point. |
| a | The semi-axis length (horizontal radius). |
| b | The semi-axis length (vertical radius). |
Definition at line 2490 of file point.H.
References validate_positive_radii().
|
inline |
|
default |
|
inline |
Calculates the area of the ellipse.
Definition at line 2547 of file point.H.
References a_, b_, Aleph::geom_pi(), and validate_positive_radii().
|
inline |
Computes the four axis-extremal points of the rotated ellipse.
ExtremalPoints struct. Definition at line 2671 of file point.H.
References a_, b_, and to_world().
Referenced by TEST_F().
|
inline |
Gets the semi-axis 'a' (local x-axis radius).
Definition at line 2535 of file point.H.
References a_.
Referenced by Aleph::Tikz_Plane::draw_rotated_ellipse(), Aleph::Tikz_Plane::rotated_x_extent(), and Aleph::Tikz_Plane::rotated_y_extent().
|
inline |
Gets the semi-axis 'b' (local y-axis radius).
Definition at line 2537 of file point.H.
References b_.
Referenced by Aleph::Tikz_Plane::draw_rotated_ellipse(), Aleph::Tikz_Plane::rotated_x_extent(), and Aleph::Tikz_Plane::rotated_y_extent().
Gets the center point.
Definition at line 2533 of file point.H.
References center_.
Referenced by Aleph::Tikz_Plane::bbox_of(), and Aleph::Tikz_Plane::draw_rotated_ellipse().
|
inline |
Gets the cosine of the rotation angle.
Definition at line 2539 of file point.H.
References cos_th_.
Referenced by Aleph::Tikz_Plane::draw_rotated_ellipse(), Aleph::Tikz_Plane::rotated_x_extent(), Aleph::Tikz_Plane::rotated_y_extent(), and TEST_F().
|
inline |
Gets the sine of the rotation angle.
Definition at line 2541 of file point.H.
References sin_th_.
Referenced by Aleph::Tikz_Plane::draw_rotated_ellipse(), Aleph::Tikz_Plane::rotated_x_extent(), Aleph::Tikz_Plane::rotated_y_extent(), and TEST_F().
Computes the intersection segment between s and this ellipse.
| s | The segment to intersect with. |
Segment. Can be a point for tangency. | std::domain_error | if there is no intersection. |
Definition at line 2642 of file point.H.
References a_, b_, Aleph::divide_and_conquer_partition_dp(), Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), Aleph::Ellipse::intersection_with(), to_local(), to_world(), and validate_positive_radii().
Referenced by TEST_F().
Checks if a segment intersects this rotated ellipse.
| s | The segment to check. |
true if they share at least one point. Definition at line 2629 of file point.H.
References a_, b_, Aleph::divide_and_conquer_partition_dp(), Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), Aleph::Ellipse::intersects_with(), to_local(), and validate_positive_radii().
Referenced by TEST_F().
|
inlineprivate |
Normalizes the rotation (cos, sin) vector to ensure it's a unit vector.
| std::domain_error | if the rotation vector is (0,0). |
Definition at line 2452 of file point.H.
References ah_domain_error_if, cos_th_, sin_th_, and Aleph::square_root().
Referenced by RotatedEllipse().
|
inlinenoexcept |
Checks for inequality between two rotated ellipses.
| e | The other ellipse. |
true if any parameter is different. Definition at line 2527 of file point.H.
References Aleph::divide_and_conquer_partition_dp().
|
default |
|
inlinenoexcept |
|
inline |
Evaluates the ellipse equation for a given point.
| p | The point in world coordinates. |
< 1 for interior points, = 1 for boundary points, and > 1 for exterior points. Definition at line 2559 of file point.H.
References a_, b_, Aleph::divide_and_conquer_partition_dp(), to_local(), and validate_positive_radii().
Referenced by contains(), on_boundary(), and strictly_contains().
|
inline |
Samples a point on the ellipse boundary from a parametric angle.
| cos_t | The cosine of the parameter angle t. |
| sin_t | The sine of the parameter angle t. |
Point on the ellipse in world coordinates. Definition at line 2604 of file point.H.
References a_, b_, Aleph::divide_and_conquer_partition_dp(), to_world(), and validate_positive_radii().
|
inline |
Samples a point on the ellipse boundary for a parameter t.
| t | A parameter in [0, 1], which maps to an angle in [0, 2π). |
Point on the ellipse. Definition at line 2618 of file point.H.
References Aleph::cosinus(), Aleph::divide_and_conquer_partition_dp(), Aleph::geom_pi(), sample(), and Aleph::sinus().
Checks if a point lies strictly inside the ellipse.
| p | The point to check. |
true if the point is strictly inside. Definition at line 2583 of file point.H.
References radius_value().
Referenced by TEST_F().
Transforms a world point to the ellipse's local, unrotated frame.
| p | A point in world coordinates. |
Definition at line 2416 of file point.H.
References center_, cos_th_, Aleph::Point::get_x(), Aleph::Point::get_y(), and sin_th_.
Referenced by intersection_with(), intersects_with(), and radius_value().
|
inline |
Definition at line 2650 of file point.H.
References a_, b_, center_, cos_th_, Aleph::geom_number_to_double(), sin_th_, and Aleph::Point::to_string().
Referenced by Aleph::operator<<().
Transforms a point from the ellipse's local frame back to world coordinates.
| p | A point in the ellipse's local coordinate system. |
Definition at line 2431 of file point.H.
References center_, cos_th_, Aleph::Point::get_x(), Aleph::Point::get_y(), and sin_th_.
Referenced by extremal_points(), intersection_with(), and sample().
|
inlineprivate |
Validates that semi-axes are positive.
| std::domain_error | if either a_ or b_ is not > 0. |
Definition at line 2443 of file point.H.
References a_, ah_domain_error_if, b_, and Aleph::divide_and_conquer_partition_dp().
Referenced by RotatedEllipse(), RotatedEllipse(), area(), intersection_with(), intersects_with(), radius_value(), and sample().
|
private |
Definition at line 2406 of file point.H.
Referenced by area(), extremal_points(), get_a(), intersection_with(), intersects_with(), operator==(), radius_value(), sample(), to_string(), and validate_positive_radii().
|
private |
Definition at line 2407 of file point.H.
Referenced by area(), extremal_points(), get_b(), intersection_with(), intersects_with(), operator==(), radius_value(), sample(), to_string(), and validate_positive_radii().
|
private |
Definition at line 2405 of file point.H.
Referenced by get_center(), operator==(), to_local(), to_string(), and to_world().
|
private |
Definition at line 2408 of file point.H.
Referenced by get_cos(), normalize_rotation(), operator==(), to_local(), to_string(), and to_world().
|
private |
Definition at line 2409 of file point.H.
Referenced by get_sin(), normalize_rotation(), operator==(), to_local(), to_string(), and to_world().