From 42c84f2523502d06e63cf558d1a7cff8f1fb6706 Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 6 Jan 2025 04:30:03 +0300 Subject: [PATCH] added midpoint for triangle class --- include/omath/Triangle3d.hpp | 3 +++ source/Triangle3d.cpp | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/omath/Triangle3d.hpp b/include/omath/Triangle3d.hpp index 370aa95..de71a80 100644 --- a/include/omath/Triangle3d.hpp +++ b/include/omath/Triangle3d.hpp @@ -29,5 +29,8 @@ namespace omath [[nodiscard]] Vector3 SideBVector() const; + + [[nodiscard]] + Vector3 MidPoint() const; }; } diff --git a/source/Triangle3d.cpp b/source/Triangle3d.cpp index 54dcf75..aacabc8 100644 --- a/source/Triangle3d.cpp +++ b/source/Triangle3d.cpp @@ -33,4 +33,8 @@ namespace omath { return m_vertex3 - m_vertex2; } -} + Vector3 Triangle3d::MidPoint() const + { + return (m_vertex1 + m_vertex2 + m_vertex3) / 3; + } +} // namespace omath