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);

Maximum number of intersecting points in a CapyGeometry2DIntersection

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

Get an arc of the circle as a Bezier spline

Input argument(s):

pointA: the beginning of the arc
pointB: the end of the arc

Output and side effect(s):

Return a Bezier spine approximating the arc from 'pointA' to 'pointB' counter-clockwise. If the points are not on the circle, their projection on the circle is used instead.

Struct CapyGeometry2DIntersection :

Struct CapyGeometry2DIntersection's properties:

Number of intersection point

Intersection points

Struct CapyGeometry2DIntersection's methods:

Destructor

Get the intersecting point between two segments Inputs: segmentA: first segment segmentB: second segment flagStrict: flag to restrict to the intersection inside the segments

Output and side effect(s):

Update the intersection points of 'segmentA' and 'segmentB'

Get the intersecting point(s) between two circles Inputs: circleA: first circle circleB: second circle

Output and side effect(s):

Output and side effect(s):

Update the intersection points of 'circleA' and 'circleB'. Points are ordered counter-clockwise on 'circleA' from the intersection of the segment connecting the center the circles

Get the intersecting point(s) between a segment and a circle Inputs: seg: the segment circle: the circle flagStrict: flag to restrict to the intersection inside the segment

Output and side effect(s):

Update the intersection points of 'seg' and 'circle'. Points are ordered according to the parameter 't' of the segment.

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

Create a CapyGeometry2DIntersection

Output and side effect(s):

Return a CapyGeometry2DIntersection initialised to 0

2022-06-21
in LibCapy,
56 views
Copyright 2021-2025 Baillehache Pascal