/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright 2015 Danny Robson */ #ifndef __UTIL_AABB_HPP #define __UTIL_AABB_HPP #include "point.hpp" #include "extent.hpp" #include #include namespace util { template struct AABB { AABB () = default; AABB (point, point); T diameter (void) const; extent magnitude (void) const; bool overlaps (point) const; point closest (point) const; AABB& expand (util::vector); AABB& expand (T); AABB expanded (util::vector); AABB expanded (T); AABB& contract (util::vector); AABB& contract (T); AABB contracted (util::vector) const; AABB contracted (T) const; void cover (point); AABB operator+ (vector) const; AABB operator- (vector) const; bool operator== (AABB) const; point p0; point p1; }; typedef AABB<2,float> AABB2f; typedef AABB<2,size_t> AABB2u; typedef AABB<2,intmax_t> AABB2i; typedef AABB<3,float> AABB3f; typedef AABB<3,size_t> AABB3u; typedef AABB<3,intmax_t> AABB3i; template std::ostream& operator<< (std::ostream&, AABB); } #endif