UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
mathlib_extra.h
Go to the documentation of this file.
1 
19 /*
20 Copyright (C) 2002-2020 UFO: Alien Invasion.
21 
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License
24 as published by the Free Software Foundation; either version 2
25 of the License, or (at your option) any later version.
26 
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30 
31 See the GNU General Public License for more details.
32 
33 You should have received a copy of the GNU General Public License
34 along with this program; if not, write to the Free Software
35 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 */
37 
38 #pragma once
39 
40 #include "ufotypes.h"
41 #include "mathlib.h"
42 
52 #ifndef DENORM
53 #define DENORM 0.0000000001
54 #endif
55 #ifndef DENORM_INV
56 #define DENORM_INV (1.0 - (DENORM))
57 #endif
58 
66 #ifndef ChkDNorm
67 #define ChkDNorm(fpVal) ((fpVal) == 0.0 ? (DENORM) : (fpVal) )
68 #endif
69 
77 #ifndef ChkDNorm_Inv
78 #define ChkDNorm_Inv(fpVal) ( ((fpVal) == 1.0) ? (DENORM_INV) : (fpVal) )
79 #endif
80 
83 /* Basic curves */
84 double FpCurveUp(double fpVal, double mEffect);
85 double FpCurveDn(double fpVal, double mEffect);
86 
87 /* "RS" = "Rapid Start", curve has a different, skewed shape */
88 double FpCurveUpRs(double fpVal, double mEffect);
89 double FpCurveDnRs(double fpVal, double mEffect);
90 
98 /* "cntPnt" = center point, function curves "fpVal" TOWARD "cntPnt" */
99 double FpCurve1D_u_in(double fpVal, double mEffect, double cntPnt);
100 /* "cntPnt" = center point, function curves "fpVal" AWAY FROM "cntPnt" */
101 double FpCurve1D_u_out(double fpVal, double mEffect, double cntPnt);
102 
105 /* Function curves "fpVal" AWAY FROM 0.0, toward 1.0f or -1.0f */
106 double FpCurve1D_s_out(double fpVal, double mEffect);
107 
114 float FpUcurve_f(const float inpVal, const float hard);
115 double FpUcurve_d(const double inpVal, const double hard);
116 
117 float FpUcurveSc_f(const float inpVal, const float hard, const float scale);
118 double FpUcurveSc_d(const double inpVal, const double hard, const double scale);
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 ran...
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 ran...
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 ran...
static const vec3_t scale
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 r...
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.
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 ran...
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 ran...
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.
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.
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 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 ran...
Cross-platform type definitions.