diff --git a/include/omath/3d_primitives/plane.hpp b/include/omath/3d_primitives/plane.hpp new file mode 100644 index 0000000..62ff993 --- /dev/null +++ b/include/omath/3d_primitives/plane.hpp @@ -0,0 +1,16 @@ +// +// Created by Vlad on 8/28/2025. +// + +#pragma once +#include "omath/triangle.hpp" +#include "omath/vector3.hpp" +#include + +namespace omath::primitives +{ + [[nodiscard]] + std::array>, 2> create_plane(const Vector3& vertex_a, + const Vector3& vertex_b, + const Vector3& direction, float size) noexcept; +} diff --git a/source/3d_primitives/plane.cpp b/source/3d_primitives/plane.cpp new file mode 100644 index 0000000..c541810 --- /dev/null +++ b/source/3d_primitives/plane.cpp @@ -0,0 +1,19 @@ +// +// Created by Vlad on 8/28/2025. +// +#include "omath/3d_primitives/plane.hpp" + +namespace omath::primitives +{ + std::array>, 2> create_plane(const Vector3& vertex_a, + const Vector3& vertex_b, + const Vector3& direction, const float size) noexcept + { + const auto second_vertex_a = vertex_a + direction * size; + return std::array + { + Triangle{second_vertex_a, vertex_a, vertex_b}, + Triangle{second_vertex_a, vertex_b + direction * size, vertex_b} + }; + } +} // namespace omath::primitives \ No newline at end of file