LibCapy - geometricShape

Basic geometric shape classes.

Macros:

Definition of the parent class for 2D geometric shapes Destructor void (*destruct)(void);

Get the area of the geometry

Output and side effect(s):

Return the area double (*getArea)(void);

Get the perimeter of the geometry

Output and side effect(s):

Return the perimeter double (*getPerimeter)(void);

Convert the geometry into a Bezier spline

Output and side effect(s):

Return the Bezier spline approximating the geometry. CapyBezierSpline (*getBezierSpline)(void);

Enumerations:

None.

Typedefs:

Parent class for 2D geometric shapes

Struct CapyPoint2D :

Struct CapyPoint2D's properties:

Location of the corner

Struct CapyPoint2D's methods:

None.

Struct CapySegment :

Struct CapySegment's properties:

Inherits CapyGeometry2D

Array of two positions, the locations of the segment extremities.

Struct CapySegment's methods:

Destructor

Struct CapyTriangle :

Struct CapyTriangle's properties:

Inherits CapyGeometry2D

Array of three positions, the locations of the triangle's corners.

Struct CapyTriangle's methods:

Destructor

Get the barycentric coordinates of a position relative to the triangle

Input argument(s):

pos: the position
coord: the barycentric coordinates

Output and side effect(s):

'coord' is updated. If at least one of the three barycentric coordinates is negative, the position is outside the triangle. Barycentric coordinates in [-inf, 1].

Struct CapyQuadrilateral :

Struct CapyQuadrilateral's properties:

Inherits CapyGeometry2D

Array of four positions, the location of the quadrilateral's corners, in clockwise order.

Struct CapyQuadrilateral's methods:

Destructor

Get the bilinear coordinates of a point in the quadrilateral from its coordinates in world coordinate system

Input argument(s):

pos: the position in world coordinate system
coords: double[2] updated with the bilinear coordinates

Struct CapyRectangle :

Struct CapyRectangle's properties:

Inherits CapyGeometry2D

Array of two positions, the location of the quadrilateral's corners (such as corners[0].x < corners[1].x and corners[0].y < corners[1].y).

Struct CapyRectangle's methods:

Destructor

Struct CapyCircle :

Struct CapyCircle's properties:

Inherits CapyGeometry2D

Center

Radius

Struct CapyCircle's methods:

Destructor

Functions:

Create a CapyGeometry2D

Output and side effect(s):

Return a CapyGeometry2D

Create a CapySegment

Output and side effect(s):

Return a CapySegment, points initialised to ((0, 0), (0, 1))

Allocate memory for a new CapySegment and create it

Output and side effect(s):

Return a CapySegment, points initialised to ((0, 0), (0, 1))

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by a CapySegment* and reset '*that' to NULL

Input argument(s):

that: a pointer to the CapySegment to free

Create a CapyTriangle

Output and side effect(s):

Return a CapyTriangle, corners initialised to ((0, 0), (0, 1), (1, 0))

Allocate memory for a new CapyTriangle and create it

Output and side effect(s):

Return a CapyTriangle, corners initialised to ((0, 0), (0, 1), (1, 0))

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by a CapyTriangle* and reset '*that' to NULL

Input argument(s):

that: a pointer to the CapyTriangle to free

Create a CapyQuadrilateral

Output and side effect(s):

Return a CapyQuadrilateral, corners initialised to ((0, 0), (0, 1), (1, 1), (1, 0))

Allocate memory for a new CapyQuadrilateral and create it

Output and side effect(s):

Return a CapyQuadrilateral, corners initialised to ((0, 0), (0, 1), (1, 1), (1, 0))

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by a CapyQuadrilateral* and reset '*that' to NULL

Input argument(s):

that: a pointer to the CapyQuadrilateral to free

Create a CapyRectangle

Output and side effect(s):

Return a CapyRectangle, corners initialised to ((0, 0), (0, 1), (1, 1), (1, 0))

Allocate memory for a new CapyRectangle and create it

Output and side effect(s):

Return a CapyRectangle, corners initialised to ((0, 0), (0, 1), (1, 1), (1, 0))

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by a CapyRectangle* and reset '*that' to NULL

Input argument(s):

that: a pointer to the CapyRectangle to free

Create a CapyCircle

Output and side effect(s):

Return a CapyCircle, center initialised to (0, 0) and radius initialised to 1.

Allocate memory for a new CapyCircle and create it

Output and side effect(s):

Return a CapyCircle, center initialised to (0, 0) and radius initialised to 1.

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by a CapyCircle* and reset '*that' to NULL

Input argument(s):

that: a pointer to the CapyCircle to free

2022-06-21
in LibCapy,
27 views
Copyright 2021-2024 Baillehache Pascal