API reference
Class MathX
Namespace: MicroEngine
Assembly: MicroEngine.Kernel.dll
Guide: Graphics
Small numeric helpers that games repeatedly need for feel and motion.
public static class MathXInheritance
Methods
Approach(float, float, float)
Moves value toward target by at most step.
public static float Approach(float value, float target, float step)Parameters
value float
target float
step float
Returns
Approach(Vector2, Vector2, float)
Moves value toward target by at most step along the straight line.
public static Vector2 Approach(Vector2 value, Vector2 target, float step)Parameters
value Vector2
target Vector2
step float
Returns
Damp(float, float, float, float)
Frame-rate independent exponential smoothing; sharpness is per second.
public static float Damp(float current, float target, float sharpness, float dt)Parameters
current float
target float
sharpness float
dt float
Returns
Damp(Vector2, Vector2, float, float)
Frame-rate independent exponential smoothing of a point; sharpness is per second.
public static Vector2 Damp(Vector2 current, Vector2 target, float sharpness, float dt)Parameters
current Vector2
target Vector2
sharpness float
dt float
Returns
FloorDiv(float, int)
The index of the cell of width size that contains value, rounding toward negative infinity (so -1 is in cell -1).
public static int FloorDiv(float value, int size)Parameters
value float
size int
Returns
FromAngle(float, float)
A vector of length pointing at radians (0 = right, π/2 = down on screen).
public static Vector2 FromAngle(float radians, float length = 1)Parameters
radians float
length float
Returns
Lerp(float, float, float)
Linear interpolation: a at t = 0, b at 1. t is not clamped.
public static float Lerp(float a, float b, float t)Parameters
a float
b float
t float
Returns
PingPong(float, float)
Returns 0..1..0 over a period, useful for pulses and bobbing.
public static float PingPong(float time, float period)Parameters
time float
period float
Returns
Wave(float, float, float)
A sine wave: sin(time × frequency × 2π) × amplitude, with frequency in cycles per second.
public static float Wave(float time, float frequency, float amplitude = 1)Parameters
time float
frequency float
amplitude float