UFO: Alien Invasion
Loading...
Searching...
No Matches
mathlib_extra.cpp File Reference

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

#include "mathlib_extra.h"
#include <math.h>
Include dependency graph for mathlib_extra.cpp:

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

Detailed Description

Special, additional math algorithms for floating-point values.

Definition in file mathlib_extra.cpp.

Function Documentation

◆ FpCurve1D_s_out()

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.

◆ FpCurve1D_u_in()

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

◆ FpCurve1D_u_out()

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

◆ FpCurveDn()

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

◆ FpCurveDnRs()

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.

◆ FpCurveUp()

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

◆ FpCurveUpRs()

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.

◆ FpUcurve_d()

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.

◆ FpUcurve_f()

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.

◆ FpUcurveSc_d()

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.

References scale.

◆ FpUcurveSc_f()

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.

References scale.