From cd1bb730f29cb287654fe2e2649400ec060f7a94 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 24 Aug 2017 16:43:54 +1000 Subject: [PATCH] geom/aabb: rename AABB to aabb --- geom/aabb.cpp | 54 +++++++++++++++++++++++----------------------- geom/aabb.hpp | 32 +++++++++++++-------------- geom/aabb.ipp | 4 ++-- geom/ellipse.cpp | 8 +++---- geom/fwd.hpp | 2 +- geom/iostream.hpp | 2 +- geom/ops.hpp | 2 +- geom/ray.cpp | 2 +- geom/ray.hpp | 2 +- test/geom/aabb.cpp | 10 ++++----- test/geom/ray.cpp | 4 ++-- 11 files changed, 61 insertions(+), 61 deletions(-) diff --git a/geom/aabb.cpp b/geom/aabb.cpp index 81901265..ad122a4b 100644 --- a/geom/aabb.cpp +++ b/geom/aabb.cpp @@ -21,11 +21,11 @@ #include "../coord/iostream.hpp" #include "../debug.hpp" -using util::geom::AABB; +using util::geom::aabb; //----------------------------------------------------------------------------- template -AABB::AABB (point _p0, point _p1): +aabb::aabb (point _p0, point _p1): p0 (_p0), p1 (_p1) { @@ -36,7 +36,7 @@ AABB::AABB (point _p0, point _p1): //----------------------------------------------------------------------------- template T -AABB::diameter (void) const +aabb::diameter (void) const { return magnitude ().diameter (); } @@ -45,7 +45,7 @@ AABB::diameter (void) const //----------------------------------------------------------------------------- template util::extent -AABB::magnitude (void) const +aabb::magnitude (void) const { extent out; for (size_t i = 0; i < S; ++i) @@ -57,7 +57,7 @@ AABB::magnitude (void) const //----------------------------------------------------------------------------- template bool -AABB::overlaps (point p) const +aabb::overlaps (point p) const { for (size_t i = 0; i < S; ++i) if (p0[i] > p[i] || p1[i] < p[i]) @@ -70,7 +70,7 @@ AABB::overlaps (point p) const //----------------------------------------------------------------------------- template util::point -AABB::closest (point q) const +aabb::closest (point q) const { point res; @@ -85,8 +85,8 @@ AABB::closest (point q) const /////////////////////////////////////////////////////////////////////////////// template -AABB -AABB::expanded (vector mag) const noexcept +aabb +aabb::expanded (vector mag) const noexcept { CHECK (all (mag >= T{0})); CHECK (all (mag < p1 - p0)); @@ -100,8 +100,8 @@ AABB::expanded (vector mag) const noexcept //----------------------------------------------------------------------------- template -AABB -AABB::expanded (T t) const noexcept +aabb +aabb::expanded (T t) const noexcept { CHECK_GE (t, T{0}); CHECK (all (t < p1 - p0)); @@ -115,8 +115,8 @@ AABB::expanded (T t) const noexcept /////////////////////////////////////////////////////////////////////////////// template -AABB -AABB::contracted (util::vector mag) const noexcept +aabb +aabb::contracted (util::vector mag) const noexcept { CHECK (all (mag > T{0})); CHECK (all (mag <= p1 - p0)); @@ -130,8 +130,8 @@ AABB::contracted (util::vector mag) const noexcept //----------------------------------------------------------------------------- template -AABB -AABB::contracted (T mag) const noexcept +aabb +aabb::contracted (T mag) const noexcept { CHECK_GE (mag, T{0}); CHECK (all (mag <= p1 - p0)); @@ -146,7 +146,7 @@ AABB::contracted (T mag) const noexcept /////////////////////////////////////////////////////////////////////////////// template void -AABB::cover (point p) +aabb::cover (point p) { p0 = min (p, p0); p1 = max (p, p1); @@ -155,8 +155,8 @@ AABB::cover (point p) /////////////////////////////////////////////////////////////////////////////// template -AABB -AABB::operator+ (vector v) const +aabb +aabb::operator+ (vector v) const { return { p0 + v, p1 + v }; } @@ -164,8 +164,8 @@ AABB::operator+ (vector v) const //----------------------------------------------------------------------------- template -AABB -AABB::operator- (vector v) const +aabb +aabb::operator- (vector v) const { return { p0 - v, p1 - v }; } @@ -174,7 +174,7 @@ AABB::operator- (vector v) const /////////////////////////////////////////////////////////////////////////////// template bool -AABB::operator== (const AABB rhs) const +aabb::operator== (const aabb rhs) const { return rhs.p0 == p0 && rhs.p1 == p1; } @@ -184,8 +184,8 @@ AABB::operator== (const AABB rhs) const //----------------------------------------------------------------------------- namespace util::debug { template - struct validator> { - static bool is_valid (const AABB &b) + struct validator> { + static bool is_valid (const aabb &b) { for (size_t i = 0; i < S; ++i) if (b.p1[i] < b.p0[i]) @@ -200,18 +200,18 @@ namespace util::debug { //----------------------------------------------------------------------------- template std::ostream& -util::geom::operator<< (std::ostream &os, util::geom::AABB b) +util::geom::operator<< (std::ostream &os, util::geom::aabb b) { - os << "AABB(" << b.p0 << ", " << b.p1 << ")"; + os << "aabb(" << b.p0 << ", " << b.p1 << ")"; return os; } //----------------------------------------------------------------------------- #define INSTANTIATE_S_T(S,T) \ -namespace util::geom { template struct AABB; } \ -template bool util::debug::is_valid (const AABB&); \ -template std::ostream& util::geom::operator<< (std::ostream&, AABB); +namespace util::geom { template struct aabb; } \ +template bool util::debug::is_valid (const aabb&); \ +template std::ostream& util::geom::operator<< (std::ostream&, aabb); #define INSTANTIATE(T) \ INSTANTIATE_S_T(2,T) \ diff --git a/geom/aabb.hpp b/geom/aabb.hpp index aaafb61a..62793d7d 100644 --- a/geom/aabb.hpp +++ b/geom/aabb.hpp @@ -25,9 +25,9 @@ namespace util::geom { template - struct AABB { - AABB () = default; - AABB (point, point); + struct aabb { + aabb () = default; + aabb (point, point); T diameter (void) const; extent magnitude (void) const; @@ -36,30 +36,30 @@ namespace util::geom { point closest (point) const; - AABB expanded (util::vector) const noexcept; - AABB expanded (T) const noexcept; + aabb expanded (util::vector) const noexcept; + aabb expanded (T) const noexcept; - AABB contracted (util::vector) const noexcept; - AABB contracted (T) const noexcept; + aabb contracted (util::vector) const noexcept; + aabb contracted (T) const noexcept; void cover (point); - AABB operator+ (vector) const; - AABB operator- (vector) const; + aabb operator+ (vector) const; + aabb operator- (vector) const; - bool operator== (AABB) const; + bool operator== (aabb) const; point p0; point p1; }; - typedef AABB<2,float> AABB2f; - typedef AABB<2,unsigned> AABB2u; - typedef AABB<2,int> AABB2i; + typedef aabb<2,float> aabb2f; + typedef aabb<2,unsigned> aabb2u; + typedef aabb<2,int> aabb2i; - typedef AABB<3,float> AABB3f; - typedef AABB<3,unsigned> AABB3u; - typedef AABB<3,int> AABB3i; + typedef aabb<3,float> aabb3f; + typedef aabb<3,unsigned> aabb3u; + typedef aabb<3,int> aabb3i; } #include "aabb.ipp" diff --git a/geom/aabb.ipp b/geom/aabb.ipp index 78017b34..6e13332e 100644 --- a/geom/aabb.ipp +++ b/geom/aabb.ipp @@ -28,9 +28,9 @@ /////////////////////////////////////////////////////////////////////////////// namespace util::geom { template - struct sampler { + struct sampler { static point - fn (AABB b, G &g) + fn (aabb b, G &g) { std::uniform_real_distribution d; diff --git a/geom/ellipse.cpp b/geom/ellipse.cpp index 5d59698b..e0516b19 100644 --- a/geom/ellipse.cpp +++ b/geom/ellipse.cpp @@ -47,7 +47,7 @@ template bool util::geom::intersects (ellipse<3,float>, util::point<3,float>); /////////////////////////////////////////////////////////////////////////////// template -static util::geom::AABB +static util::geom::aabb bounds (ellipse e) { return { @@ -59,7 +59,7 @@ bounds (ellipse e) //----------------------------------------------------------------------------- template class K> -util::geom::AABB +util::geom::aabb util::geom::bounds (K k) { return ::bounds (k); @@ -67,5 +67,5 @@ util::geom::bounds (K k) //----------------------------------------------------------------------------- -template util::geom::AABB<2,float> util::geom::bounds (ellipse<2,float>); -template util::geom::AABB<3,float> util::geom::bounds (ellipse<3,float>); +template util::geom::aabb<2,float> util::geom::bounds (ellipse<2,float>); +template util::geom::aabb<3,float> util::geom::bounds (ellipse<3,float>); diff --git a/geom/fwd.hpp b/geom/fwd.hpp index 78772ffb..611a89a9 100644 --- a/geom/fwd.hpp +++ b/geom/fwd.hpp @@ -22,7 +22,7 @@ namespace util::geom { template struct ray; template struct plane; - template struct AABB; + template struct aabb; template struct sphere; template struct ellipse; template struct rect; diff --git a/geom/iostream.hpp b/geom/iostream.hpp index 507aecab..66af161c 100644 --- a/geom/iostream.hpp +++ b/geom/iostream.hpp @@ -26,7 +26,7 @@ namespace util::geom { template std::ostream& - operator<< (std::ostream&, AABB); + operator<< (std::ostream&, aabb); template std::ostream& diff --git a/geom/ops.hpp b/geom/ops.hpp index 504d584d..e0f5f979 100644 --- a/geom/ops.hpp +++ b/geom/ops.hpp @@ -55,7 +55,7 @@ namespace util::geom { typename T, template class K > - AABB + aabb bounds (K); template < diff --git a/geom/ray.cpp b/geom/ray.cpp index 3650ad3f..84802215 100644 --- a/geom/ray.cpp +++ b/geom/ray.cpp @@ -44,7 +44,7 @@ ray::intersect (plane q) const /// returns NaN if behind template T -ray::intersect (AABB r) const +ray::intersect (aabb r) const { auto t1 = (r.p0 - origin) / direction; auto t2 = (r.p1 - origin) / direction; diff --git a/geom/ray.hpp b/geom/ray.hpp index 5b2d13f6..3f506e86 100644 --- a/geom/ray.hpp +++ b/geom/ray.hpp @@ -47,7 +47,7 @@ namespace util::geom { //--------------------------------------------------------------------- // intersection tests T intersect (plane) const; - T intersect (AABB) const; + T intersect (aabb) const; T intersect (sphere) const; // queries diff --git a/test/geom/aabb.cpp b/test/geom/aabb.cpp index 696254a4..8e1cf651 100644 --- a/test/geom/aabb.cpp +++ b/test/geom/aabb.cpp @@ -4,7 +4,7 @@ #include -using util::geom::AABB2f; +using util::geom::aabb2f; int @@ -14,16 +14,16 @@ main (int, char**) { // Test contraction - const AABB2f val { { 2, 2 }, { 8, 8 } }; - const AABB2f res { { 3, 3 }, { 7, 7 } }; + const aabb2f val { { 2, 2 }, { 8, 8 } }; + const aabb2f res { { 3, 3 }, { 7, 7 } }; tap.expect_eq (val.contracted (2.f), res, "over contraction"); } { // Test expansion - const AABB2f val { { 2, 2 }, { 8, 8 } }; - const AABB2f res { { 1, 1 }, { 9, 9 } }; + const aabb2f val { { 2, 2 }, { 8, 8 } }; + const aabb2f res { { 1, 1 }, { 9, 9 } }; tap.expect_eq (val.expanded (2.f), res, "expansion"); } diff --git a/test/geom/ray.cpp b/test/geom/ray.cpp index 2cef97e1..7d5a3dc1 100644 --- a/test/geom/ray.cpp +++ b/test/geom/ray.cpp @@ -23,10 +23,10 @@ test_intersect_plane (util::TAP::logger &tap) void test_intersect_aabb (util::TAP::logger &tap) { - using util::geom::AABB2f; + using util::geom::aabb2f; // trivial case: unit aabb at origin, ray from (0.5,-0.5) upwards - const AABB2f box { + const aabb2f box { { 0.f, 0.f }, { 1.f, 1.f } };