From b222c21715384efc2eaa53d3ba295fb34da5b599 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 9 Apr 2023 12:24:55 +0100 Subject: Start to factor out geometric place from face controller split --- lib/geometricPlane.cpp | 9 +++++++++ lib/geometricPlane.h | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 lib/geometricPlane.cpp create mode 100644 lib/geometricPlane.h (limited to 'lib') diff --git a/lib/geometricPlane.cpp b/lib/geometricPlane.cpp new file mode 100644 index 0000000..cb52997 --- /dev/null +++ b/lib/geometricPlane.cpp @@ -0,0 +1,9 @@ +#include "geometricPlane.h" +#include + +GeometricPlane::PlaneRelation +GeometricPlane::getRelation(glm::vec3 p) const +{ + const auto d = glm::dot(normal, p - origin); + return d < 0.f ? PlaneRelation::Below : d > 0.f ? PlaneRelation::Above : PlaneRelation::On; +} diff --git a/lib/geometricPlane.h b/lib/geometricPlane.h new file mode 100644 index 0000000..96816f2 --- /dev/null +++ b/lib/geometricPlane.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +class GeometricPlane { +public: + enum class PlaneRelation { Above, Below, On }; + + glm::vec3 origin, normal; + + PlaneRelation getRelation(glm::vec3 point) const; +}; -- cgit v1.2.3