|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Represents a triangle in 3D space defined by three points. More...
#include <point.H>
Classes | |
| struct | BaryCoords |
| Structure to hold barycentric coordinates. More... | |
Public Member Functions | |
| Triangle3D ()=default | |
| Default constructor. | |
| Triangle3D (const Point3D &p1, const Point3D &p2, const Point3D &p3) | |
| Constructs a 3D triangle from three vertices. | |
| const Point3D & | get_p1 () const |
| Gets the first vertex of the triangle. | |
| const Point3D & | get_p2 () const |
| Gets the second vertex of the triangle. | |
| const Point3D & | get_p3 () const |
| Gets the third vertex of the triangle. | |
| Point3D | normal () const |
| Computes the normal vector of the triangle's plane. | |
| Geom_Number | double_area_squared () const |
| Calculates twice the squared area of the triangle. | |
| Point3D | centroid () const |
| Computes the centroid (center of mass) of the triangle. | |
| bool | is_degenerate () const |
| Checks if the triangle is degenerate (i.e., its vertices are collinear). | |
| BaryCoords | barycentric (const Point3D &p) const |
Computes the barycentric coordinates of a point p with respect to this triangle. | |
Private Attributes | |
| Point3D | p1_ |
| Point3D | p2_ |
| Point3D | p3_ |
|
default |
Default constructor.
Initializes a degenerate triangle at the origin.
|
inline |
Computes the barycentric coordinates of a point p with respect to this triangle.
| p | The point to find coordinates for. |
BaryCoords struct containing the coordinates (u, v, w). | std::domain_error | if the triangle is degenerate. |
Definition at line 3438 of file point.H.
References ah_domain_error_if, Aleph::divide_and_conquer_partition_dp(), is_degenerate(), p1_, p2_, p3_, and w.
|
inline |
|
inline |
Gets the first vertex of the triangle.
Definition at line 3376 of file point.H.
References p1_.
Referenced by Aleph::operator<<().
Gets the second vertex of the triangle.
Definition at line 3378 of file point.H.
References p2_.
Referenced by Aleph::operator<<().
Gets the third vertex of the triangle.
Definition at line 3380 of file point.H.
References p3_.
Referenced by Aleph::operator<<().
|
inline |
Checks if the triangle is degenerate (i.e., its vertices are collinear).
true if the area is zero, false otherwise. Definition at line 3416 of file point.H.
References Aleph::Point3D::norm_squared(), and normal().
Referenced by barycentric(), TEST_F(), and TEST_F().
|
inline |
Computes the normal vector of the triangle's plane.
The normal is calculated as (p2-p1) x (p3-p1). Its magnitude is twice the triangle's area. The direction depends on the winding order of the vertices.
Point3D representing the normal vector (not normalized). Definition at line 3389 of file point.H.
References Aleph::Point3D::cross(), p1_, p2_, and p3_.
Referenced by double_area_squared(), is_degenerate(), and TEST_F().
|
private |
Definition at line 3360 of file point.H.
Referenced by barycentric(), centroid(), get_p1(), and normal().
|
private |
Definition at line 3360 of file point.H.
Referenced by barycentric(), centroid(), get_p2(), and normal().
|
private |
Definition at line 3360 of file point.H.
Referenced by barycentric(), centroid(), get_p3(), and normal().