Cross-platform C SDK logo

Cross-platform C SDK

2D Polygons

❮ 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

Pol2D*pol2d_create (...)
Pol2D*pol2d_copy (...)
voidpol2d_destroy (...)
voidpol2d_update (...)
const V2D*pol2d_points (...)
const uint32_tpol2d_n (...)

Polygons are the most generic container volume that can best be adjusted to the shape of certain objects or point distributions (Figure 1).

Drawing a polygon on the plane.
Figure 1: 2D polygons.

pol2d_create ()

Create a new polygon.

Pol2Df*
pol2d_createf(const V2Df *points,
              const uint32_t n);

Pol2Dd*
pol2d_created(const V2Dd *points,
              const uint32_t n);

Pol2D*
Pol2D::create(const V2D *points,
              const uint32_t n);
points

List of points that make up the polygon.

n

Number of points.

Return

The polygon created.


pol2d_copy ()

Create a copy of the polygon.

Pol2Df*
pol2d_copyf(const Pol2Df *pol);

Pol2Dd*
pol2d_copyd(const Pol2Dd *pol);

Pol2D*
Pol2D::copy(const Pol2D *pol);
pol

The original polygon.

Return

The copy.


pol2d_destroy ()

Destroy the polygon.

void
pol2d_destroyf(Pol2Df **pol);

void
pol2d_destroyd(Pol2Dd **pol);

void
Pol2D::destroy(Pol2D **pol);
pol

The polygon. Will be set to NULL after destruction.


pol2d_update ()

Updates the position of the points that make up the polygon.

void
pol2d_updatef(Pol2Df *pol,
              const V2Df *points);

void
pol2d_updated(Pol2Dd *pol,
              const V2Dd *points);

void
Pol2D::update(Pol2D *pol,
              const V2D *points);
pol

The polygon to update.

points

The new positions of the points.

Remarks

The number of points must be the same as that used in the constructor pol2d_createf.


pol2d_points ()

Gets the vertices that make up the polygon.

const V2Df*
pol2d_pointsf(const Pol2Df *pol);

const V2Dd*
pol2d_pointsd(const Pol2Dd *pol);

const V2D*
Pol2D::points(const Pol2D *pol);
pol

The polygon.

Return

Pointer to an array of vertices.

Remarks

Do not modify the returned array. Copy if necessary.


pol2d_n ()

Gets the number of vertices that make up the polygon.

const uint32_t
pol2d_nf(const Pol2Df *pol);

const uint32_t
pol2d_nd(const Pol2Dd *pol);

const uint32_t
Pol2D::n(const Pol2D *pol);
pol

The polygon.

Return

The number of vertices.

Remarks

It is the same value as the one used in the constructor pol2d_createf.

❮ Back
Next ❯