UFO: Alien Invasion
|
Special, additional math algorithms for floating-point values. More...
Go to the source code of this file.
Macros | |
#define | DENORM 0.0000000001 |
This "DENORM" is for avoiding denormal-related issues when values equal to a perfect 0.0f are passed to some functions, which could otherwise cause very high CPU use (slow things down), or sometimes even break stuff (error, crash, etc.) Also used to avoid divide-by-zero issues. More... | |
#define | DENORM_INV (1.0 - (DENORM)) |
#define | ChkDNorm(fpVal) ((fpVal) == 0.0 ? (DENORM) : (fpVal) ) |
This takes a floating-point variable and, if it happens to have a value of perfect 0.0f, will gently nudge it UP a little to avoid denormal or divide-by-zero problems. More... | |
#define | ChkDNorm_Inv(fpVal) ( ((fpVal) == 1.0) ? (DENORM_INV) : (fpVal) ) |
This takes a floating-point variable and, if it happens to have a value of perfect 1.0f, will gently nudge it DOWN a little to avoid denormal or divide-by-zero problems. More... | |
Functions | |
double | FpCurveUp (double fpVal, double mEffect) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" upward (toward 1.0) in a curve with a controlled shape. More... | |
double | FpCurveDn (double fpVal, double mEffect) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" downward (toward 0.0) in a curve with a controlled shape. More... | |
double | FpCurveUpRs (double fpVal, double mEffect) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" upward (toward 1.0) in a curve with a controlled shape that is more extreme closer to 0.0 and tapers off closer to 1.0, resulting in a curve that bends into a special shape. More... | |
double | FpCurveDnRs (double fpVal, double mEffect) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" downward (toward 0.0) in a curve with a controlled shape that is more extreme closer to 0.0 and tapers off closer to 1.0, resulting in a curve that bends into a special shape. More... | |
double | FpCurve1D_u_in (double fpVal, double mEffect, double cntPnt) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" inward toward a given center point value in a curve with a controlled shape. More... | |
double | FpCurve1D_u_out (double fpVal, double mEffect, double cntPnt) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" outward away from a given center point value in a curve with a controlled shape. The value will curve toward either 1.0 or 0.0, depending on which one would NOT mean crossing the center point. More... | |
double | FpCurve1D_s_out (double fpVal, double mEffect) |
Takes a floating-point value (double) between -1.0 and +1.0 and returns a new value within the same range, with output values skewed or "leaning" outward away from 0.0. The value will curve toward either -1.0 or +1.0, depending on which one would NOT mean crossing 0.0. More... | |
float | FpUcurve_f (const float inpVal, const float hard) |
Takes a (float) of any value and outputs a value from -1.f to +1.f, along a curve, so that as the input value gets farther from 0.0f it slows down and never quite gets to +1.f or -1.f. More... | |
double | FpUcurve_d (const double inpVal, const double hard) |
Takes a (float) of any value and outputs a value from -1.f to +1.f, along a curve, so that as the input value gets farther from 0.0f it slows down and never quite gets to +1.f or -1.f. More... | |
float | FpUcurveSc_f (const float inpVal, const float hard, const float scale) |
Takes a (float) of any value and outputs a value from -1.f to +1.f, along a curve, so that as the input value gets farther from 0.0f it slows down and never quite gets to +1.f or -1.f. More... | |
double | FpUcurveSc_d (const double inpVal, const double hard, const double scale) |
Takes a (float) of any value and outputs a value from -1.f to +1.f, along a curve, so that as the input value gets farther from 0.0f it slows down and never quite gets to +1.f or -1.f. More... | |
Special, additional math algorithms for floating-point values.
These are special, custom functions for influencing floating-point variables, Usually with values that start and end either between 0.f and 1.f or -1.f and +1.f. They can push variables toward or away from the minimum and maxumium possible values in a non-linear, curved shape. Unless stated otherwise, "fpVal" is the original value to be altered, and "mEffect" is a value between 0.f and 1.f that affects how strong the curve is, with 1.f having the most effect. Some functions also have a "cntPnt" (Center Point) value that can be given, a point that the fpVal curves toward or away from.
NOTE: A special .PNG file will also be available that will show these functions on a graph, to help in choosing which one is most suitable to use. (Please see "mathlib_extra.png")
Definition in file mathlib_extra.h.
#define ChkDNorm | ( | fpVal | ) | ((fpVal) == 0.0 ? (DENORM) : (fpVal) ) |
This takes a floating-point variable and, if it happens to have a value of perfect 0.0f, will gently nudge it UP a little to avoid denormal or divide-by-zero problems.
[in] | fpVal | Floating-point variable that should be checked, to make sure it isn't a perfect zero. |
Definition at line 67 of file mathlib_extra.h.
Referenced by AM_CalculateTeamScores().
#define ChkDNorm_Inv | ( | fpVal | ) | ( ((fpVal) == 1.0) ? (DENORM_INV) : (fpVal) ) |
This takes a floating-point variable and, if it happens to have a value of perfect 1.0f, will gently nudge it DOWN a little to avoid denormal or divide-by-zero problems.
[in] | fpVal | Floating-point variable that should be checked, to make sure it isn't a perfect 1.0f. |
Definition at line 78 of file mathlib_extra.h.
Referenced by AM_CalculateTeamScores().
#define DENORM 0.0000000001 |
This "DENORM" is for avoiding denormal-related issues when values equal to a perfect 0.0f are passed to some functions, which could otherwise cause very high CPU use (slow things down), or sometimes even break stuff (error, crash, etc.) Also used to avoid divide-by-zero issues.
The "Inv" (Inverted) value is for avoiding similar issues when a variable can almost reach 1.0f but should not hit it perfectly.
Definition at line 53 of file mathlib_extra.h.
Referenced by FpCurve1D_s_out(), FpCurve1D_u_in(), FpCurve1D_u_out(), FpCurveDn(), FpCurveDnRs(), FpCurveUp(), and FpCurveUpRs().
#define DENORM_INV (1.0 - (DENORM)) |
Definition at line 56 of file mathlib_extra.h.
Referenced by FpCurve1D_s_out(), FpCurve1D_u_in(), FpCurve1D_u_out(), FpCurveDn(), FpCurveDnRs(), FpCurveUp(), and FpCurveUpRs().
double FpCurve1D_s_out | ( | double | fpVal, |
double | mEffect | ||
) |
Takes a floating-point value (double) between -1.0 and +1.0 and returns a new value within the same range, with output values skewed or "leaning" outward away from 0.0. The value will curve toward either -1.0 or +1.0, depending on which one would NOT mean crossing 0.0.
fpVal = -1.0f to 1.0f for these functions
[in] | fpVal | Initial floating-Point value (double) to be altered. May range from -1.0 to +1.0. |
[in] | mEffect | How extreme the effect is (the shape of the curve). A value of 0.0 is no curve or effect at all, while a value of 1.0 is for maximum effect (very extreme). |
Definition at line 218 of file mathlib_extra.cpp.
References DENORM, and DENORM_INV.
double FpCurve1D_u_in | ( | double | fpVal, |
double | mEffect, | ||
double | cntPnt | ||
) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" inward toward a given center point value in a curve with a controlled shape.
These next functions can curve up OR down, depending on the starting value of "x" and the center mid-point, which by default is 0.5f. The "_u_" in the function name means "unsigned" because all the values are still between 0.0f and 1.0f, while later functions with "_s_" will work with values between -1.0f and +1.0f.
[in] | fpVal | Initial floating-Point value (double) to be altered. |
[in] | mEffect | How extreme the effect is (the shape of the curve). A value of 0.0 is no curve or effect at all, while a value of 1.0 is for maximum effect (very extreme). |
[in] | cntPnt | The center point (a value between 0.0 and 1.0) that fpVal should "lean" or skew to. |
Definition at line 137 of file mathlib_extra.cpp.
References DENORM, DENORM_INV, and FpCurveDn().
Referenced by AM_CalculateTeamScores().
double FpCurve1D_u_out | ( | double | fpVal, |
double | mEffect, | ||
double | cntPnt | ||
) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" outward away from a given center point value in a curve with a controlled shape. The value will curve toward either 1.0 or 0.0, depending on which one would NOT mean crossing the center point.
[in] | fpVal | Initial floating-Point value (double) to be altered. |
[in] | mEffect | How extreme the effect is (the shape of the curve). A value of 0.0 is no curve or effect at all, while a value of 1.0 is for maximum effect (very extreme). |
[in] | cntPnt | The center point (a value between 0.0 and 1.0) that fpVal should "lean" or skew away from. |
Definition at line 178 of file mathlib_extra.cpp.
References DENORM, DENORM_INV, and FpCurveUp().
double FpCurveDn | ( | double | fpVal, |
double | mEffect | ||
) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" downward (toward 0.0) in a curve with a controlled shape.
[in] | fpVal | Initial floating-Point value (double) to be altered. |
[in] | mEffect | How extreme the effect is (the shape of the curve). A value of 0.0 is no curve or effect at all, while a value of 1.0 is for maximum effect (very extreme). |
Definition at line 59 of file mathlib_extra.cpp.
References DENORM, and DENORM_INV.
Referenced by AM_CalculateTeamScores(), AM_DoFight(), and FpCurve1D_u_in().
double FpCurveDnRs | ( | double | fpVal, |
double | mEffect | ||
) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" downward (toward 0.0) in a curve with a controlled shape that is more extreme closer to 0.0 and tapers off closer to 1.0, resulting in a curve that bends into a special shape.
[in] | fpVal | Initial floating-Point value (double) to be altered. |
[in] | mEffect | How extreme the effect is (the shape of the curve). A value of 0.0 is no curve or effect at all, while a value of 1.0 is for maximum effect (very extreme). |
Definition at line 110 of file mathlib_extra.cpp.
References DENORM, and DENORM_INV.
double FpCurveUp | ( | double | fpVal, |
double | mEffect | ||
) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" upward (toward 1.0) in a curve with a controlled shape.
fpVal = 0.0f to 1.0f for these functions
[in] | fpVal | Initial floating-Point value (double) to be altered. |
[in] | mEffect | How extreme the effect is (the shape of the curve). A value of 0.0 is no curve or effect at all, while a value of 1.0 is for maximum effect (very extreme). |
Definition at line 36 of file mathlib_extra.cpp.
References DENORM, and DENORM_INV.
Referenced by AM_CalculateTeamScores(), and FpCurve1D_u_out().
double FpCurveUpRs | ( | double | fpVal, |
double | mEffect | ||
) |
Takes a floating-point value (double) between 0.0 and 1.0 and returns a new value within the same range, with output values skewed or "leaning" upward (toward 1.0) in a curve with a controlled shape that is more extreme closer to 0.0 and tapers off closer to 1.0, resulting in a curve that bends into a special shape.
[in] | fpVal | Initial floating-Point value (double) to be altered. |
[in] | mEffect | How extreme the effect is (the shape of the curve). A value of 0.0 is no curve or effect at all, while a value of 1.0 is for maximum effect (very extreme). |
Definition at line 85 of file mathlib_extra.cpp.
References DENORM, and DENORM_INV.
double FpUcurve_d | ( | const double | inpVal, |
const double | hard | ||
) |
Takes a (float) of any value and outputs a value from -1.f to +1.f, along a curve, so that as the input value gets farther from 0.0f it slows down and never quite gets to +1.f or -1.f.
[in] | inpVal | The original input value. |
[in] | hard | The steepness or slope of the curve, valid values are 0.f to +inf. Higher values mean a more rapid approach of inpVal toward +1.f or -1,f. |
Definition at line 255 of file mathlib_extra.cpp.
float FpUcurve_f | ( | const float | inpVal, |
const float | hard | ||
) |
Takes a (float) of any value and outputs a value from -1.f to +1.f, along a curve, so that as the input value gets farther from 0.0f it slows down and never quite gets to +1.f or -1.f.
These are floating-point curves where the input can start at 0.f but has no upper limit. The output will always be within 0.f and +- 1.f. They may be used for newer alien interest code, air combat, and other stuff. If they need to be used often, the (float) based functions should of course be faster than the ones that use (double)s.
[in] | inpVal | The original input value. |
[in] | hard | The steepness or slope of the curve, valid values are 0.f to +inf. Higher values mean a more rapid approach of inpVal toward +1.f or -1,f. |
Definition at line 241 of file mathlib_extra.cpp.
References f.
double FpUcurveSc_d | ( | const double | inpVal, |
const double | hard, | ||
const double | scale | ||
) |
Takes a (float) of any value and outputs a value from -1.f to +1.f, along a curve, so that as the input value gets farther from 0.0f it slows down and never quite gets to +1.f or -1.f.
[in] | inpVal | The original input value. |
[in] | hard | The steepness or slope of the curve, valid values are 0.f to +inf. Higher values mean a more rapid |
[in] | scale | An additional scaling factor that can affect the shape of the sloped curve of potential output values. approach of inpVal toward +1.f or -1,f. |
Definition at line 285 of file mathlib_extra.cpp.
float FpUcurveSc_f | ( | const float | inpVal, |
const float | hard, | ||
const float | scale | ||
) |
Takes a (float) of any value and outputs a value from -1.f to +1.f, along a curve, so that as the input value gets farther from 0.0f it slows down and never quite gets to +1.f or -1.f.
[in] | inpVal | The original input value. |
[in] | hard | The steepness or slope of the curve, valid values are 0.f to +inf. Higher values mean a more rapid |
[in] | scale | An additional scaling factor that can affect the shape of the sloped curve of potential output values. approach of inpVal toward +1.f or -1,f. |
Definition at line 270 of file mathlib_extra.cpp.