summaryrefslogtreecommitdiff
path: root/lib/triangle.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-12-15 14:53:05 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-12-15 14:53:05 +0000
commitea393a85a572e94f4c76e79cbd16897f9eae55f5 (patch)
tree12cf233b9fcb0bcf7f4c94e2561b79096a1338a4 /lib/triangle.h
parent2D triangle area support (diff)
downloadilt-ea393a85a572e94f4c76e79cbd16897f9eae55f5.tar.bz2
ilt-ea393a85a572e94f4c76e79cbd16897f9eae55f5.tar.xz
ilt-ea393a85a572e94f4c76e79cbd16897f9eae55f5.zip
Triangle height support
Point C from the line AB
Diffstat (limited to 'lib/triangle.h')
-rw-r--r--lib/triangle.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/triangle.h b/lib/triangle.h
index 5787094..888481d 100644
--- a/lib/triangle.h
+++ b/lib/triangle.h
@@ -45,6 +45,12 @@ struct Triangle : public glm::vec<3, glm::vec<Dim, T, Q>> {
return crossProduct(sideDifference(1), sideDifference(2));
}
+ [[nodiscard]] constexpr auto
+ height()
+ {
+ return (area() * 2) / glm::length(difference(p(0), p(1)));
+ }
+
[[nodiscard]] constexpr Normal3D
nnormal() const
requires(Dim == 3)