|
persona-3-dual
A DS demake of Persona 3
|
#include <MathManager.hpp>


Public Types | |
| enum class | EaseMode { Linear , InQuad , OutQuad , InOutQuad , InCubic , OutCubic , InBack , OutBack } |
| Easing curves for fixed-point interpolation (t in [0, 1]). More... | |
Public Member Functions | |
| void | init () override |
| void | process () override |
| void | shutdown () override |
| 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 | atan (ae::q20_12_t y) |
| Computes the arctangent of a single ratio. | |
| ae::q20_12_t | div (ae::q20_12_t num, ae::q20_12_t den) |
| Divides two Q20.12 values. | |
| ae::q20_12_t | sqrt (ae::q20_12_t v) |
| Computes the square root of a Q20.12 value. | |
| ae::q20_12_t | mod (ae::q20_12_t num, ae::q20_12_t den) |
| Computes the modulo of two Q20.12 values. | |
| ae::angle16_t | radiansToAngle (ae::q20_12_t radians) |
| Converts an angle in radians (Q20.12). | |
| ae::angle16_t | degreesToCyclicAngle (ae::q20_12_t degrees) |
| Converts an angle in degrees (Q20.12) to a cyclic angle. | |
| ae::q20_12_t | angleToRadians (ae::angle16_t angle) |
| Converts a cyclic angle to radians (Q20.12). | |
| ae::q4_12_t | sin (ae::angle16_t angle) |
| Sine of a cyclic angle. | |
| ae::q4_12_t | sin (ae::q20_12_t radians) |
| Sine, accepting radians (Q20.12). | |
| ae::q4_12_t | cos (ae::angle16_t angle) |
| Cosine of a cyclic angle. | |
| ae::q4_12_t | cos (ae::q20_12_t radians) |
| Cosine, accepting radians (Q20.12). | |
| ae::q20_12_t | tan (ae::q20_12_t radians) |
| Tangent, accepting radians (Q20.12). | |
| ae::angle16_t | asin (ae::q4_12_t ratio) |
| Computes the arcsine of a ratio. | |
| ae::angle16_t | acos (ae::q4_12_t ratio) |
| Computes the arccosine of a ratio. | |
| 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. | |
| 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::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. | |
| 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. | |
| u32 | secondsToSamples (ae::q20_12_t seconds, u32 sampleRate) |
| Converts a Q20.12 seconds value to a sample count, avoiding overflow when seconds * sampleRate exceeds Q20.12's integer range. | |
| ae::q20_12_t | randFrac () |
| Returns a uniformly distributed random fraction from 0 to 1. | |
| 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. | |
| int | lerp (int a, int b, ae::q20_12_t t) |
| Linearly interpolates two integers with a fixed-point blend factor. | |
| 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 | clamp (ae::q20_12_t v, ae::q20_12_t lo, ae::q20_12_t hi) |
| Clamps a Q20.12 value to [lo, hi]. | |
Private Member Functions | |
| MathManager ()=default | |
Friends | |
| class | Singleton< MathManager > |
Definition at line 16 of file MathManager.hpp.
|
strong |
Easing curves for fixed-point interpolation (t in [0, 1]).
| Enumerator | |
|---|---|
| Linear | |
| InQuad | |
| OutQuad | |
| InOutQuad | |
| InCubic | |
| OutCubic | |
| InBack | |
| OutBack | |
Definition at line 224 of file MathManager.hpp.
|
privatedefault |

| ae::angle16_t MathManager::acos | ( | ae::q4_12_t | ratio | ) |
Computes the arccosine of a ratio.
| ratio | Ratio in Q4.12. |
Definition at line 81 of file MathManager.cpp.
| ae::q20_12_t MathManager::angleToRadians | ( | ae::angle16_t | angle | ) |
Converts a cyclic angle to radians (Q20.12).
| angle | Cyclic angle (full turn = 1<<15). |
Definition at line 45 of file MathManager.cpp.
| ae::angle16_t MathManager::asin | ( | ae::q4_12_t | ratio | ) |
Computes the arcsine of a ratio.
| ratio | Ratio in Q4.12. |
Definition at line 76 of file MathManager.cpp.
| ae::q20_12_t MathManager::atan | ( | ae::q20_12_t | y | ) |
Computes the arctangent of a single ratio.
Implemented as atan2(y, 1), per BlocksDS's documented approach for deriving atan from atan2_f32.
| y | Ratio in Q20.12. |
Definition at line 131 of file MathManager.cpp.

| ae::q20_12_t MathManager::atan2 | ( | ae::q20_12_t | y, |
| ae::q20_12_t | x ) |
Computes the angle (in radians) between the positive x-axis and (x, y).
Calls BlocksDS's native fixed-point atan2_f32, which operates directly on 20.12 fixed-point values with no float conversion.
| y | Y Point 2. |
| x | X Point 1. |
Definition at line 122 of file MathManager.cpp.

| ae::q20_12_t MathManager::clamp | ( | ae::q20_12_t | v, |
| ae::q20_12_t | lo, | ||
| ae::q20_12_t | hi ) |
Clamps a Q20.12 value to [lo, hi].
Definition at line 144 of file MathManager.cpp.

| ae::q4_12_t MathManager::cos | ( | ae::angle16_t | angle | ) |
Cosine of a cyclic angle.
| angle | Cyclic angle (full turn = 1<<15). |
Definition at line 66 of file MathManager.cpp.
| ae::q4_12_t MathManager::cos | ( | ae::q20_12_t | radians | ) |
Cosine, accepting radians (Q20.12).
| radians | Angle in radians, as a Q20.12 fixed-point value. |
Definition at line 61 of file MathManager.cpp.

| ae::angle16_t MathManager::degreesToCyclicAngle | ( | ae::q20_12_t | degrees | ) |
Converts an angle in degrees (Q20.12) to a cyclic angle.
| degrees | Angle in degrees |
Definition at line 40 of file MathManager.cpp.
| ae::q20_12_t MathManager::div | ( | ae::q20_12_t | num, |
| ae::q20_12_t | den ) |
Divides two Q20.12 values.
| num | Numerator. |
| den | Denominator. |
Definition at line 4 of file MathManager.cpp.


| ae::q20_12_t MathManager::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.
| x1 | X component of the first vector. |
| y1 | Y component of the first vector. |
| z1 | Z component of the first vector. |
| x2 | X component of the second vector. |
| y2 | Y component of the second vector. |
| z2 | Z component of the second vector. |
Definition at line 86 of file MathManager.cpp.

| ae::q20_12_t MathManager::ease | ( | EaseMode | mode, |
| ae::q20_12_t | t ) |
Applies an easing curve to a normalized time value.
| mode | Easing curve to apply. |
| t | Normalized time in [0, 1] as Q20.12 (clamped). |
Definition at line 168 of file MathManager.cpp.


|
inlineoverride |
Definition at line 19 of file MathManager.hpp.
| ae::q20_12_t MathManager::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.
| x | X component. |
| y | Y component. |
| z | Z component. |
Definition at line 100 of file MathManager.cpp.

| ae::q20_12_t MathManager::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.
| x | X component. |
| y | Y component. |
| z | Z component. |
Definition at line 95 of file MathManager.cpp.


| ae::q20_12_t MathManager::lerp | ( | ae::q20_12_t | a, |
| ae::q20_12_t | b, | ||
| ae::q20_12_t | t ) |
Linearly interpolates two Q20.12 values.
| a | Start value. |
| b | End value. |
| t | Blend factor in [0, 1] as Q20.12. |
Definition at line 157 of file MathManager.cpp.

| int MathManager::lerp | ( | int | a, |
| int | b, | ||
| ae::q20_12_t | t ) |
Linearly interpolates two integers with a fixed-point blend factor.
| a | Start value. |
| b | End value. |
| t | Blend factor in [0, 1] as Q20.12. |
Definition at line 162 of file MathManager.cpp.
| ae::q20_12_t MathManager::mod | ( | ae::q20_12_t | num, |
| ae::q20_12_t | den ) |
Computes the modulo of two Q20.12 values.
| num | Numerator. |
| den | Denominator. |
Definition at line 25 of file MathManager.cpp.

| void MathManager::normalize | ( | ae::q20_12_t & | x, |
| ae::q20_12_t & | y, | ||
| ae::q20_12_t & | z ) |
Normalizes a Q20.12 3D vector in place.
| x | X component, updated in place. |
| y | Y component, updated in place. |
| z | Z component, updated in place. |
Definition at line 105 of file MathManager.cpp.
|
inlineoverride |
Definition at line 23 of file MathManager.hpp.
| ae::angle16_t MathManager::radiansToAngle | ( | ae::q20_12_t | radians | ) |
Converts an angle in radians (Q20.12).
| radians | Angle in radians, as a Q20.12 fixed-point value. |
Definition at line 35 of file MathManager.cpp.

| ae::q20_12_t MathManager::randFrac | ( | ) |
Returns a uniformly distributed random fraction from 0 to 1.
Definition at line 116 of file MathManager.cpp.
| u32 MathManager::secondsToSamples | ( | ae::q20_12_t | seconds, |
| u32 | sampleRate ) |
Converts a Q20.12 seconds value to a sample count, avoiding overflow when seconds * sampleRate exceeds Q20.12's integer range.
| seconds | Time value in seconds, as Q20.12. |
| sampleRate | Samples per second. |
Definition at line 136 of file MathManager.cpp.
|
inlineoverride |
Definition at line 27 of file MathManager.hpp.
| ae::q4_12_t MathManager::sin | ( | ae::angle16_t | angle | ) |
Sine of a cyclic angle.
| angle | Cyclic angle (full turn = 1<<15). |
Definition at line 56 of file MathManager.cpp.
| ae::q4_12_t MathManager::sin | ( | ae::q20_12_t | radians | ) |
Sine, accepting radians (Q20.12).
| radians | Angle in radians, as a Q20.12 fixed-point value. |
Definition at line 51 of file MathManager.cpp.

| ae::q20_12_t MathManager::sqrt | ( | ae::q20_12_t | v | ) |
Computes the square root of a Q20.12 value.
| v | Value to root. |
Definition at line 14 of file MathManager.cpp.


| ae::q20_12_t MathManager::tan | ( | ae::q20_12_t | radians | ) |
Tangent, accepting radians (Q20.12).
| radians | Angle in radians, as a Q20.12 fixed-point value. |
Definition at line 71 of file MathManager.cpp.

|
friend |
Definition at line 268 of file MathManager.hpp.