# FreeBSD Manual Pages

```M_RECTANGLE(3)		 BSD Library Functions Manual		M_RECTANGLE(3)

NAME
M_Rectangle -- Agar-Math rectangle	structure

SYNOPSIS
#include <agar/math.h>

DESCRIPTION
The M_Rectangle2 structure	describes a rectangle in R^2 in	terms of four
points:

typedef struct m_rectangle2 {
M_Vector2 a, b, c,	d;
} M_Rectangle2;

Similarly,	M_Rectangle3 describes a rectangle in R^3:

typedef struct m_rectangle3 {
M_Vector3 a, b, c,	d;
} M_Rectangle3;

INITIALIZATION
M_Rectangle2 M_RectangleFromLines2(M_Line2	L1, M_Line2 L2)

M_Rectangle3 M_RectangleFromLines3(M_Line2	L1, M_Line2 L2,	M_Line2	L3)

M_Rectangle2 M_RectangleFromPts2(M_Vector2	a, M_Vector2 b)

M_Rectangle3 M_RectangleFromPts3(M_Vector3	a, M_Vector3 b,	M_Vector3 c)

void M_RectangleWrite2(AG_DataSource *ds, M_Rectangle2 *R)

void M_RectangleWrite3(AG_DataSource *ds, M_Rectangle3 *R)

M_Rectangle2 M_RECTANGLE2_INITIALIZER(M_Vector2 a,	M_Vector2 b, M_Vector2
c)

M_Rectangle3 M_RECTANGLE3_INITIALIZER(M_Vector3 a,	M_Vector3 b, M_Vector3
c)

The functions M_RectangleFromLines2() and M_RectangleFromLines3() return
an	M_Rectangle2 or	M_Rectangle3 describing	a rectangle in terms of	two or
three lines.

M_RectangleFromPts2() and M_RectangleFromPts3() return a rectangle	in
terms of two or three points.

write a rectangle structure from/to an AG_DataSource(3).

The macros	M_RECTANGLE2_INITIALIZER() and M_RECTANGLE3_INITIALIZER() ex-
pand to static initializers for M_Rectangle2 and M_Rectangle3, respec-
tively.

COMPUTATIONS
int M_PointInRectangle2(M_Rectangle2 R, M_Vector2 p)

M_Real M_RectangleWidth2(M_Rectangle2 R)

M_Real M_RectangleWidth2v(const M_Rectangle2 *R)

M_Real M_RectangleHeight2(M_Rectangle2 R)

M_Real M_RectangleHeight2v(const M_Rectangle2 *R)

M_Real M_RectangleWidth3(M_Rectangle3 R)

M_Real M_RectangleWidth3v(const M_Rectangle3 *R)

M_Real M_RectangleHeight3(M_Rectangle3 R)

M_Real M_RectangleHeight3v(const M_Rectangle3 *R)

The M_PointInRectangle2() routine tests whether point p lies inside the
rectangle R and returns 1 if it does, otherwise 0.

The M_RectangleWidth[23]()	and M_RectangleHeight[23]() routines return
the width and height of the rectangle.