A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
EGG::Mathf Namespace Reference

Detailed Description

Math functions and constants used in the base game.

Classes

struct  AtanEntry
 
struct  BaseAndDec32
 
struct  BaseAndDec64
 
union  c32
 
union  c64
 
struct  SinCosEntry
 

Functions

f32 frsqrt (f32 x)
 
f32 SinFIdx (f32 fidx)
 
f32 CosFIdx (f32 fidx)
 
f32 AtanFIdx_ (f32 x)
 
f32 Atan2FIdx (f32 y, f32 x)
 
static f32 sqrt (f32 x)
 
static f32 sin (f32 x)
 
static f32 cos (f32 x)
 
static f32 acos (f32 x)
 
static f32 atan2 (f32 y, f32 x)
 
static f32 abs (f32 x)
 
static f64 force25Bit (f64 x)
 This is used to mimic the Wii's floating-point unit.
 
static f32 fma (f32 x, f32 y, f32 z)
 Fused multiply-add operation.
 
static f32 fms (f32 x, f32 y, f32 z)
 Fused multiply-subtract operation.
 
static f64 frsqrte (const f64 val)
 
static f32 fres (const f32 val)
 
static f32 finv (f32 x)
 Fused Newton-Raphson operation.
 

Variables

static constexpr SinCosEntry sSinCosTbl [256+1]
 
static constexpr AtanEntry sArcTanTbl [32+1]
 
static constexpr u64 EXPONENT_SHIFT_F64 = 52
 
static constexpr u64 MANTISSA_MASK_F64 = 0x000fffffffffffffULL
 
static constexpr u64 EXPONENT_MASK_F64 = 0x7ff0000000000000ULL
 
static constexpr u64 SIGN_MASK_F64 = 0x8000000000000000ULL
 
static constexpr std::array< BaseAndDec64, 32 > RSQRTE_TABLE
 
static constexpr std::array< BaseAndDec32, 32 > FRES_TABLE
 

Function Documentation

◆ abs()

static f32 EGG::Mathf::abs ( f32 x)
inlinestaticnodiscard

Definition at line 53 of file Math.hh.

◆ acos()

static f32 EGG::Mathf::acos ( f32 x)
inlinestaticnodiscard0x8022F8C0

Definition at line 44 of file Math.hh.

◆ atan2()

static f32 EGG::Mathf::atan2 ( f32 y,
f32 x )
inlinestaticnodiscard0x8022F8E4

Definition at line 49 of file Math.hh.

◆ Atan2FIdx()

f32 EGG::Mathf::Atan2FIdx ( f32 y,
f32 x )
nodiscard0x800853C0

Definition at line 365 of file Math.cc.

◆ AtanFIdx_()

f32 EGG::Mathf::AtanFIdx_ ( f32 x)
nodiscard

Definition at line 357 of file Math.cc.

◆ cos()

static f32 EGG::Mathf::cos ( f32 x)
inlinestaticnodiscard0x8022F86C

Takes in radians

Definition at line 39 of file Math.hh.

◆ CosFIdx()

f32 EGG::Mathf::CosFIdx ( f32 fidx)
nodiscard0x80085180

Definition at line 343 of file Math.cc.

◆ finv()

static f32 EGG::Mathf::finv ( f32 x)
inlinestaticnodiscard

Fused Newton-Raphson operation.

Definition at line 315 of file Math.hh.

◆ fma()

static f32 EGG::Mathf::fma ( f32 x,
f32 y,
f32 z )
inlinestaticnodiscard

Fused multiply-add operation.

We cannot use std::fma due to the Wii computing at 64-bit precision.

Definition at line 68 of file Math.hh.

◆ fms()

static f32 EGG::Mathf::fms ( f32 x,
f32 y,
f32 z )
inlinestaticnodiscard

Fused multiply-subtract operation.

We cannot use std::fms due to the Wii computing at 64-bit precision.

Definition at line 75 of file Math.hh.

◆ force25Bit()

static f64 EGG::Mathf::force25Bit ( f64 x)
inlinestaticnodiscard

This is used to mimic the Wii's floating-point unit.

This handles the edgecase where double-precision floating-point numbers are passed into single-precision floating-point operands in assembly.

Definition at line 60 of file Math.hh.

◆ fres()

static f32 EGG::Mathf::fres ( const f32 val)
inlinestaticnodiscard

Definition at line 249 of file Math.hh.

◆ frsqrt()

f32 EGG::Mathf::frsqrt ( f32 x)
nodiscard0x80085040

CREDIT: Hanachan

Definition at line 315 of file Math.cc.

◆ frsqrte()

static f64 EGG::Mathf::frsqrte ( const f64 val)
inlinestaticnodiscard

Definition at line 158 of file Math.hh.

◆ sin()

static f32 EGG::Mathf::sin ( f32 x)
inlinestaticnodiscard0x8022F860

Takes in radians

Definition at line 33 of file Math.hh.

◆ SinFIdx()

f32 EGG::Mathf::SinFIdx ( f32 fidx)
nodiscard0x80085110

Definition at line 328 of file Math.cc.

◆ sqrt()

static f32 EGG::Mathf::sqrt ( f32 x)
inlinestaticnodiscard0x8022F80C

Definition at line 22 of file Math.hh.

Variable Documentation

◆ EXPONENT_MASK_F64

u64 EGG::Mathf::EXPONENT_MASK_F64 = 0x7ff0000000000000ULL
staticconstexpr

Definition at line 120 of file Math.hh.

◆ EXPONENT_SHIFT_F64

u64 EGG::Mathf::EXPONENT_SHIFT_F64 = 52
staticconstexpr

Definition at line 118 of file Math.hh.

◆ FRES_TABLE

std::array<BaseAndDec32, 32> EGG::Mathf::FRES_TABLE
staticconstexpr

Definition at line 214 of file Math.hh.

◆ MANTISSA_MASK_F64

u64 EGG::Mathf::MANTISSA_MASK_F64 = 0x000fffffffffffffULL
staticconstexpr

Definition at line 119 of file Math.hh.

◆ RSQRTE_TABLE

std::array<BaseAndDec64, 32> EGG::Mathf::RSQRTE_TABLE
staticconstexpr

Definition at line 123 of file Math.hh.

◆ sArcTanTbl

AtanEntry EGG::Mathf::sArcTanTbl[32+1]
staticconstexpr0x80274148

Definition at line 277 of file Math.cc.

◆ SIGN_MASK_F64

u64 EGG::Mathf::SIGN_MASK_F64 = 0x8000000000000000ULL
staticconstexpr

Definition at line 121 of file Math.hh.

◆ sSinCosTbl

SinCosEntry EGG::Mathf::sSinCosTbl[256+1]
staticconstexpr0x80248010

Definition at line 16 of file Math.cc.