UFO: Alien Invasion
Loading...
Searching...
No Matches
mathlib_extra.h
Go to the documentation of this file.
1
18
19/*
20Copyright (C) 2002-2025 UFO: Alien Invasion.
21
22This program is free software; you can redistribute it and/or
23modify it under the terms of the GNU General Public License
24as published by the Free Software Foundation; either version 2
25of the License, or (at your option) any later version.
26
27This program is distributed in the hope that it will be useful,
28but WITHOUT ANY WARRANTY; without even the implied warranty of
29MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30
31See the GNU General Public License for more details.
32
33You should have received a copy of the GNU General Public License
34along with this program; if not, write to the Free Software
35Foundation, 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
82
83/* Basic curves */
84double FpCurveUp(double fpVal, double mEffect);
85double FpCurveDn(double fpVal, double mEffect);
86
87/* "RS" = "Rapid Start", curve has a different, skewed shape */
88double FpCurveUpRs(double fpVal, double mEffect);
89double FpCurveDnRs(double fpVal, double mEffect);
90
98/* "cntPnt" = center point, function curves "fpVal" TOWARD "cntPnt" */
99double FpCurve1D_u_in(double fpVal, double mEffect, double cntPnt);
100/* "cntPnt" = center point, function curves "fpVal" AWAY FROM "cntPnt" */
101double FpCurve1D_u_out(double fpVal, double mEffect, double cntPnt);
102
104
105/* Function curves "fpVal" AWAY FROM 0.0, toward 1.0f or -1.0f */
106double FpCurve1D_s_out(double fpVal, double mEffect);
107
114float FpUcurve_f(const float inpVal, const float hard);
115double FpUcurve_d(const double inpVal, const double hard);
116
117float FpUcurveSc_f(const float inpVal, const float hard, const float scale);
118double FpUcurveSc_d(const double inpVal, const double hard, const double scale);
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...
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 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...
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,...
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...
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,...
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 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,...
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,...
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...
Cross-platform type definitions.
static const vec3_t scale