]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_find_position.cpp
Make sure sign is preserved for turbulence direction.
[flightgear.git] / src / FDM / UIUCModel / uiuc_find_position.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_find_positon.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  Determine the position of a surface/object given the
8                command, increment rate, and current position.  Outputs
9                new position
10                
11 ----------------------------------------------------------------------
12
13  STATUS:       alpha version
14
15 ----------------------------------------------------------------------
16
17  REFERENCES:   
18
19 ----------------------------------------------------------------------
20
21  HISTORY:      03/03/2003   initial release
22
23 ----------------------------------------------------------------------
24
25  AUTHOR(S):    Robert Deters      <rdeters@uiuc.edu>
26                Michael Selig      <m-selig@uiuc.edu>
27
28 ----------------------------------------------------------------------
29
30  VARIABLES:
31
32 ----------------------------------------------------------------------
33
34  INPUTS:       command, increment rate, position
35
36 ----------------------------------------------------------------------
37
38  OUTPUTS:      position
39
40 ----------------------------------------------------------------------
41
42  CALLED BY:    uiuc_aerodeflections()
43
44 ----------------------------------------------------------------------
45
46  CALLS TO:     *
47
48 ----------------------------------------------------------------------
49
50  COPYRIGHT:    (C) 2003 by Michael Selig
51
52  This program is free software; you can redistribute it and/or
53  modify it under the terms of the GNU General Public License
54  as published by the Free Software Foundation.
55
56  This program is distributed in the hope that it will be useful,
57  but WITHOUT ANY WARRANTY; without even the implied warranty of
58  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
59  GNU General Public License for more details.
60
61  You should have received a copy of the GNU General Public License
62  along with this program; if not, write to the Free Software
63  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
64  USA or view http://www.gnu.org/copyleft/gpl.html.
65
66 **********************************************************************/
67 #include "uiuc_find_position.h"
68
69 double uiuc_find_position(double command, double increment_per_timestep,
70                           double position)
71 {
72   if (position < command) {
73     position += increment_per_timestep;
74     if (position > command) 
75       position = command;
76   } 
77   else if (position > command) {
78     position -= increment_per_timestep;
79     if (position < command)
80       position = command;
81   }
82
83   return position;
84 }