53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
|
#include "Shape.hpp"
|
|
|
|
namespace J3ML::Geometry
|
|
{
|
|
using LinearAlgebra::Vector2;
|
|
// CaveGame AABB
|
|
class AABB2D : public Shape2D
|
|
{
|
|
public:
|
|
|
|
Vector2 minPoint;
|
|
Vector2 maxPoint;
|
|
AABB2D() {}
|
|
AABB2D(const Vector2& min, const Vector2& max):
|
|
minPoint(min), maxPoint(max)
|
|
{}
|
|
|
|
float Width() const;
|
|
float Height() const;
|
|
|
|
float DistanceSq(const Vector2& pt) const;
|
|
|
|
void SetNegativeInfinity();
|
|
|
|
void Enclose(const Vector2& point);
|
|
|
|
bool Intersects(const AABB2D& rhs) const;
|
|
|
|
bool Contains(const AABB2D& rhs) const;
|
|
|
|
bool Contains(const Vector2& pt) const;
|
|
|
|
bool Contains(int x, int y) const;
|
|
|
|
bool IsDegenerate() const;
|
|
|
|
bool HasNegativeVolume() const;
|
|
|
|
bool IsFinite() const;
|
|
|
|
Vector2 PosInside(const Vector2 &normalizedPos) const;
|
|
|
|
Vector2 ToNormalizedLocalSpace(const Vector2 &pt) const;
|
|
|
|
AABB2D operator+(const Vector2& pt) const;
|
|
|
|
AABB2D operator-(const Vector2& pt) const;
|
|
|
|
};
|
|
} |