]> git.mxchange.org Git - flightgear.git/blob - Slew/slew.c
7e7c1598a5ad2b6bf39afcecc80967e0de058c51
[flightgear.git] / Slew / slew.c
1 /**************************************************************************
2  * slew.c -- the "slew" flight model
3  *
4  * Written by Curtis Olson, started May 1997.
5  *
6  * Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  * $Id$
23  * (Log is kept at end of this file)
24  **************************************************************************/
25
26
27 #include <math.h>
28
29 #include <Flight/Slew/slew.h>
30 #include <Flight/flight.h>
31 #include <Aircraft/aircraft.h>
32 #include <Controls/controls.h>
33 #include <Include/fg_constants.h>
34
35
36 #ifndef M_PI                                    
37 #define M_PI        3.14159265358979323846      /* pi */
38 #endif                                                           
39
40 #ifndef PI2                                               
41 #define PI2  (M_PI + M_PI)                      
42 #endif        
43
44
45 /* reset flight params to a specific position */
46 void fgSlewInit(double pos_x, double pos_y, double pos_z, double heading) {
47     struct fgFLIGHT *f;
48
49     f = &current_aircraft.flight;
50
51     /*
52     f->pos_x = pos_x;
53     f->pos_y = pos_y;
54     f->pos_z = pos_z;
55
56     f->vel_x = 0.0;
57     f->vel_y = 0.0;
58     f->vel_z = 0.0;
59
60     f->Phi = 0.0;
61     f->Theta = 0.0;
62     f->Psi = 0.0;
63
64     f->vel_Phi = 0.0;
65     f->vel_Theta = 0.0;
66     f->vel_Psi = 0.0;
67
68     f->Psi = heading;
69     */
70 }
71
72
73 /* update position based on inputs, positions, velocities, etc. */
74 void fgSlewUpdate( void ) {
75     struct fgFLIGHT *f;
76     struct fgCONTROLS *c;
77
78     f = &current_aircraft.flight;
79     c = &current_aircraft.controls;
80
81     /* f->Psi += ( c->aileron / 8 );
82     if ( f->Psi > FG_2PI ) {
83         f->Psi -= FG_2PI;
84     } else if ( f->Psi < 0 ) {
85         f->Psi += FG_2PI;
86     }
87
88     f->vel_x = -c->elev;
89
90     f->pos_x = f->pos_x + (cos(f->Psi) * f->vel_x);
91     f->pos_y = f->pos_y + (sin(f->Psi) * f->vel_x); */
92 }
93
94
95 /* $Log$
96 /* Revision 1.10  1998/01/27 00:47:53  curt
97 /* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
98 /* system and commandline/config file processing code.
99 /*
100  * Revision 1.9  1998/01/19 19:27:06  curt
101  * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
102  * This should simplify things tremendously.
103  *
104  * Revision 1.8  1998/01/19 18:40:30  curt
105  * Tons of little changes to clean up the code and to remove fatal errors
106  * when building with the c++ compiler.
107  *
108  * Revision 1.7  1997/12/15 23:54:42  curt
109  * Add xgl wrappers for debugging.
110  * Generate terrain normals on the fly.
111  *
112  * Revision 1.6  1997/08/27 03:30:11  curt
113  * Changed naming scheme of basic shared structures.
114  *
115  * Revision 1.5  1997/07/19 22:35:06  curt
116  * Moved fiddled with PI to avoid compiler warnings.
117  *
118  * Revision 1.4  1997/06/21 17:12:51  curt
119  * Capitalized subdirectory names.
120  *
121  * Revision 1.3  1997/05/29 22:40:00  curt
122  * Working on incorporating the LaRCsim flight model.
123  *
124  * Revision 1.2  1997/05/29 12:30:19  curt
125  * Some initial mods to work better in a timer environment.
126  *
127  * Revision 1.1  1997/05/29 02:29:42  curt
128  * Moved to their own directory.
129  *
130  * Revision 1.2  1997/05/23 15:40:37  curt
131  * Added GNU copyright headers.
132  *
133  * Revision 1.1  1997/05/16 16:04:45  curt
134  * Initial revision.
135  *
136  */