| 1 | // util.hxx - general-purpose utility functions. |
| 2 | // Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt |
| 3 | // |
| 4 | // This program is free software; you can redistribute it and/or |
| 5 | // modify it under the terms of the GNU General Public License as |
| 6 | // published by the Free Software Foundation; either version 2 of the |
| 7 | // License, or (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, but |
| 10 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | // General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program; if not, write to the Free Software |
| 16 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | // |
| 18 | // $Id$ |
| 19 | |
| 20 | #ifndef __UTIL_HXX |
| 21 | #define __UTIL_HXX 1 |
| 22 | |
| 23 | #include <string> |
| 24 | #include <simgear/misc/sg_path.hxx> |
| 25 | |
| 26 | /** |
| 27 | * Move a value towards a target. |
| 28 | * |
| 29 | * This function was originally written by Alex Perry. |
| 30 | * |
| 31 | * @param current The current value. |
| 32 | * @param target The target value. |
| 33 | * @param timeratio The percentage of smoothing time that has passed |
| 34 | * (elapsed time/smoothing time) |
| 35 | * @return The new value. |
| 36 | */ |
| 37 | double fgGetLowPass (double current, double target, double timeratio); |
| 38 | |
| 39 | |
| 40 | /** |
| 41 | * Set the read and write lists of allowed paths patterns for SGPath::validate() |
| 42 | */ |
| 43 | void fgInitAllowedPaths(); |
| 44 | |
| 45 | namespace flightgear |
| 46 | { |
| 47 | /** |
| 48 | * @brief getAircraftAuthorsText - get the aircraft authors as a single |
| 49 | * string value. This will combine the new (structured) authors data if |
| 50 | * present, otherwise just return the old plain string |
| 51 | * @return |
| 52 | */ |
| 53 | std::string getAircraftAuthorsText(); |
| 54 | |
| 55 | /** |
| 56 | * @brief low-pass filter for bearings, etc in degrees. Inputs can have any sign |
| 57 | * and output is always in the range [-180.0 .. 180.0]. Ranges of inputs do not |
| 58 | * have to be consistent, they will be normalised before filtering. |
| 59 | * |
| 60 | * @param current - current value in degrees |
| 61 | * @param target - target (new) value in degrees. |
| 62 | * @param timeratio - |
| 63 | */ |
| 64 | double lowPassPeriodicDegreesSigned(double current, double target, double timeratio); |
| 65 | |
| 66 | /** |
| 67 | * @brief low-pass filter for bearings, etc in degrees. Inputs can have any sign |
| 68 | * and output is always in the range [0.0 .. 360.0]. Ranges of inputs do not |
| 69 | * have to be consistent, they will be normalised before filtering. |
| 70 | * |
| 71 | * @param current - current value in degrees |
| 72 | * @param target - target (new) value in degrees. |
| 73 | * @param timeratio - |
| 74 | */ |
| 75 | double lowPassPeriodicDegreesPositive(double current, double target, double timeratio); |
| 76 | |
| 77 | /** |
| 78 | * @brief exponential filter |
| 79 | * |
| 80 | * @param current - current value |
| 81 | * @param target - target (new) value |
| 82 | * @param timeratio - |
| 83 | */ |
| 84 | double filterExponential(double current, double target, double timeratio); |
| 85 | } |
| 86 | |
| 87 | #endif // __UTIL_HXX |