Skip to main content

Math

Math library.

Functions

LineIntersection

Math.LineIntersection(
a1: Vector2,
a2: Vector2,
b1: Vector2,
b2: Vector2
) boolean

ArgumentTypeDescription
a1Vector2Line 1 start.
a2Vector2Line 1 end.
b1Vector2Line 2 start.
b2Vector2Line 2 end.

Returns if Line1 and Line2 have Intersection.


LineSegmentIntersection

Math.LineSegmentIntersection(
a1: Vector2,
a2: Vector2,
b1: Vector2,
b2: Vector2
) boolean

ArgumentTypeDescription
a1Vector2Segment 1 start.
a2Vector2Segment1 end.
b1Vector2Segment2 start.
b2Vector2Segment2 end.

Returns if Line1 and Line2 have Intersection.


FastSqrt

Math.FastSqrt( value: number - float ) number

ArgumentTypeDescription
valuenumber - floatNumber for sqrt.

Returns sqrt result.


QuaternionRotation

Math.QuaternionRotation(
yaw: number - float,
pitch: number - float,
roll: number - float
) Vector4

ArgumentTypeDescription
yawnumber - floatYaw
pitchnumber - floatPitch
rollnumber - floatAngle

Returns Quaternion Rotation Vector4.


Vector4

Math.Vector4(
x: number - float,
y: number - float,
z: number - float,
w: number - float
) Vector4

ArgumentTypeDescription
xnumber - floatx
ynumber - floaty
znumber - floatz
wnumber - floatw

Returns Vector4.


Vector3

Math.Vector3(
x: number - float,
y: number - float,
z: number - float
) Vector3

ArgumentTypeDescription
xnumber - floatx
ynumber - floaty
znumber - floatz

Returns Vector3.


Vector2

Math.Vector2( x: number - float, y: number - float ) Vector2

ArgumentTypeDescription
xnumber - floatx
ynumber - floaty

Returns Vector2.


CatmullRom

Math.CatmullRom(
a: Vector2,
b: Vector2,
c: Vector2,
d: Vector2,
t: number - float
) Vector2

ArgumentTypeDescription
aVector2a
bVector2b
cVector2c
dVector2d
tnumber - floatWeighting factor.

Returns the result of the Catmull-Rom interpolation.


GetAngle

Math.GetAngle(
a: Vector2,
b: Vector2,
c: Vector2
) number

ArgumentTypeDescription
aVector2PA
bVector2PB
cVector2PC

Returns angle between ba and bc.


GetAngleDeg

Math.GetAngleDeg(
a: Vector2,
b: Vector2,
c: Vector2
) number

ArgumentTypeDescription
aVector2PA
bVector2PB
cVector2PC

Returns angle degree between ba and bc (0-180).


GetFullAngleDeg

Math.GetFullAngleDeg(
a: Vector2,
b: Vector2,
c: Vector2
) number

ArgumentTypeDescription
aVector2PA
bVector2PB
cVector2PC

Returns angle degree between ba and bc (-180-180).


LineSegmentIntersection

Math.LineSegmentIntersection(
a: Vector2,
b: Vector2,
c: Vector2,
d: Vector2
) boolean, Vector2

ArgumentTypeDescription
aVector2Line 1 start.
bVector2Line 1 end.
cVector2Line 2 start
dVector2Line 2 end.

Returns true if line segment 1 and line segment2 has intersection and intersection point(if false ,defalut return point a).


CircleLineIntersection

Math.CircleLineIntersection(
a: Vector2,
b: Vector2,
c: Vector2,
radius: number,
onlySegment: boolean
) [Vector2], [Vector2]

ArgumentTypeDescription
aVector2Line start.
bVector2Line end.
cVector2Center.
radiusnumberCircle radius.
onlySegmentbooleanOnly check ab as line segment.

Returns two Intersection points if exist or else reutrns nil.


BuildCircle

Math.BuildCircle(
center: Vector2,
radius: number,
quality: number
) Vector2[]

ArgumentTypeDescription
centerVector2Center.
radiusnumberCircle radius.
qualitynumberCircle sides.

Returns circle points table.


BuildSafeCircle

Math.BuildSafeCircle(
center: Vector2,
radius: number,
sides: number,
bSafeOffset: boolean
) Vector2[] - std::vector<Vector2>

ArgumentTypeDescription
centerVector2Center position.
radiusnumberCircle radius.
sidesnumberCircle sides.
bSafeOffsetbooleanApply safe offset.

Returns safe circle points.


Deg2Rad

Math.Deg2Rad( degrees: number ) number - float

ArgumentTypeDescription
degreesnumber(float)

Convert degrees to radians


Rad2Deg

Math.Rad2Deg( radians: number ) number - float

ArgumentTypeDescription
radiansnumber(float)

Convert radians to degrees


ToDX2D

Math.ToDX2D(
vec: Vector2
) D3DXVECTOR2

ArgumentTypeDescription
vecVector2

Convert Vector2 to D3DXVECTOR2


ToDX2D

Math.ToDX2D(
vec: Vector3
) D3DXVECTOR2

ArgumentTypeDescription
vecVector3

Convert Vector3 to D3DXVECTOR2


ToDX3D

Math.ToDX3D(
vec: Vector3
) D3DXVECTOR3

ArgumentTypeDescription
vecVector3

Convert Vector3 to D3DXVECTOR3


GetDirectionFromOrientation

Math.GetDirectionFromOrientation(
obj: EffectEmitter
) Vector2

ArgumentTypeDescription
objEffectEmitter

Returns direction vector from orientation matrix (taken from given EffectEmitter).


GetDirectionFromOrientation

Math.GetDirectionFromOrientation( matrix: _D3DMATRIX ) Vector2

ArgumentTypeDescription
matrix_D3DMATRIX

Returns direction vector from orientation matrix.


InverseLerp

Math.InverseLerp(
A: Vector2,
B: Vector2,
C: Vector2
) number - float

ArgumentTypeDescription
AVector2Start position
BVector2End position
CVector2Result position from normal Lerp/Extension

Performs reverse linear interpolation and returns float time value.


IsCollinearLines

Math.IsCollinearLines(
A: Vector2,
B: Vector2,
C: Vector2,
D: Vector2
) boolean

ArgumentTypeDescription
AVector2
BVector2
CVector2
DVector2

Returns whether AB and CD are collinear.


IsCollinearLines

Math.IsCollinearLines( AB: LineSegment, CD: LineSegment ) boolean

ArgumentTypeDescription
ABLineSegment
CDLineSegment

Returns whether AB and CD are collinear.


IsCollinearLines

Math.IsCollinearLines( AB: Line, CD: Line ) boolean

ArgumentTypeDescription
ABLine
CDLine

Returns whether AB and CD are collinear.


IsStraightLine

Math.IsStraightLine(
points: Vector2[],
deviation: number - float
) boolean

ArgumentTypeDescription
pointsVector2[]Given positions to check.
deviationnumber - floatDeviation. The closer to 0 the stricter this check is.

Returns whether given points form a straight line or not (within given deviation).


IsStraightLine

Math.IsStraightLine(
points: Vector3[],
deviation: number - float
) boolean

ArgumentTypeDescription
pointsVector3[]Given positions to check.
deviationnumber - floatDeviation. The closer to 0 the stricter this check is.

Returns whether given points form a straight line or not (within given deviation).


GetCentroid

Math.GetCentroid(
points: Vector2[]
) Vector2

ArgumentTypeDescription
pointsVector2[]Lua table of given Vector2 positions.

Returns calculated centroid from given positions.


GetCentroid

Math.GetCentroid(
points: Vector3[] - std::vector<Vector3>
) Vector2

ArgumentTypeDescription
pointsVector3[] - std::vector<Vector3>Given positions.

Returns calculated centroid from given positions.


GetEnemyCentroid

Math.GetEnemyCentroid(
position: Vector2,
range: number - float
) Vector2, number

ArgumentTypeDescription
positionVector2Given position.
rangenumber - floatGiven range.

Returns enemy centroid from enemies at given position within given range, and returns affected enemy count.


GetMEC

Math.GetMEC(
positions: Vector2[]
) Vector2, float

ArgumentTypeDescription
positionsVector2[]Lua table of given Vector2 positions.

Get Minimum Enclosing Circle (position and radius) from given Vector2 positions.


GetMEC

Math.GetMEC(
positions: Vector3[] - std::vector<Vector3>
) Vector2, float

ArgumentTypeDescription
positionsVector3[] - std::vector<Vector3>Given positions.

Get Minimum Enclosing Circle (position and radius) from given Vector3 positions.