diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-05 20:20:14 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-05 20:20:14 +0000 |
commit | 335e9c6b4bbc5bbf1a861ac16abf612f5519dd5e (patch) | |
tree | ce88489a661a605a010d1335776712078e9029ec /lib/geometricPlane.h | |
parent | Inline functions of GeometricPlane (diff) | |
download | ilt-335e9c6b4bbc5bbf1a861ac16abf612f5519dd5e.tar.bz2 ilt-335e9c6b4bbc5bbf1a861ac16abf612f5519dd5e.tar.xz ilt-335e9c6b4bbc5bbf1a861ac16abf612f5519dd5e.zip |
Template GeometicPlane on Position type
Diffstat (limited to 'lib/geometricPlane.h')
-rw-r--r-- | lib/geometricPlane.h | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/geometricPlane.h b/lib/geometricPlane.h index 5be76ec..fd3a1d7 100644 --- a/lib/geometricPlane.h +++ b/lib/geometricPlane.h @@ -9,17 +9,23 @@ class GeometricPlane { public: + enum class PlaneRelation { Above, Below, On }; + + static bool isIntersect(PlaneRelation a, PlaneRelation b); +}; + +template<typename PositionType> class GeometricPlaneT : public GeometricPlane { +public: struct DistAndPosition { - float dist; - Position3D position; + PositionType::value_type dist; + PositionType position; }; - enum class PlaneRelation { Above, Below, On }; - Position3D origin; + PositionType origin; Normal3D normal; [[nodiscard]] inline PlaneRelation - getRelation(Position3D point) const + getRelation(PositionType point) const { const auto d = glm::dot(normal, point - origin); return d < 0.F ? PlaneRelation::Below : d > 0.F ? PlaneRelation::Above : PlaneRelation::On; @@ -34,11 +40,4 @@ public: } return DistAndPosition {dist, ray.start + (ray.direction * dist)}; } - - inline static bool - isIntersect(PlaneRelation a, PlaneRelation b) - { - return ((a == PlaneRelation::Above && b == PlaneRelation::Below) - || (a == PlaneRelation::Below && b == PlaneRelation::Above)); - } }; |