|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
A non-degenerate triangle defined by three points. More...
#include <point.H>
Public Member Functions | |
| Triangle (Point p1, Point p2, Point p3) | |
| Constructs a triangle from three points. | |
| Triangle (Point p, const Segment &s) | |
| Constructs a triangle from a point and a segment. | |
| Triangle (const Segment &s, Point p) | |
| Constructs a triangle from a segment and a point. | |
| Geom_Number | area () const |
| Calculates the unsigned area of the triangle. | |
| bool | is_clockwise () const |
| Checks if the triangle vertices are ordered clockwise. | |
| const Point & | highest_point () const |
| Gets the vertex with the largest y-coordinate. | |
| const Point & | lowest_point () const |
| Gets the vertex with the smallest y-coordinate. | |
| const Point & | leftmost_point () const |
| Gets the vertex with the smallest x-coordinate. | |
| const Point & | rightmost_point () const |
| Gets the vertex with the largest x-coordinate. | |
| const Point & | get_p1 () const |
| Gets the first vertex. | |
| const Point & | get_p2 () const |
| Gets the second vertex. | |
| const Point & | get_p3 () const |
| Gets the third vertex. | |
| bool | operator== (const Triangle &t) const noexcept |
| Checks for equality between two triangles. | |
| bool | operator!= (const Triangle &t) const noexcept |
| Checks for inequality between two triangles. | |
| Point | centroid () const |
| Computes the centroid (center of mass) of the triangle. | |
| Geom_Number | perimeter () const |
| Computes the perimeter of the triangle. | |
| Point | circumcenter () const |
| Computes the circumcenter of the triangle. | |
| Point | incenter () const |
| Computes the incenter of the triangle. | |
| std::array< Segment, 3 > | edges () const |
| Gets the three edges of the triangle. | |
| bool | contains (const Point &p) const |
| Checks if a point lies strictly inside this triangle. | |
| Segment | intersection_with (const Segment &s) const |
| Computes the intersection segment between this triangle and a segment. | |
Public Member Functions inherited from Aleph::Geom_Object | |
| Geom_Object ()=default | |
| virtual | ~Geom_Object ()=default |
Private Attributes | |
| Point | p1_ |
| Point | p2_ |
| Point | p3_ |
| Geom_Number | area_ |
Friends | |
| class | Point |
| class | Segment |
A non-degenerate triangle defined by three points.
Provides basic geometric properties and predicates for a triangle, such as area, orientation, and special centers (centroid, circumcenter, incenter). Used by polygon triangulation and other geometric algorithms.
Constructs a triangle from three points.
| p1 | The first vertex. |
| p2 | The second vertex. |
| p3 | The third vertex. |
| std::domain_error | if the three points are collinear. |
Definition at line 1494 of file point.H.
References ah_domain_error_if, area_, Aleph::area_of_parallelogram(), p1_, p2_, and p3_.
Constructs a triangle from a point and a segment.
| p | The first vertex. |
| s | The segment defining the other two vertices. |
| std::domain_error | if the three points are collinear. |
Definition at line 1508 of file point.H.
References ah_domain_error_if, area_, Aleph::area_of_parallelogram(), p1_, p2_, and p3_.
Constructs a triangle from a segment and a point.
| s | The segment defining the first two vertices. |
| p | The third vertex. |
| std::domain_error | if the three points are collinear. |
Definition at line 1521 of file point.H.
References ah_domain_error_if, area_, Aleph::area_of_parallelogram(), p1_, p2_, and p3_.
|
inline |
|
inline |
|
inline |
Computes the circumcenter of the triangle.
The circumcenter is the intersection point of the perpendicular bisectors of the edges and is equidistant from the three vertices.
Point representing the circumcenter. | std::domain_error | if the triangle is degenerate (collinear vertices). |
Definition at line 1643 of file point.H.
References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), Aleph::Point::get_x(), Aleph::Point::get_y(), p1_, p2_, p3_, and y1().
Checks if a point lies strictly inside this triangle.
This is done by checking if the point is on the same side of all three edges. The result depends on the triangle's orientation.
| p | The point to check. |
true if the point is strictly inside, false if it is on an edge or outside. Definition at line 1706 of file point.H.
References Aleph::and, is_clockwise(), Aleph::Point::is_left_of(), Aleph::Point::is_to_right_from(), p1_, p2_, and p3_.
Referenced by demo_geometric_primitives(), TEST_F(), and TEST_F().
|
inline |
Gets the first vertex.
Definition at line 1587 of file point.H.
References p1_.
Referenced by Aleph::ShortestPathInPolygon::build_tris(), Eepic_Triangle::draw(), Aleph::Tikz_Plane::draw_triangle(), Aleph::Segment::intersection_with(), Aleph::Segment::intersects_with(), Aleph::ConvexPolygonDecomposition::operator()(), Aleph::operator<<(), print_triangle(), Aleph::detail::spp_build_tris(), Aleph::GeomSerializer::to_geojson(), Aleph::GeomSerializer::to_wkt(), and triangle_area().
Gets the second vertex.
Definition at line 1589 of file point.H.
References p2_.
Referenced by Aleph::ShortestPathInPolygon::build_tris(), Eepic_Triangle::draw(), Aleph::Tikz_Plane::draw_triangle(), Aleph::Segment::intersection_with(), Aleph::Segment::intersects_with(), Aleph::ConvexPolygonDecomposition::operator()(), Aleph::operator<<(), print_triangle(), Aleph::detail::spp_build_tris(), Aleph::GeomSerializer::to_geojson(), Aleph::GeomSerializer::to_wkt(), and triangle_area().
Gets the third vertex.
Definition at line 1591 of file point.H.
References p3_.
Referenced by Aleph::ShortestPathInPolygon::build_tris(), Eepic_Triangle::draw(), Aleph::Tikz_Plane::draw_triangle(), Aleph::Segment::intersection_with(), Aleph::Segment::intersects_with(), Aleph::ConvexPolygonDecomposition::operator()(), Aleph::operator<<(), print_triangle(), Aleph::detail::spp_build_tris(), Aleph::GeomSerializer::to_geojson(), Aleph::GeomSerializer::to_wkt(), and triangle_area().
Gets the vertex with the largest y-coordinate.
Definition at line 1550 of file point.H.
References Aleph::Point::get_y(), max(), p1_, p2_, and p3_.
Referenced by Aleph::Tikz_Plane::bbox_of().
|
inline |
Computes the incenter of the triangle.
The incenter is the intersection point of the angle bisectors and is the center of the triangle's incircle.
Point representing the incenter. | std::domain_error | if the triangle is degenerate. |
Definition at line 1678 of file point.H.
References ah_domain_error_if, Aleph::Point::distance_to(), p1_, p2_, p3_, and Aleph::sum().
Computes the intersection segment between this triangle and a segment.
| s | The segment to intersect with. |
Segment. Definition at line 1723 of file point.H.
References Aleph::Segment::intersection_with().
|
inline |
Checks if the triangle vertices are ordered clockwise.
true if the vertex order (p1, p2, p3) is clockwise, false otherwise. Definition at line 1541 of file point.H.
References area_.
Referenced by contains().
Gets the vertex with the smallest x-coordinate.
Definition at line 1570 of file point.H.
References Aleph::Point::get_x(), min(), p1_, p2_, and p3_.
Referenced by Aleph::Tikz_Plane::bbox_of().
Gets the vertex with the smallest y-coordinate.
Definition at line 1560 of file point.H.
References Aleph::Point::get_y(), min(), p1_, p2_, and p3_.
Referenced by Aleph::Tikz_Plane::bbox_of().
Checks for inequality between two triangles.
| t | The other triangle to compare. |
true if the triangles do not share the same three vertices. Definition at line 1613 of file point.H.
References Aleph::divide_and_conquer_partition_dp().
Checks for equality between two triangles.
| t | The other triangle to compare. |
true if the triangles are composed of the same three points. Definition at line 1600 of file point.H.
References Aleph::and, Aleph::divide_and_conquer_partition_dp(), p1_, p2_, and p3_.
|
inline |
Gets the vertex with the largest x-coordinate.
Definition at line 1580 of file point.H.
References Aleph::Point::get_x(), max(), p1_, p2_, and p3_.
Referenced by Aleph::Tikz_Plane::bbox_of().
|
private |
Definition at line 1484 of file point.H.
Referenced by Triangle(), Triangle(), Triangle(), area(), and is_clockwise().
|
private |
Definition at line 1482 of file point.H.
Referenced by Triangle(), Triangle(), Triangle(), centroid(), circumcenter(), contains(), edges(), get_p1(), highest_point(), incenter(), leftmost_point(), lowest_point(), operator==(), perimeter(), and rightmost_point().
|
private |
Definition at line 1482 of file point.H.
Referenced by Triangle(), Triangle(), Triangle(), centroid(), circumcenter(), contains(), edges(), get_p2(), highest_point(), incenter(), leftmost_point(), lowest_point(), operator==(), perimeter(), and rightmost_point().
|
private |
Definition at line 1482 of file point.H.
Referenced by Triangle(), Triangle(), Triangle(), centroid(), circumcenter(), contains(), edges(), get_p3(), highest_point(), incenter(), leftmost_point(), lowest_point(), operator==(), perimeter(), and rightmost_point().