GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
M_POLYGON(3) FreeBSD Library Functions Manual M_POLYGON(3)

M_PolygonAgar-Math polygon structure

#include <agar/core.h>
#include <agar/gui.h>
#include <agar/math/m.h>

The M_Polygon structure describes a simple polygon. The polygon may be convex or concave. Self-intersections and holes are not allowed.

typedef struct m_polygon {
	M_Vector2 *v;	/* Vertices */
	Uint n;		/* Vertex count */
} M_Polygon;

void
(M_Polygon *P);


M_Polygon
(void);


void
(M_Polygon *P);


M_Polygon
(Uint n, const M_Vector2 *v);


M_Polygon
(const M_PointSet2 *ps);


M_Polygon
(const M_PointSet2i *ps);


M_Polygon
(Uint n, const M_Line2 *L);


M_PointSet2
(const M_Polygon *P);


M_PointSet2i
(const M_Polygon *P, M_Real w, M_Real h);


M_Polygon
(AG_DataSource *ds);


void
(AG_DataSource *ds, const M_Polygon *P);

The () function initializes a M_Polygon structure. The M_POLYGON_INITIALIZER() macro may also be used as a static initializer.

The () function releases the memory allocated for vertices.

The () function returns a polygon structure given an array of points. The () 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 () and M_PolygonToPointSet2i() routines convert a M_Polygon to a M_PointSet2 or M_PointSet2i structure.

The () and M_PolygonWrite() functions read or write a polygon structure from/to an AG_DataSource(3).

int
M_PolygonAddVertex(M_Polygon *P, M_Vector2 v);


int
(M_Polygon *P, M_Line2 L);


int
(M_Polygon *P, int v);


int
(M_Polygon *Pdst, const M_Polygon *Psrc);


void
(M_Polygon *P, M_Real xScale, M_Real yScale);


void
(M_Polygon *P, M_Real xOffs, M_Real yOffs);


int
(const M_Polygon *P, M_Vector2 p);


int
(const M_Polygon *P);

The () 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.

() removes the vertex at given index v.

The () 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.

() multiplies all vertices of a polygon with the given scaling factors xScale, yScale. M_PolygonOffset() translates all vertices against xOffs, yOffs.

The () function returns 1 if the point p lies inside the polygon.

() returns 1 if the polygon is convex.

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)

The M_Polygon structure first appeared in Agar 1.3.4.

December 21, 2022 Agar 1.7

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.