UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mathlib_extra.cpp File Reference

Special, additional math algorithms for floating-point values. More...

#include "mathlib_extra.h"
#include <math.h>

Go to the source code of this file.

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...
 

Detailed Description

Special, additional math algorithms for floating-point values.

Definition in file mathlib_extra.cpp.

Function Documentation

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.

Parameters
[in]fpValInitial floating-Point value (double) to be altered. May range from -1.0 to +1.0.
[in]mEffectHow 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).
Returns
The new, altered value.

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.

Parameters
[in]fpValInitial floating-Point value (double) to be altered.
[in]mEffectHow 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]cntPntThe center point (a value between 0.0 and 1.0) that fpVal should "lean" or skew to.
Returns
The new, altered value.

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.

Parameters
[in]fpValInitial floating-Point value (double) to be altered.
[in]mEffectHow 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]cntPntThe center point (a value between 0.0 and 1.0) that fpVal should "lean" or skew away from.
Returns
The new, altered value.

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.

Parameters
[in]fpValInitial floating-Point value (double) to be altered.
[in]mEffectHow 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).
Returns
The new, altered value.

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.

Parameters
[in]fpValInitial floating-Point value (double) to be altered.
[in]mEffectHow 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).
Returns
The new, altered value.

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.

Parameters
[in]fpValInitial floating-Point value (double) to be altered.
[in]mEffectHow 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).
Returns
The new, altered value.

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.

Parameters
[in]fpValInitial floating-Point value (double) to be altered.
[in]mEffectHow 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).
Returns
The new, altered value.

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.

Parameters
[in]inpValThe original input value.
[in]hardThe 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.
Returns
The altered value, between -1.f and 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.

Parameters
[in]inpValThe original input value.
[in]hardThe 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.
Returns
The altered value, between -1.f and 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.

Parameters
[in]inpValThe original input value.
[in]hardThe steepness or slope of the curve, valid values are 0.f to +inf. Higher values mean a more rapid
[in]scaleAn 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.
Returns
The altered value, between -1.f and 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.

Parameters
[in]inpValThe original input value.
[in]hardThe steepness or slope of the curve, valid values are 0.f to +inf. Higher values mean a more rapid
[in]scaleAn 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.
Returns
The altered value, between -1.f and 1.f.

Definition at line 270 of file mathlib_extra.cpp.