Cross-platform C SDK logo

Cross-platform C SDK

2D Boxes

❮ 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

Box2Dbox2d (...)
Box2Dbox2d_from_points (...)
V2Dbox2d_center (...)
voidbox2d_add (...)
voidbox2d_addn (...)
voidbox2d_add_circle (...)
voidbox2d_merge (...)
voidbox2d_segments (...)
realbox2d_area (...)
bool_tbox2d_is_null (...)

Types and Constants

Box2DkNULL

2D containers or (Bounding boxes) delimit the area of the plane occupied by different geometric elements (Figure 1). They are useful in the collision detection or clipping operations, which prevent non-visible figures from being drawn, improving overall performance.

  • Use box2d_from_pointsf to create a 2D box from a set of points.
  • Use box2d_addnf to change dimensions based on new points.
  • Use box2d_segmentsf to get the four segments that delimit the box.
  • Drawing of a plan where a 2D container appears that integrates several figures.
    Figure 1: 2D boxes as a container for other objects.

kNULL

const Box2Df kBOX2D_NULLf;

const Box2Dd kBOX2D_NULLd;

const Box2D Box2D::kNULL;

Represents a null box (without geometry).


box2d ()

Create a new box with the indicated limits.

Box2Df
box2df(const real32_t minX,
       const real32_t minY,
       const real32_t maxX,
       const real32_t maxY);

Box2Dd
box2dd(const real64_t minX,
       const real64_t minY,
       const real64_t maxX,
       const real64_t maxY);

Box2D
Box2D(const real minX,
      const real minY,
      const real maxX,
      const real maxY);
minX

The lower limit on X.

minY

The lower limit on Y.

maxX

The upper limit on X.

maxY

The upper limit on Y.

Return

The newly created box.


box2d_from_points ()

Create a new box containing a set of points.

Box2Df
box2d_from_pointsf(const V2Df *p,
                   const uint32_t n);

Box2Dd
box2d_from_pointsd(const V2Dd *p,
                   const uint32_t n);

Box2D
Box2D::from_points(const V2D *p,
                   const uint32_t n);
p

2d point vector.

n

Number of points in vector.

Return

The newly created box.


box2d_center ()

Returns the center point.

V2Df
box2d_centerf(const Box2Df *box);

V2Dd
box2d_centerd(const Box2Dd *box);

V2D
Box2D::center(const Box2D *box);
box

The container.

Return

Center coordinates.


box2d_add ()

Expand the dimensions of the box to contain the entry point. If the point is already within its area, the box is not modified.

void
box2d_addf(Box2Df *box,
           const V2Df *p);

void
box2d_addd(Box2Dd *box,
           const V2Dd *p);

void
Box2D::add(Box2D *box,
           const V2D *p);
box

The container.

p

The point to include.


box2d_addn ()

Expand the dimensions of the box to contain several points. It is equivalent to calling the method box2d_addf successively.

void
box2d_addnf(Box2Df *box,
            const V2Df *p,
            const uint32_t n);

void
box2d_addnd(Box2Dd *box,
            const V2Dd *p,
            const uint32_t n);

void
Box2D::addn(Box2D *box,
            const V2D *p,
            const uint32_t n);
box

The container.

p

Vector points to include.

n

Number of points.


box2d_add_circle ()

Expand the dimensions of the container to accommodate a circle.

void
box2d_add_circlef(Box2Df *box,
                  const Cir2Df *cir);

void
box2d_add_circled(Box2Dd *box,
                  const Cir2Dd *cir);

void
Box2D::add_circle(Box2D *box,
                  const Cir2D *cir);
box

The container.

cir

Circle.


box2d_merge ()

Expand the dimensions of dest to contain src.

void
box2d_mergef(Box2Df *dest,
             const Box2Df *src);

void
box2d_merged(Box2Dd *dest,
             const Box2Dd *src);

void
Box2D::merge(Box2D *dest,
             const Box2D *src);
dest

The container that will be expanded.

src

The container that must be added.


box2d_segments ()

Gets the four segments that make up the box.

void
box2d_segmentsf(const Box2Df *box,
                Seg2Df *segs);

void
box2d_segmentsd(const Box2Dd *box,
                Seg2Dd *segs);

void
Box2D::segments(const Box2D *box,
                Seg2D *segs);
box

The container.

segs

Array of at least four segments.


box2d_area ()

Gets the area of ​​the box.

real32_t
box2d_areaf(const Box2Df *box);

real64_t
box2d_aread(const Box2Dd *box);

real
Box2D::area(const Box2D *box);
box

The container.

Return

The area (width * height).


box2d_is_null ()

Check if a container is null (without any geometry inside).

bool_t
box2d_is_nullf(const Box2Df *box);

bool_t
box2d_is_nulld(const Box2Dd *box);

bool_t
Box2D::is_null(const Box2D *box);
box

The container.

Return

TRUE if is null, FALSE if contains any geometry.

❮ Back
Next ❯