#include "Library/Math/MathRandomUtil.h" #include namespace al { f32 getRandom() { u32 random = (sead::GlobalRandom::instance()->getU32() >> 9) | 0x3F800000; return (*reinterpret_cast(&random)) - 1; } f32 getRandom(f32 factor) { return getRandom(0.f, factor); } f32 getRandom(f32 min, f32 max) { return (getRandom() * (max - min)) + min; } s32 getRandom(s32 factor) { return getRandom(0, factor); } s32 getRandom(s32 min, s32 max) { return (s32)getRandom((f32)min, (f32)max); } f32 getRandomDegree() { return getRandom(360.f); } f32 getRandomRadian() { return getRandom(6.2832f); } void getRandomVector(sead::Vector3f* vec, f32 factor) { f32 x = (getRandom() * (factor + factor)) - factor; f32 y = (getRandom() * (factor + factor)) - factor; f32 z = (getRandom() * (factor + factor)) - factor; vec->x = x; vec->y = y; vec->z = z; } void getRandomDir(sead::Vector3f* vec) { getRandomVector(vec, 10.f); while (vec->dot(*vec) > 0.000001f) getRandomVector(vec, 10.f); vec->normalize(); } } // namespace al