Arma Reforger Script API
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
SCR_Math2D Interface Reference

SCR_Math2D Class. More...

Static Public Member Functions

static void Get2DPolygon (notnull array< vector > points3D, out notnull array< float > points2D)
 Get 2D points array from vector array, format { x1,y1, x2,y2, x3,y3 }.
 
static void Get3DPolygon (notnull array< float > points2D, out notnull array< vector > points3D)
 Get an array of vectors from 2D array with 0 for Y value.
 
static bool GetMinMaxPolygon (notnull array< float > polygon, out float minX, out float maxX, out float minY, out float maxY)
 
static float GetPolygonArea (notnull array< float > polygon)
 Get provided polygon's area.
 
static bool GetRandomPointInPolygon (notnull array< float > polygon, out float x, out float y)
 Get a random point within the provided 2D polygon.
 
static bool GetRandomPointInRectangle (float minX, float maxX, float minY, float maxY, out float x, out float y)
 Get a random point in the provided rectangle.
 
static bool GetRandomPointInSector (float originX, float originY, float angleFrom, float angleTo, float radius, out float x, out float y)
 Get a random point in the provided circular sector - uniform distribution.
 
static bool IsPolygonValid (notnull array< float > polygon)
 Checks the amount of points for a 2D polygon (needs 3 points to make a polygon and an even amount of values to have valid points)
 
static bool PolarToCartesian (float angle, float radius, out float x, out float y)
 Translates polar coordinates (angle and radius) into cartesian (x,y)
 
static vector GenerateRandomPoint (array< float > polygon, vector bbMin, vector bbMax)
 Generates random point in given polygon.
 
static vector GenerateRandomPointInRadius (float minRadius, float maxRadius, vector center, bool uniform=true)
 Generates a random point around center in range min/max radius.
 

Detailed Description

SCR_Math2D Class.

Contains various scripted 2D math functions

Member Function Documentation

◆ GenerateRandomPoint()

static vector SCR_Math2D.GenerateRandomPoint ( array< float >  polygon,
vector  bbMin,
vector  bbMax 
)
static

Generates random point in given polygon.

Parameters
polygonConsecutive floats give polygon in 2D (2 floats = Vector2)
bbMinBounding box minimum corner
bbMaxBounding box maximum corner
Returns
Vector3 point in polygon

◆ GenerateRandomPointInRadius()

static vector SCR_Math2D.GenerateRandomPointInRadius ( float  minRadius,
float  maxRadius,
vector  center,
bool  uniform = true 
)
static

Generates a random point around center in range min/max radius.

Parameters
minRadiusAll generated points will be at least this far from center
maxRadiusAll generated points will be at most this far from center
centerPosition around which to generate. Vector2 XZ
uniformIf false, has a small bias towards the center which may be desirable in some situations
Returns
Vector2 XZ set, Y = 0

◆ Get2DPolygon()

static void SCR_Math2D.Get2DPolygon ( notnull array< vector >  points3D,
out notnull array< float >  points2D 
)
static

Get 2D points array from vector array, format { x1,y1, x2,y2, x3,y3 }.

◆ Get3DPolygon()

static void SCR_Math2D.Get3DPolygon ( notnull array< float >  points2D,
out notnull array< vector >  points3D 
)
static

Get an array of vectors from 2D array with 0 for Y value.

Parameters
points2D
[out]points3D
Returns
array of vector where Y is set to zero, e.g { x0, y0, x1, y1 } = { { x0, 0, y0 }, { x1, 0, y1 } }

◆ GetMinMaxPolygon()

static bool SCR_Math2D.GetMinMaxPolygon ( notnull array< float >  polygon,
out float  minX,
out float  maxX,
out float  minY,
out float  maxY 
)
static
Returns
true on success, otherwise false (e.g invalid polygon)

◆ GetPolygonArea()

static float SCR_Math2D.GetPolygonArea ( notnull array< float >  polygon)
static

Get provided polygon's area.

Returns
-1 on invalid polygon, otherwise the polygon's surface

◆ GetRandomPointInPolygon()

static bool SCR_Math2D.GetRandomPointInPolygon ( notnull array< float >  polygon,
out float  x,
out float  y 
)
static

Get a random point within the provided 2D polygon.

Parameters
polygon
[out]xfound point's x coordinates
[out]yfound point's x coordinates
Returns
true on success, false otherwise

◆ GetRandomPointInRectangle()

static bool SCR_Math2D.GetRandomPointInRectangle ( float  minX,
float  maxX,
float  minY,
float  maxY,
out float  x,
out float  y 
)
static

Get a random point in the provided rectangle.

◆ GetRandomPointInSector()

static bool SCR_Math2D.GetRandomPointInSector ( float  originX,
float  originY,
float  angleFrom,
float  angleTo,
float  radius,
out float  x,
out float  y 
)
static

Get a random point in the provided circular sector - uniform distribution.

Parameters
angleFromangle in radians from which we calculate random angle
angleToangle in radians to which we calculate random angle

◆ IsPolygonValid()

static bool SCR_Math2D.IsPolygonValid ( notnull array< float >  polygon)
static

Checks the amount of points for a 2D polygon (needs 3 points to make a polygon and an even amount of values to have valid points)

◆ PolarToCartesian()

static bool SCR_Math2D.PolarToCartesian ( float  angle,
float  radius,
out float  x,
out float  y 
)
static

Translates polar coordinates (angle and radius) into cartesian (x,y)

Parameters
anglein radians
radius
[out]x
[out]y

The documentation for this interface was generated from the following file: