8#ifndef GALAXY_MATH_RECT_HPP_
9#define GALAXY_MATH_RECT_HPP_
13#include <glm/vec2.hpp>
24 template<meta::is_arithmetic Type>
57 bool contains(const Type _x, const Type _y) const noexcept;
94 void set_top_left(const glm::vec<2, Type, glm::defaultp>& pos) noexcept;
126 glm::vec<2, Type, glm::defaultp>
get_center() const noexcept;
134 glm::vec<2, Type, glm::defaultp>
get_size() const noexcept;
140 auto operator<=>(const
Rect&) const noexcept = default;
188 template<meta::is_arithmetic Type>
197 template<meta::is_arithmetic Type>
206 template<meta::is_arithmetic Type>
211 template<meta::is_arithmetic Type>
215 return ((_x >
x) && (_x < (
x +
width)) && (_y >
y) && (_y < (
y +
height)));
218 template<meta::is_arithmetic Type>
224 template<meta::is_arithmetic Type>
234 template<meta::is_arithmetic Type>
240 template<meta::is_arithmetic Type>
247 template<meta::is_arithmetic Type>
253 template<meta::is_arithmetic Type>
259 template<meta::is_arithmetic Type>
265 template<meta::is_arithmetic Type>
271 template<meta::is_arithmetic Type>
277 template<meta::is_arithmetic Type>
281 return (value >= min) && (value <= max);
Represents a rectangle object.
bool intersects(const Rect< Type > &b) const noexcept
Do two rectangles intersect.
bool contains(const Type _x, const Type _y) const noexcept
Does the rectangle contain the point (x, y).
bool overlaps(const Rect< Type > &b) noexcept
Do the rectangles a and b overlap.
Type height
Height of rectangle.
void set_top_left(const glm::vec< 2, Type, glm::defaultp > &pos) noexcept
Set the top-left position.
Type get_right() const noexcept
Get top right corner.
bool value_in_range(const Type value, const Type min, const Type max) noexcept
Private function to determine if value is in range. Inclusive. Credits: https://stackoverflow....
Type width
Width of rectangle.
glm::vec< 2, Type, glm::defaultp > get_size() const noexcept
Gets width and height of rectangle.
~Rect() noexcept
Destructor.
glm::vec< 2, Type, glm::defaultp > get_top_left() const noexcept
Get the upper-left coordinate.
Type get_bottom() const noexcept
Get bottom left corner.
glm::vec< 2, Type, glm::defaultp > get_center() const noexcept
Gets the center of the rectangle.
Rect() noexcept
Constructor.