Agar
Agar 1.7 Manual

M_Rectangle2(3)

SYNOPSIS

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

DESCRIPTION

The M_Rectangle2 structure describes a rectangle in R2 in terms of four points:
typedef struct m_rectangle2 {
	M_Vector2 a, b, c, d;
} M_Rectangle2;

Similarly, M_Rectangle3 describes a rectangle in R3:
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)

M_Rectangle2 M_RectangleRead2 (AG_DataSource *ds)

M_Rectangle3 M_RectangleRead3 (AG_DataSource *ds)

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.

The M_RectangleRead[23]() and M_RectangleWrite[23]() functions read or write a rectangle structure from/to an AG_DataSource(3).

The macros M_RECTANGLE2_INITIALIZER() and M_RECTANGLE3_INITIALIZER() expand to static initializers for M_Rectangle2 and M_Rectangle3, respectively.

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.

SEE ALSO

AG_DataSource(3), AG_Intro(3), M_Circle(3), M_Geometry(3), M_Plane(3), M_Polygon(3), M_Rectangle(3), M_Sphere(3), M_Triangle(3), M_Vector(3)

HISTORY

The M_Rectangle structure first appeared in Agar 1.3.4.


ElectronTubeStore Csoft.net www.libAgar.org is © 2024 Julien Nadeau Carriere <vedge@csoft.net>.
Support LibAgar: www.patreon.com/libAgar.