SYNOPSIS
|
DESCRIPTION
![]()
|
INITIALIZATION
The M_PolygonInit() function initializes a M_Polygon structure. The M_POLYGON_INITIALIZER() macro may also be used as a static initializer. The M_PolygonFree() function releases the memory allocated for vertices. The M_PolygonFromPts() function returns a polygon structure given an array of points. The M_PolygonFromPointSet() variant accepts a M_PointSet2(3) argument. M_PolygonFromLines() returns a polygon from an array of lines L. n is the number of elements in the array. The M_PolygonToPointSet2() and M_PolygonToPointSet2i() routines convert a M_Polygon to a M_PointSet2 or M_PointSet2i structure. The M_PolygonRead() and M_PolygonWrite() functions read or write a polygon structure from/to an AG_DataSource(3). |
OPERATIONS
The M_PolygonAddVertex() function adds a new vertex to a polygon. Returns index of new vertex on success, -1 on failure. The M_PolygonAddLine() variant accepts a M_Line(3) argument instead of a vector. M_PolygonDelVertex() removes the vertex at given index v. The M_PolygonCopy() function copies the vertices of a source polygon Psrc to a destination polygon Pdst. The destination structure does not need to be initialized. Any existing vertices in Pdst will be overwritten. The function returns 0 on success or -1 if insufficient memory is available. M_PolygonScale() multiplies all vertices of a polygon with the given scaling factors xScale, yScale. M_PolygonOffset() translates all vertices against xOffs, yOffs. The M_PointInPolygon() function returns 1 if the point p lies inside the polygon. M_PolygonIsConvex() returns 1 if the polygon is convex. |
SEE ALSO
AG_DataSource(3), AG_Intro(3), M_Circle(3), M_Geometry(3), M_Plane(3), M_PointSet(3), M_Polygon(3), M_Rectangle(3), M_Sphere(3), M_Triangle(3), M_Vector(3) |
HISTORY
The M_Polygon structure first appeared in Agar 1.3.4. |