A triangle defined by its three side lengths. More...
#include <shapes.hpp>
Public Member Functions | |
| Triangle (double a, double b, double c) | |
| Construct a triangle from three side lengths. | |
| double | area () const override |
| Compute the area of the shape. | |
| std::string | name () const override |
| Return the human-readable name of the shape. | |
| double | perimeter () const override |
| Compute the perimeter of the shape. | |
Public Member Functions inherited from geometry::Shape | |
| virtual | ~Shape ()=default |
| Virtual destructor for safe polymorphic deletion. | |
| std::string | describe () const |
| Pretty-print shape information. | |
Additional Inherited Members | |
Static Public Member Functions inherited from geometry::Shape | |
| static int | instance_count () |
| Get the total count of Shape instances created. | |
Protected Member Functions inherited from geometry::Shape | |
| Shape () | |
| Increment the instance counter. | |
A triangle defined by its three side lengths.
The area is computed via Heron's formula:
\[ s = \frac{a + b + c}{2}, \qquad A = \sqrt{s(s-a)(s-b)(s-c)} \]
Definition at line 202 of file shapes.hpp.
|
inline |
Construct a triangle from three side lengths.
| a | First side. |
| b | Second side. |
| c | Third side. |
Definition at line 211 of file shapes.hpp.
|
inlinenodiscardoverridevirtual |
Compute the area of the shape.
Implements geometry::Shape.
Definition at line 213 of file shapes.hpp.
|
inlinenodiscardoverridevirtual |
Return the human-readable name of the shape.
"Circle", "Rectangle", etc. Implements geometry::Shape.
Definition at line 222 of file shapes.hpp.
|
inlinenodiscardoverridevirtual |
Compute the perimeter of the shape.
Implements geometry::Shape.
Definition at line 218 of file shapes.hpp.