1 #ifndef MATH3D_GEOMETRY2D_H 2 #define MATH3D_GEOMETRY2D_H 9 #include "Triangle2D.h" 13 #include "Polygon2D.h" 14 #include <KrisLibrary/utils/AnyValue.h> 22 enum Type { Empty, Point, Segment, AABB, Triangle, Circle, Box };
32 static const char* TypeName(Type type);
33 const char* TypeName()
const {
return GeometricPrimitive2D::TypeName(type); }
36 void Set(
const AABB2D& aabb);
37 void Set(
const Box2D& box);
44 void ToPolygon(std::vector<Vector2>& outline,
int divs=32)
const;
46 static bool SupportsCollides(Type a,Type b);
47 bool SupportsCollides(Type b)
const {
return GeometricPrimitive2D::SupportsCollides(type,b); }
49 bool Collides(
const Vector2& point)
const;
50 bool Collides(
const Segment2D& segment)
const;
51 bool Collides(
const AABB2D& aabb)
const;
52 bool Collides(
const Box2D& box)
const;
53 bool Collides(
const Circle2D& circle)
const;
54 bool Collides(
const Triangle2D& triangle)
const;
55 static bool SupportsDistance(Type a,Type b);
56 bool SupportsDistance(Type b) {
return GeometricPrimitive2D::SupportsDistance(type,b); }
58 Real Distance(
const Vector2& x)
const;
59 Real Distance(
const Segment2D& segment)
const;
60 Real Distance(
const AABB2D& aabb)
const;
61 Real Distance(
const Box2D& box)
const;
62 Real Distance(
const Circle2D& circle)
const;
63 Real Distance(
const Triangle2D& triangle)
const;
A 2D circle class.
Definition: Circle2D.h:16
A 2D triangle class.
Definition: Triangle2D.h:25
A polymorphic container class that can contain data of any type.
Definition: AnyValue.h:25
A 2D boxThe box is the unit square [0,1]^2 set in the scaled local coordinate system. That is, one corner is at the origin, and it has dimensions [dims.x,dims.y] in the coordinates given by {xbasis,ybasis}.
Definition: Box2D.h:20
Definition: geometry2d.h:19
A 2D segment class.
Definition: Segment2D.h:17
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:12
A 2D vector class.
Definition: math3d/primitives.h:41
A 2D axis-aligned bounding box.
Definition: AABB2D.h:13