|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Fundamental segment defined by two points. More...
#include <point.H>
Public Types | |
| enum | Sense { E , NE , N , NW , W , S , SW , SE } |
| Cardinal directions associated with a segment. More... | |
Public Member Functions | |
| bool | operator== (const Segment &s) const |
| bool | operator!= (const Segment &s) const |
| const Point & | highest_point () const |
| const Point & | lowest_point () const |
| const Point & | leftmost_point () const |
| const Point & | rightmost_point () const |
| const Point & | get_src_point () const |
| const Point & | get_tgt_point () const |
| Segment ()=default | |
| Segment (Point __src, const Point &__tgt) | |
| Segment (Point __src, const Geom_Number &m, const Geom_Number &l) | |
| Builds a new segment given source point, slope and length. | |
| Segment (const Segment &sg, const Geom_Number &dist) | |
| Builds a new segment parallel to sg and with a distance dist. | |
| double | slope () const |
| double | counterclockwise_angle_with (const Segment &s) const |
| Compute the counterclockwise wise angle respect another segment s. | |
| double | counterclockwise_angle () const |
| Compute the counterclockwise angle of this respect x-axis. | |
| Geom_Number | size () const |
| Return the Euclidean length of the segment (distance between endpoints). | |
| bool | is_colinear_with (const Point &p) const |
Return true if p is colinear with this segment. | |
| bool | is_to_left_from (const Point &p) const |
Return true if this segment is to the left of point p. | |
| bool | is_to_right_from (const Point &p) const |
Return true if this segment is to the right of point p. | |
| Point | mid_point () const |
| Return the midpoint of this segment. | |
| const Point & | nearest_point (const Point &p) const |
Return whichever endpoint is nearer to p. | |
| Segment | get_perpendicular (const Point &p) const |
Construct the segment perpendicular to this passing through p. | |
| Segment | mid_perpendicular (const Geom_Number &dist) const |
Return the perpendicular chord of length 2*dist through the midpoint. | |
| bool | intersects_properly_with (const Segment &s) const |
| Return true if the segments intersect at interior points only. | |
| bool | contains_to (const Point &p) const |
Return true if p lies on this segment. | |
| bool | contains_to (const Segment &s) const |
Return true if s lies entirely inside this segment. | |
| bool | intersects_with (const Segment &s) const |
Return true if s intersects this segment (including endpoints). | |
| bool | intersects_with (const Triangle &t) const |
| bool | intersects_with (const Ellipse &e) const |
| bool | is_parallel_with (const Segment &s) const |
Return true if s has the same slope. | |
| Point | intersection_with (const Segment &s) const |
| Compute intersection point solving point-slope equations for both lines. | |
| Sense | sense () const |
| void | enlarge_src (const Geom_Number &__dist) |
Extend the segment by __dist from the source endpoint. | |
| void | enlarge_tgt (const Geom_Number &__dist) |
Extend the segment by __dist from the target endpoint. | |
| std::string | to_string () const |
| Return "(src)(tgt)" textual form. | |
| operator std::string () const | |
| void | rotate (const double &angle) |
Rotate the segment by angle (radians) around the source point. | |
| Segment | intersection_with (const Triangle &t) const |
| Segment | intersection_with (const Ellipse &e) const |
Public Member Functions inherited from Geom_Object | |
| Geom_Object ()=default | |
| virtual | ~Geom_Object ()=default |
Private Member Functions | |
| double | compute_slope () const |
Static Private Member Functions | |
| static Point | compute_tgt_point (const Point &__src, const Geom_Number &m, const Geom_Number &d) |
| Computes the target point of a segment given the source point, slope and length. | |
Private Attributes | |
| Point | src |
| Point | tgt |
Friends | |
| class | Point |
| class | Triangle |
| enum Segment::Sense |
|
default |
Referenced by intersection_with(), and intersects_with().
|
inline |
Builds a new segment given source point, slope and length.
It computes the source point by usen these equations:
| [in] | __src | Source point |
| [in] | m | slope (rise over run, dimensionless) |
| [in] | l | length |
|
inline |
Builds a new segment parallel to sg and with a distance dist.
Definition at line 532 of file point.H.
References get_src_point(), get_tgt_point(), mid_perpendicular(), mid_point(), src, and tgt.
|
inlineprivate |
|
inlinestaticprivate |
Computes the target point of a segment given the source point, slope and length.
It uses the solution of these equations:
Definition at line 497 of file point.H.
References square_root(), Point::x, y, and Point::y.
Referenced by enlarge_src(), and enlarge_tgt().
|
inline |
Return true if p lies on this segment.
Definition at line 700 of file point.H.
References Point::is_between(), src, and tgt.
Referenced by intersects_with(), and Point::is_inside().
|
inline |
Return true if s lies entirely inside this segment.
Definition at line 706 of file point.H.
References get_src_point(), get_tgt_point(), Point::is_between(), src, and tgt.
|
inline |
Compute the counterclockwise angle of this respect x-axis.
Definition at line 571 of file point.H.
References counterclockwise_angle_with(), and Point.
Referenced by TEST_F().
|
inline |
Compute the counterclockwise wise angle respect another segment s.
Definition at line 550 of file point.H.
References arctan2(), __gmp_expr< mpq_t, mpq_t >::get_d(), PI, src, tgt, Point::x, Point::y, and y1().
Referenced by counterclockwise_angle(), Aleph::GiftWrappingConvexHull::operator()(), and TEST_F().
|
inline |
Extend the segment by __dist from the source endpoint.
Definition at line 783 of file point.H.
References compute_tgt_point(), size(), slope(), and src.
Referenced by Ellipse::compute_tangents().
|
inline |
Extend the segment by __dist from the target endpoint.
Definition at line 796 of file point.H.
References compute_tgt_point(), size(), slope(), and tgt.
Referenced by Ellipse::compute_tangents().
Construct the segment perpendicular to this passing through p.
Definition at line 618 of file point.H.
References Point::get_x(), Point::get_y(), Point, slope(), src, tgt, y, and y1().
Referenced by Aleph::QuickHull::get_fartest_point().
|
inline |
Definition at line 468 of file point.H.
References src.
Referenced by Segment(), Ellipse::compute_tangents(), contains_to(), Aleph::CuttingEarsTriangulation::diagonalie(), Ellipse::intersection_with(), Ellipse::intersects_with(), nearest_point(), Aleph::BruteForceConvexHull::operator()(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inline |
Definition at line 470 of file point.H.
References tgt.
Referenced by Segment(), Ellipse::compute_tangents(), contains_to(), Aleph::CuttingEarsTriangulation::diagonalie(), Regular_Polygon::get_vertex(), Ellipse::intersection_with(), Ellipse::intersects_with(), nearest_point(), Aleph::BruteForceConvexHull::operator()(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inline |
Definition at line 1473 of file point.H.
References Ellipse::intersection_with().
Compute intersection point solving point-slope equations for both lines.
Definition at line 733 of file point.H.
References ah_domain_error_if, is_parallel_with(), slope(), src, Point::x, y, Point::y, and y1().
Referenced by Triangle::intersection_with(), and intersection_with().
Definition at line 1088 of file point.H.
References Segment(), ah_domain_error_if, Triangle::contains_to(), Triangle::get_p1(), Triangle::get_p2(), Triangle::get_p3(), intersection_with(), and intersects_with().
|
inline |
Return true if the segments intersect at interior points only.
Definition at line 687 of file point.H.
References Point::is_colinear_with(), Point::is_to_left_from(), src, and tgt.
Referenced by intersects_with().
|
inline |
Definition at line 1466 of file point.H.
References Ellipse::intersects_with().
|
inline |
Return true if s intersects this segment (including endpoints).
Definition at line 713 of file point.H.
References contains_to(), intersects_properly_with(), src, and tgt.
Referenced by Aleph::CuttingEarsTriangulation::diagonalie(), intersection_with(), and intersects_with().
|
inline |
Definition at line 1077 of file point.H.
References Segment(), Triangle::get_p1(), Triangle::get_p2(), Triangle::get_p3(), and intersects_with().
|
inline |
|
inline |
Return true if s has the same slope.
Definition at line 727 of file point.H.
References slope().
Referenced by intersection_with().
|
inline |
Return true if this segment is to the left of point p.
Definition at line 590 of file point.H.
References Point::is_to_right_from().
Referenced by Ellipse::intersects_with(), and TEST_F().
|
inline |
Return true if this segment is to the right of point p.
Definition at line 596 of file point.H.
References Point::is_to_left_from().
Referenced by TEST_F().
|
inline |
|
inline |
|
inline |
Return the perpendicular chord of length 2*dist through the midpoint.
Definition at line 650 of file point.H.
References arctan(), Polar_Point::get_r(), Polar_Point::get_theta(), Point::is_to_right_from(), pitag(), Point, src, and tgt.
Referenced by Segment().
|
inline |
Return whichever endpoint is nearer to p.
Definition at line 612 of file point.H.
References get_src_point(), get_tgt_point(), and Point::nearest_point().
|
inline |
Definition at line 814 of file point.H.
References to_string().
|
inline |
|
inline |
|
inline |
Rotate the segment by angle (radians) around the source point.
Definition at line 820 of file point.H.
References Polar_Point::get_r(), Polar_Point::get_theta(), src, and tgt.
Referenced by Regular_Polygon::get_vertex().
|
inline |
|
inline |
|
inline |
Definition at line 544 of file point.H.
References compute_slope().
Referenced by enlarge_src(), enlarge_tgt(), get_perpendicular(), intersection_with(), Ellipse::intersection_with(), Ellipse::intersects_with(), is_parallel_with(), and TEST_F().
|
inline |
Return "(src)(tgt)" textual form.
Definition at line 809 of file point.H.
References src, tgt, and Point::to_string().
Referenced by operator std::string().
|
friend |
Definition at line 418 of file point.H.
Referenced by counterclockwise_angle(), get_perpendicular(), and mid_perpendicular().
|
private |
Definition at line 421 of file point.H.
Referenced by Segment(), compute_slope(), contains_to(), contains_to(), counterclockwise_angle_with(), enlarge_src(), get_perpendicular(), get_src_point(), highest_point(), intersection_with(), intersects_properly_with(), intersects_with(), Point::is_clockwise_with(), is_colinear_with(), Point::is_colinear_with(), Point::is_to_left_from(), Point::is_to_right_from(), leftmost_point(), lowest_point(), mid_perpendicular(), mid_point(), operator==(), rightmost_point(), rotate(), sense(), size(), and to_string().
|
private |
Definition at line 421 of file point.H.
Referenced by Segment(), compute_slope(), contains_to(), contains_to(), counterclockwise_angle_with(), enlarge_tgt(), get_perpendicular(), get_tgt_point(), highest_point(), intersects_properly_with(), intersects_with(), Point::is_clockwise_with(), is_colinear_with(), Point::is_colinear_with(), Point::is_to_left_from(), Point::is_to_right_from(), leftmost_point(), lowest_point(), mid_perpendicular(), mid_point(), operator==(), rightmost_point(), rotate(), sense(), size(), and to_string().