Module extender_math

A math extender module for Micro2D.

Info:

  • Author: Sharper Dev

Functions

MathE.lerp (a, b, t) Linearly interpolates from a to b using the factor t.
MathE.checkAABBPoint (rectX, rectY, rectW, rectH, pointX, pointY) Tests whether a point lies inside or on the boundary of an axis-aligned rectangle.
MathE.checkAABBRect (rectX1, rectY1, rectW1, rectH1, rectX2, rectY2, rectW2, rectH2) Tests whether two axis-aligned rectangles overlap or touch at an edge.


Functions

MathE.lerp (a, b, t)
Linearly interpolates from a to b using the factor t. Values of t outside [0, 1] extrapolate beyond the endpoints.

Parameters:

  • a number Starting value.
  • b number Ending value.
  • t number Interpolation factor.

Returns:

    number

Usage:

    local result = MathE.lerp(0, 100, 0.5) -- result is 50
MathE.checkAABBPoint (rectX, rectY, rectW, rectH, pointX, pointY)
Tests whether a point lies inside or on the boundary of an axis-aligned rectangle.

Parameters:

  • rectX number Rectangle's left coordinate.
  • rectY number Rectangle's top coordinate.
  • rectW number Rectangle width.
  • rectH number Rectangle height.
  • pointX number Point's horizontal coordinate.
  • pointY number Point's vertical coordinate.

Returns:

    boolean inside True if the point is within the rectangle.

Usage:

    local inside = MathE.checkAABBPoint(0, 0, 100, 100, 50, 50) -- inside is true
MathE.checkAABBRect (rectX1, rectY1, rectW1, rectH1, rectX2, rectY2, rectW2, rectH2)
Tests whether two axis-aligned rectangles overlap or touch at an edge.

Parameters:

  • rectX1 number First rectangle's left coordinate.
  • rectY1 number First rectangle's top coordinate.
  • rectW1 number First rectangle's width.
  • rectH1 number First rectangle's height.
  • rectX2 number Second rectangle's left coordinate.
  • rectY2 number Second rectangle's top coordinate.
  • rectW2 number Second rectangle's width.
  • rectH2 number Second rectangle's height.

Returns:

    boolean intersects True if the rectangles overlap or touch.

Usage:

    local intersects = MathE.checkAABBRect(0, 0, 100, 100, 50, 50, 100, 100) -- intersects is true
generated by LDoc 1.5.0 Last updated 2026-10-04 12:53:32