Arma Reforger Script API
Loading...
Searching...
No Matches
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 float DegreeToTrigoRadian (float value)
 Get a counter-clockwise radian angle value from clockwise angles.
 
static bool GetLinesIntersectionXZ (float x0, float y0, float angleRad0, float x1, float y1, float angleRad1, out float x, out float 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.
 

Static Protected Member Functions

static bool CartesianToPolar (float x, float y, out float angle, out float radius)
 Translates cartesian coordinates (x,y) into polar (angle and radius)
 

Detailed Description

SCR_Math2D Class.

Contains various scripted 2D math functions

Member Function Documentation

◆ CartesianToPolar()

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

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

Parameters
[in]x
[in]y
[out]anglein radian
[out]radius
Returns
true

◆ DegreeToTrigoRadian()

static float SCR_Math2D.DegreeToTrigoRadian ( float value)
static

Get a counter-clockwise radian angle value from clockwise angles.

Parameters
[in]valueangle in clockwise degrees
Returns
[0..Math.PI2[ counter-clockwise value

◆ GenerateRandomPoint()

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

Generates random point in given polygon.

Parameters
[in]polygonConsecutive floats give polygon in 2D (2 floats = Vector2)
[in]bbMinBounding box minimum corner
[in]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
[in]minRadiusAll generated points will be at least this far from center
[in]maxRadiusAll generated points will be at most this far from center
[in]centerPosition around which to generate. Vector2 XZ
[in]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 }.

Parameters
[in]points3D
[out]points2D

◆ 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
[in]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 } }

◆ GetLinesIntersectionXZ()

static bool SCR_Math2D.GetLinesIntersectionXZ ( float x0,
float y0,
float angleRad0,
float x1,
float y1,
float angleRad1,
out float x,
out float y )
static
Parameters
[in]x0
[in]y0
[in]angleRad0counter-clockwise radians, range does not matter (no need for [0..Math.PI2[)
[in]x1
[in]y1
[in]angleRad1counter-clockwise radians, range does not matter (no need for [0..Math.PI2[)
[out]x
[out]y
Returns
true on intersection, false otherwise

◆ GetMinMaxPolygon()

static bool SCR_Math2D.GetMinMaxPolygon ( notnull array< float > polygon,
out float minX,
out float maxX,
out float minY,
out float maxY )
static
Parameters
[in]polygon
[out]minX
[out]maxX
[out]minY
[out]maxY
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.

Parameters
[in]polygon
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
[in]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.

Parameters
[in]minX
[in]maxX
[in]minY
[in]maxY
[out]x
[out]y
Returns

◆ 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
[in]originX
[in]originY
[in]angleFromangle in radians from which we calculate random angle
[in]angleToangle in radians to which we calculate random angle
[in]radius
[out]x
[out]y
Returns

◆ 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)

Parameters
[in]polygonformat x0, y0, x1, y1 etc
Returns
true if the polygon has at least three valid points, false otherwise (two points only, or odd number of values)

◆ 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
[in]anglein radians
[in]radius
[out]x
[out]y
Returns
true

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