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_LINE(3) FreeBSD Library Functions Manual M_LINE(3)

M_LineAgar-Math line segment / half-line structure

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

The M_Line2 structure describes a line segment, an Euclidean vector or a half-line in R^2. An M_Line is defined by an origin point p, a normalized direction vector d and a real length t (which can be set to M_INFINITY in order to express a half-line). The structure is defined as:

typedef struct m_line2 {
	M_Vector2 p;
	M_Vector2 d;
	M_Real t;
} M_Line2;

Similarly, M_Line3 describes a line segment, an Euclidean vector or a half-line in R^3:

typedef struct m_line3 {
	M_Vector3 p;
	M_Vector3 d;
	M_Real t;
} M_Line3;

M_Line2
(M_Vector2 p, M_Vector2 d, M_Real t);


M_Line3
(M_Vector3 p, M_Vector3 d, M_Real t);


M_Line2
(M_Vector2 p1, M_Vector2 p2);


M_Line3
(M_Vector3 p1, M_Vector3 p2);


M_Line2
(AG_DataSource *ds);


M_Line3
(AG_DataSource *ds);


void
(AG_DataSource *ds, M_Line2 *L);


void
(AG_DataSource *ds, M_Line3 *L);


M_Line2
(M_Real px, M_Real py, M_Real nx, M_Real ny, M_Real t);


M_Line3
(M_Real px, M_Real py, M_Real pz, M_Real nx, M_Real ny, M_Real nz, M_Real t);

The functions () and M_LineFromPtDir3() return an M_Line2 or M_Line3 describing a line segment a specified origin point p, direction vector d (of unit-length) and length t. The endpoints of the line will be p and (p + d*t).

() and M_LineFromPts3() return a line segment from two specified endpoints p1 and p2.

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

The macros () and M_LINE3_INITIALIZER() expand to static initializers for M_Line2 and M_Line3, respectively.

M_Vector2
(M_Line2 L);


M_Vector2
(M_Line2 L);


M_Vector3
(M_Line3 L);


M_Vector3
(M_Line3 L);


void
(M_Line2 L, M_Vector2 *p1, M_Vector2 *p2);


void
(M_Line3 L, M_Vector3 *p1, M_Vector3 *p2);


void
(M_Line2 L);


void
(M_Line3 L);


M_Real
(M_Line2 L, M_Vector2 p);


M_Real
(M_Line2 L, M_Vector2 p);


M_Real
(M_Line3 L, M_Vector3 p);


M_Real
(M_Line2 L1, M_Line2 L2);


M_Real
(M_Line3 L1, M_Line3 L2);


M_Line2
(M_Line2 L, M_Real offset);


M_Line3
(M_Line3 L, M_Real offset);


M_Line2
(M_Line3 L);


M_Line3
(M_Line2 L);


int
(M_Line2 L1, M_Line2 L2, M_Vector2 *x);


int
(M_Line3 L1, M_Line3 L2, M_Line3 *Ls);

The () routines return the initial point (i.e., the p vector). () routines return the terminal point (i.e., p + d*t). The () functions return the two endpoints of line L into p1 and p2.

() and M_LineIsRay3() evaluate to 1 of the line is defined as a half-line (i.e., t is M_INFINITY).

() tests whether point p lies on the left (<0), is coincident (==0), or is on the right (>0) of the line L. The direction is determined by the handedness of the line.

The () and M_LinePointDistance3() routines compute the minimal distance between a line L and a point p.

() and M_LineLineAngle3() return the counterclockwise angle (in radians) between L1 and L2. The angle is computed as the arc cosine of the dot product of the direction vectors of the two lines.

The () functions return a line parallel to L, with the specified offset amount. The direction of the offset is determined by the handedness of L.

() computes a line in R^2 from the projection onto the X-Y plane of a specified line in R^3. M_LineProject3() returns the projection of a line in R^2 onto the X-Y plane in R^3.

The () function computes the intersection point x of two lines in R^2. If there is a solution, the function returns 1, otherwise it returns 0.

The () function computes the shortest line segment Ls connecting two lines in R^3. Returns 1 if there is a solution, 0 if there is not.

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)

The M_Line 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.