Cross-platform C SDK logo

Cross-platform C SDK

2D Collisions

❮ Back
Next ❯
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.

Functions

bool_tcol2d_point_point (...)
bool_tcol2d_segment_point (...)
bool_tcol2d_segment_segment (...)
bool_tcol2d_circle_point (...)
bool_tcol2d_circle_segment (...)
bool_tcol2d_circle_circle (...)
bool_tcol2d_box_point (...)
bool_tcol2d_box_segment (...)
bool_tcol2d_box_circle (...)
bool_tcol2d_box_box (...)
bool_tcol2d_obb_point (...)
bool_tcol2d_obb_segment (...)
bool_tcol2d_obb_circle (...)
bool_tcol2d_obb_box (...)
bool_tcol2d_obb_obb (...)
bool_tcol2d_poly_point (...)
bool_tcol2d_poly_segment (...)
bool_tcol2d_poly_circle (...)
bool_tcol2d_poly_box (...)
bool_tcol2d_poly_obb (...)
bool_tcol2d_poly_poly (...)

Collision detection is responsible for studying and developing algorithms that check if two geometric objects intersect at some point. As the general case would be quite complex to implement and inefficient to evaluate, a series of collision volumes (Figure 1) are defined that will enclose the original sets and where the tests can be significantly simplified. The use of these most elementary forms is usually known as broad phase collision detection (Figure 2), since it seeks to detect "non-collision" as quickly as possible. In Hello 2D Collisions! you have an example application.

Drawing multiple collision volumes in the plane.
Figure 1: 2D collision volumes.
Drawing of multiple collision volumes that intersect in the plane.
Figure 2: Broad phase collision detection.

col2d_point_point ()

Point-point collision.

bool_t
col2d_point_pointf(const V2Df *pnt1,
                   const V2Df *pnt2,
                   const real32_t tol,
                   Col2Df *col);

bool_t
col2d_point_pointd(const V2Dd *pnt1,
                   const V2Dd *pnt2,
                   const real64_t tol,
                   Col2Dd *col);

bool_t
Col2D::point_point(const V2D *pnt1,
                   const V2D *pnt2,
                   const real tol,
                   Col2D *col);
pnt1

First point.

pnt2

Second point.

tol

Tolerance. Minimum distance to be considered a collision.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_segment_point ()

Segment-point collision.

bool_t
col2d_segment_pointf(const Seg2Df *seg,
                     const V2Df *pnt,
                     const real32_t tol,
                     Col2Df *col);

bool_t
col2d_segment_pointd(const Seg2Dd *seg,
                     const V2Dd *pnt,
                     const real64_t tol,
                     Col2Dd *col);

bool_t
Col2D::segment_point(const Seg2D *seg,
                     const V2D *pnt,
                     const real tol,
                     Col2D *col);
seg

Segment.

pnt

Point.

tol

Tolerance. Minimum distance to be considered a collision.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_segment_segment ()

Segment-segment collision.

bool_t
col2d_segment_segmentf(const Seg2Df *seg1,
                       const Seg2Df *seg2,
                       Col2Df *col);

bool_t
col2d_segment_segmentd(const Seg2Dd *seg1,
                       const Seg2Dd *seg2,
                       Col2Dd *col);

bool_t
Col2D::segment_segment(const Seg2D *seg1,
                       const Seg2D *seg2,
                       Col2D *col);
seg1

First segment.

seg2

Second segment.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_circle_point ()

Circle-point collision.

bool_t
col2d_circle_pointf(const Cir2Df *cir,
                    const V2Df *pnt,
                    Col2Df *col);

bool_t
col2d_circle_pointd(const Cir2Dd *cir,
                    const V2Dd *pnt,
                    Col2Dd *col);

bool_t
Col2D::circle_point(const Cir2D *cir,
                    const V2D *pnt,
                    Col2D *col);
cir

Circle.

pnt

Point.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_circle_segment ()

Circle-segment collision.

bool_t
col2d_circle_segmentf(const Cir2Df *cir,
                      const Seg2Df *seg,
                      Col2Df *col);

bool_t
col2d_circle_segmentd(const Cir2Dd *cir,
                      const Seg2Dd *seg,
                      Col2Dd *col);

bool_t
Col2D::circle_segment(const Cir2D *cir,
                      const Seg2D *seg,
                      Col2D *col);
cir

Circle.

seg

Segment.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_circle_circle ()

Circle-circle collision.

bool_t
col2d_circle_circlef(const Cir2Df *cir1,
                     const Cir2Df *cir2,
                     Col2Df *col);

bool_t
col2d_circle_circled(const Cir2Dd *cir1,
                     const Cir2Dd *cir2,
                     Col2Dd *col);

bool_t
Col2D::circle_circle(const Cir2D *cir1,
                     const Cir2D *cir2,
                     Col2D *col);
cir1

First circle.

cir2

Second circle.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_box_point ()

Box-point collision.

bool_t
col2d_box_pointf(const Box2Df *box,
                 const V2Df *pnt,
                 Col2Df *col);

bool_t
col2d_box_pointd(const Box2Dd *box,
                 const V2Dd *pnt,
                 Col2Dd *col);

bool_t
Col2D::box_point(const Box2D *box,
                 const V2D *pnt,
                 Col2D *col);
box

Box.

pnt

Point.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_box_segment ()

Box-segment collision.

bool_t
col2d_box_segmentf(const Box2Df *box,
                   const Seg2Df *seg,
                   Col2Df *col);

bool_t
col2d_box_segmentd(const Box2Dd *box,
                   const Seg2Dd *seg,
                   Col2Dd *col);

bool_t
Col2D::box_segment(const Box2D *box,
                   const Seg2D *seg,
                   Col2D *col);
box

Box.

seg

Segment.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_box_circle ()

Box-circle collision.

bool_t
col2d_box_circlef(const Box2Df *box,
                  const Cir2Df *cir,
                  Col2Df *col);

bool_t
col2d_box_circled(const Box2Dd *box,
                  const Cir2Dd *cir,
                  Col2Dd *col);

bool_t
Col2D::box_circle(const Box2D *box,
                  const Cir2D *cir,
                  Col2D *col);
box

Box.

cir

Circle.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_box_box ()

Box-box collision.

bool_t
col2d_box_boxf(const Box2Df *box1,
               const Box2Df *box2,
               Col2Df *col);

bool_t
col2d_box_boxd(const Box2Dd *box1,
               const Box2Dd *box2,
               Col2Dd *col);

bool_t
Col2D::box_box(const Box2D *box1,
               const Box2D *box2,
               Col2D *col);
box1

First box.

box2

Second box.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_obb_point ()

Point-oriented box collision.

bool_t
col2d_obb_pointf(const OBB2Df *obb,
                 const V2Df *pnt,
                 Col2Df *col);

bool_t
col2d_obb_pointd(const OBB2Dd *obb,
                 const V2Dd *pnt,
                 Col2Dd *col);

bool_t
Col2D::obb_point(const OBB2D *obb,
                 const V2D *pnt,
                 Col2D *col);
obb

Oriented box.

pnt

Point.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_obb_segment ()

Segment-oriented box collision.

bool_t
col2d_obb_segmentf(const OBB2Df *obb,
                   const Seg2Df *seg,
                   Col2Df *col);

bool_t
col2d_obb_segmentd(const OBB2Dd *obb,
                   const Seg2Dd *seg,
                   Col2Dd *col);

bool_t
Col2D::obb_segment(const OBB2D *obb,
                   const Seg2D *seg,
                   Col2D *col);
obb

Oriented box.

seg

Segment.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_obb_circle ()

Collision-oriented box-circle.

bool_t
col2d_obb_circlef(const OBB2Df *obb,
                  const Cir2Df *cir,
                  Col2Df *col);

bool_t
col2d_obb_circled(const OBB2Dd *obb,
                  const Cir2Dd *cir,
                  Col2Dd *col);

bool_t
Col2D::obb_circle(const OBB2D *obb,
                  const Cir2D *cir,
                  Col2D *col);
obb

Oriented box.

cir

Circle.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_obb_box ()

Box-oriented box collision.

bool_t
col2d_obb_boxf(const OBB2Df *obb,
               const Box2Df *box,
               Col2Df *col);

bool_t
col2d_obb_boxd(const OBB2Dd *obb,
               const Box2Dd *box,
               Col2Dd *col);

bool_t
Col2D::obb_box(const OBB2D *obb,
               const Box2D *box,
               Col2D *col);
obb

Oriented box.

box

Aligned box.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_obb_obb ()

Oriented Box-Oriented Box collision.

bool_t
col2d_obb_obbf(const OBB2Df *obb1,
               const OBB2Df *obb2,
               Col2Df *col);

bool_t
col2d_obb_obbd(const OBB2Dd *obb1,
               const OBB2Dd *obb2,
               Col2Dd *col);

bool_t
Col2D::obb_obb(const OBB2D *obb1,
               const OBB2D *obb2,
               Col2D *col);
obb1

First oriented box.

obb2

Second oriented box.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_poly_point ()

Polygon-point collision.

bool_t
col2d_poly_pointf(const Pol2Df *pol,
                  const V2Df *pnt,
                  Col2Df *col);

bool_t
col2d_poly_pointd(const Pol2Dd *pol,
                  const V2Dd *pnt,
                  Col2Dd *col);

bool_t
Col2D::poly_point(const Pol2D *pol,
                  const V2D *pnt,
                  Col2D *col);
pol

Polygon.

pnt

Point.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_poly_segment ()

Polygon-segment collision.

bool_t
col2d_poly_segmentf(const Pol2Df *pol,
                    const Seg2Df *seg,
                    Col2Df *col);

bool_t
col2d_poly_segmentd(const Pol2Dd *pol,
                    const Seg2Dd *seg,
                    Col2Dd *col);

bool_t
Col2D::poly_segment(const Pol2D *pol,
                    const Seg2D *seg,
                    Col2D *col);
pol

Polygon.

seg

Segment.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_poly_circle ()

Polygon-circle collision.

bool_t
col2d_poly_circlef(const Pol2Df *pol,
                   const Cir2Df *cir,
                   Col2Df *col);

bool_t
col2d_poly_circled(const Pol2Dd *pol,
                   const Cir2Dd *cir,
                   Col2Dd *col);

bool_t
Col2D::poly_circle(const Pol2D *pol,
                   const Cir2D *cir,
                   Col2D *col);
pol

Polygon.

cir

Circle.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_poly_box ()

Polygon-box collision.

bool_t
col2d_poly_boxf(const Pol2Df *pol,
                const Box2Df *cir,
                Col2Df *col);

bool_t
col2d_poly_boxd(const Pol2Dd *pol,
                const Box2Dd *cir,
                Col2Dd *col);

bool_t
Col2D::poly_box(const Pol2D *pol,
                const Box2D *cir,
                Col2D *col);
pol

Polygon.

cir

Box.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_poly_obb ()

Polygon-box collision.

bool_t
col2d_poly_obbf(const Pol2Df *pol,
                const OBB2Df *cir,
                Col2Df *col);

bool_t
col2d_poly_obbd(const Pol2Dd *pol,
                const OBB2Dd *cir,
                Col2Dd *col);

bool_t
Col2D::poly_obb(const Pol2D *pol,
                const OBB2D *cir,
                Col2D *col);
pol

Polygon.

cir

Oriented box.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.


col2d_poly_poly ()

Polygon-polygon collision.

bool_t
col2d_poly_polyf(const Pol2Df *pol1,
                 const Pol2Df *pol2,
                 Col2Df *col);

bool_t
col2d_poly_polyd(const Pol2Dd *pol1,
                 const Pol2Dd *pol2,
                 Col2Dd *col);

bool_t
Col2D::poly_poly(const Pol2D *pol1,
                 const Pol2D *pol2,
                 Col2D *col);
pol1

First polygon.

pol2

Second polygon.

col

Detailed data of the collision. It can be NULL if we don't need additional information.

Return

TRUE if the objects intersect, FALSE otherwise.

❮ Back
Next ❯