Documentation Index
Fetch the complete documentation index at: https://mintlify.com/adi3120/Fazen2d/llms.txt
Use this file to discover all available pages before exploring further.
MathUtils is a small static utility class with a linear range mapping function and the mathematical constant pi. All members are static — no instance is needed. It is commonly used to convert between coordinate spaces, drive wave-based animations, and scale game values such as health or progress bars.
Header
Members
| Member | Type | Value / Signature | Description |
|---|---|---|---|
pi | static constexpr double | 3.141592653589793238 | Mathematical constant π |
Map | static float | Map(float value, float x1, float x2, float y1, float y2) | Linearly maps value from [y1, y2] to [x1, x2] (inverse of parameter-name convention) |
static constexpr double pi
A compile-time constant equal to 3.141592653589793238. Use it with std::sin, std::cos, or any formula that requires radians.
static float Map(float value, float x1, float x2, float y1, float y2)
Linearly scales value from the range [y1, y2] back to the range [x1, x2]. Despite the parameter naming convention suggesting a forward [x1,x2] → [y1,y2] mapping, the implementation computes the inverse direction. Values outside [y1, y2] are extrapolated linearly.
Map() Formula
The implementation computes slope m and intercept b from the x/y ranges, then solves the inverse:
b and simplifying:
value equals y1 the result is x1; when value equals y2 the result is x2.
Parameters
The input value to map. Treated as a point within or outside the
[y1, y2] range.The lower bound of the output range. Returned when
value equals y1.The upper bound of the output range. Returned when
value equals y2. Must not equal x1 (would produce a division by zero via slope m).The lower bound of the input range. When
value equals y1, the result is x1.The upper bound of the input range. When
value equals y2, the result is x2. Must not equal y1 (division by zero in the inverse step).Usage Examples
std::sin(t) is the input value drawn from the [y1, y2] range [-1, 1]. The output is scaled to the [x1, x2] range [5, 35], producing smooth oscillation between rows 5 and 35.