1 #ifndef MATH3D_GEOMETRY2D_H 2 #define MATH3D_GEOMETRY2D_H 9 #include "Triangle2D.h" 13 #include "Polygon2D.h" 14 #include <KrisLibrary/utils/AnyValue.h> 27 enum Type { Empty, Point, Segment, AABB, Triangle, Circle, Box };
37 static const char* TypeName(Type type);
38 const char* TypeName()
const {
return GeometricPrimitive2D::TypeName(type); }
41 void Set(
const AABB2D& aabb);
42 void Set(
const Box2D& box);
49 void ToPolygon(std::vector<Vector2>& outline,
int divs=32)
const;
51 static bool SupportsCollides(Type a,Type b);
52 bool SupportsCollides(Type b)
const {
return GeometricPrimitive2D::SupportsCollides(type,b); }
54 bool Collides(
const Vector2& point)
const;
55 bool Collides(
const Segment2D& segment)
const;
56 bool Collides(
const AABB2D& aabb)
const;
57 bool Collides(
const Box2D& box)
const;
58 bool Collides(
const Circle2D& circle)
const;
59 bool Collides(
const Triangle2D& triangle)
const;
60 static bool SupportsDistance(Type a,Type b);
61 bool SupportsDistance(Type b) {
return GeometricPrimitive2D::SupportsDistance(type,b); }
63 Real Distance(
const Vector2& x)
const;
64 Real Distance(
const Segment2D& segment)
const;
65 Real Distance(
const AABB2D& aabb)
const;
66 Real Distance(
const Box2D& box)
const;
67 Real Distance(
const Circle2D& circle)
const;
68 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
A generic 2D geometric primitive class.
Definition: geometry2d.h:24
A 2D segment class.
Definition: Segment2D.h:17
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:13
A 2D vector class.
Definition: math3d/primitives.h:41
A 2D axis-aligned bounding box.
Definition: AABB2D.h:13