|
BurgerLib
|
Functions to handle Frac point integer math. More...
#include <fxfixed.h>
Static Public Member Functions | |
| static Frac32 BURGER_API | MultiplySaturate (Frac32 fInputMulA, Frac32 fInputMulB) |
| Multiply two 2.30 fixed point numbers with saturation. | |
| static Frac32 BURGER_API | DivideSaturate (Frac32 fInputNumerator, Frac32 fInputDenominator) |
| Divide a 2.30 fixed point number with saturation. | |
| static Frac32 BURGER_API | CosFromFixed (Fixed32 fRadians) |
| Calculate a cosine from a Fixed32 radian value. | |
| static Frac32 BURGER_API | SinFromFixed (Fixed32 fRadians) |
| Calculate a sine from a Fixed32 radian value. | |
Functions to handle Frac point integer math.
Not all modern computers have floating point support in hardware, so to get hiogh precision fractional values, a 2.30 integer format is used.
How it works is simple. The upper 2 bits are treated as a 2 bit whole integer while the lower 30 bits represent the numerator of the fraction x/1073741824. Using this method, 1.5f is represented at 0x60000000.
These routines will make it easy to perform conversion of numbers to this numeric type and to handle the most common mathematical operations with 1/1073741824th precision.
Many of these functions are inline or written in assembly language for speed.
| Frac32 BURGER_API Burger::FracMath::CosFromFixed | ( | Fixed32 | fRadians | ) | [static] |
Calculate a cosine from a Fixed32 radian value.
Given a radian value of Burger::PiFixed32 to - Burger::PiFixed32 return the cosine value as a Frac32 from -1 to 1
| fRadians | A Fixed32 value in radians |
| Frac32 BURGER_API Burger::FracMath::DivideSaturate | ( | Frac32 | fInputNumerator, |
| Frac32 | fInputDenominator | ||
| ) | [static] |
Divide a 2.30 fixed point number with saturation.
Perform a signed division of two 32-bit fixed point numbers and return the Frac point result. If the answer exceeds the range allowable for a Frac32 value, it will be saturated to the minimum and maximum bounds. Division by zero will return positive or negative maximums.
| fInputNumerator | Value to divide |
| fInputDenominator | Value to divide with |
| Frac32 BURGER_API Burger::FracMath::MultiplySaturate | ( | Frac32 | fInputMulA, |
| Frac32 | fInputMulB | ||
| ) | [static] |
Multiply two 2.30 fixed point numbers with saturation.
Perform a signed multiplication of two 32-bit frac point numbers and return the frac point result. If the value exceeds the range allowable for a Frac32 value, it will be saturated to the minimum and maximum bounds.
| fInputMulA | First signed value to multiply |
| fInputMulB | Second signed value to multiply |
| Frac32 BURGER_API Burger::FracMath::SinFromFixed | ( | Fixed32 | fRadians | ) | [static] |
Calculate a sine from a Fixed32 radian value.
Given a radian value of Burger::PiFixed32 to - Burger::PiFixed32 return the sine value as a Frac32 from -1 to 1
| fRadians | A Fixed32 value in radians |
1.8.0