9#include <aegis/manager.hpp>
10#include <aegis/ndsTypes.hpp>
11#include <aegis/types.hpp>
13#include <nds/arm9/math.h>
14#include <nds/arm9/trig_lut.h>
16class MathManager :
public ae::Manager,
public ae::Singleton<MathManager>
41 ae::q20_12_t
atan2(ae::q20_12_t y, ae::q20_12_t x);
52 ae::q20_12_t
atan(ae::q20_12_t y);
61 ae::q20_12_t
div(ae::q20_12_t num, ae::q20_12_t den);
69 ae::q20_12_t
sqrt(ae::q20_12_t v);
78 ae::q20_12_t
mod(ae::q20_12_t num, ae::q20_12_t den);
110 ae::q4_12_t
sin(ae::angle16_t angle);
118 ae::q4_12_t
sin(ae::q20_12_t radians);
126 ae::q4_12_t
cos(ae::angle16_t angle);
134 ae::q4_12_t
cos(ae::q20_12_t radians);
142 ae::q20_12_t
tan(ae::q20_12_t radians);
150 ae::angle16_t
asin(ae::q4_12_t ratio);
158 ae::angle16_t
acos(ae::q4_12_t ratio);
172 ae::q20_12_t x1, ae::q20_12_t y1, ae::q20_12_t z1, ae::q20_12_t x2, ae::q20_12_t y2, ae::q20_12_t z2);
182 ae::q20_12_t
lengthSq(ae::q20_12_t x, ae::q20_12_t y, ae::q20_12_t z);
192 ae::q20_12_t
length(ae::q20_12_t x, ae::q20_12_t y, ae::q20_12_t z);
202 void normalize(ae::q20_12_t& x, ae::q20_12_t& y, ae::q20_12_t& z);
244 ae::q20_12_t
lerp(ae::q20_12_t a, ae::q20_12_t b, ae::q20_12_t t);
254 int lerp(
int a,
int b, ae::q20_12_t t);
268 ae::q20_12_t
clamp(ae::q20_12_t v, ae::q20_12_t lo, ae::q20_12_t hi);
ae::q20_12_t clamp(ae::q20_12_t v, ae::q20_12_t lo, ae::q20_12_t hi)
Clamps a Q20.12 value to [lo, hi].
ae::q20_12_t lengthSq(ae::q20_12_t x, ae::q20_12_t y, ae::q20_12_t z)
Computes the squared length of a Q20.12 3D vector.
ae::q4_12_t cos(ae::angle16_t angle)
Cosine of a cyclic angle.
ae::q4_12_t sin(ae::angle16_t angle)
Sine of a cyclic angle.
ae::q20_12_t sqrt(ae::q20_12_t v)
Computes the square root of a Q20.12 value.
ae::q20_12_t ease(EaseMode mode, ae::q20_12_t t)
Applies an easing curve to a normalized time value.
ae::q20_12_t angleToRadians(ae::angle16_t angle)
Converts a cyclic angle to radians (Q20.12).
ae::angle16_t asin(ae::q4_12_t ratio)
Computes the arcsine of a ratio.
ae::angle16_t degreesToCyclicAngle(ae::q20_12_t degrees)
Converts an angle in degrees (Q20.12) to a cyclic angle.
ae::angle16_t acos(ae::q4_12_t ratio)
Computes the arccosine of a ratio.
ae::angle16_t radiansToAngle(ae::q20_12_t radians)
Converts an angle in radians (Q20.12).
void normalize(ae::q20_12_t &x, ae::q20_12_t &y, ae::q20_12_t &z)
Normalizes a Q20.12 3D vector in place.
ae::q20_12_t atan2(ae::q20_12_t y, ae::q20_12_t x)
Computes the angle (in radians) between the positive x-axis and (x, y).
ae::q20_12_t length(ae::q20_12_t x, ae::q20_12_t y, ae::q20_12_t z)
Computes the length of a Q20.12 3D vector.
ae::q20_12_t div(ae::q20_12_t num, ae::q20_12_t den)
Divides two Q20.12 values.
ae::q20_12_t tan(ae::q20_12_t radians)
Tangent, accepting radians (Q20.12).
ae::q20_12_t lerp(ae::q20_12_t a, ae::q20_12_t b, ae::q20_12_t t)
Linearly interpolates two Q20.12 values.
ae::q20_12_t atan(ae::q20_12_t y)
Computes the arctangent of a single ratio.
ae::q20_12_t randFrac()
Returns a uniformly distributed random fraction from 0 to 1.
u32 secondsToSamples(ae::q20_12_t seconds, u32 sampleRate)
Converts a Q20.12 seconds value to a sample count, avoiding overflow when seconds * sampleRate exceed...
EaseMode
Easing curves for fixed-point interpolation (t in [0, 1]).
ae::q20_12_t mod(ae::q20_12_t num, ae::q20_12_t den)
Computes the modulo of two Q20.12 values.
ae::q20_12_t dot(ae::q20_12_t x1, ae::q20_12_t y1, ae::q20_12_t z1, ae::q20_12_t x2, ae::q20_12_t y2, ae::q20_12_t z2)
Computes the dot product of two Q20.12 3D vectors.