From 3186d300a13e62e753926ea09529c4ae940ee247 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 8 Apr 2019 14:05:38 +1000 Subject: [PATCH] geom/aabb: add `expand` observer. --- geom/aabb.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/geom/aabb.hpp b/geom/aabb.hpp index 0bbc9ad1..ea1041f0 100644 --- a/geom/aabb.hpp +++ b/geom/aabb.hpp @@ -73,6 +73,21 @@ namespace cruft::geom { } + /////////////////////////////////////////////////////////////////////// + /// Applies a negative offset to lo, and a positive offset to hi, and + /// returns the result. + /// + /// The offset applied is identical for lo and hi, so one may need to + /// consider halving the supplied magnitude depending on the use case. + aabb + expand [[nodiscard]] (T mag) const + { + return { + lo - mag, + hi + mag + }; + } + /////////////////////////////////////////////////////////////////////// /// Adds a constant vector to both the lo and hi points. aabb operator+ (vector v) const