Branch data Line data Source code
1 : : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 : :
3 : : Header: FGExternalForce.h
4 : : Author: Jon Berndt, Dave Culp
5 : : Date started: 9/21/07
6 : :
7 : : ------------- Copyright (C) 2007 Jon S. Berndt (jon@jsbsim.org) -------------
8 : :
9 : : This program is free software; you can redistribute it and/or modify it under
10 : : the terms of the GNU Lesser General Public License as published by the Free Software
11 : : Foundation; either version 2 of the License, or (at your option) any later
12 : : version.
13 : :
14 : : This program is distributed in the hope that it will be useful, but WITHOUT
15 : : ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 : : FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17 : : details.
18 : :
19 : : You should have received a copy of the GNU Lesser General Public License along with
20 : : this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 : : Place - Suite 330, Boston, MA 02111-1307, USA.
22 : :
23 : : Further information about the GNU Lesser General Public License can also be found on
24 : : the world wide web at http://www.gnu.org.
25 : :
26 : :
27 : : HISTORY
28 : : --------------------------------------------------------------------------------
29 : : 9/21/07 JB Created
30 : :
31 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 : : SENTRY
33 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34 : :
35 : : #ifndef FGEXTERNALFORCE_H
36 : : #define FGEXTERNALFORCE_H
37 : :
38 : : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 : : INCLUDES
40 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41 : :
42 : : #include "FGFDMExec.h"
43 : : #include "FGJSBBase.h"
44 : : #include "models/propulsion/FGForce.h"
45 : : #include <string>
46 : : #include "input_output/FGPropertyManager.h"
47 : : #include "math/FGColumnVector3.h"
48 : : #include "math/FGFunction.h"
49 : :
50 : : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 : : DEFINITIONS
52 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53 : :
54 : : #define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.8 2009/10/02 10:30:09 jberndt Exp $"
55 : :
56 : : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 : : FORWARD DECLARATIONS
58 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 : :
60 : : namespace JSBSim {
61 : :
62 : : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 : : CLASS DOCUMENTATION
64 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 : :
66 : : /** Encapsulates code that models an individual arbitrary force.
67 : : This class encapsulates an individual force applied at the specified
68 : : location on the vehicle, and oriented as specified in one of three frames:
69 : :
70 : : - BODY frame is defined with the X axis positive forward, the Y axis
71 : : positive out the right wing, and the Z axis completing the set
72 : : positive downward out the belly of the aircraft.
73 : : - LOCAL frame is a world-based frame, with X positive north, Y positive east
74 : : and Z completing the right handed system positive down towards
75 : : the center of the Earth.
76 : : - WIND frame (rotated) has X negative into the wind vector (in other words
77 : : drag is along the positive X axis), the Z axis is perpendicular to
78 : : X and positive up (lift) but in the aircraft XZ plane, and Y
79 : : completes the right handed system. This is modified from a normal
80 : : wind frame definition, which is rotated about the Y axis 180 degrees
81 : : from this WIND frame.
82 : :
83 : : Much of the substance of this class is located in the FGForce base class, from
84 : : which this class is derived.
85 : :
86 : : Here is the XML definition of a force (optional items are in []):
87 : :
88 : : @code
89 : : <force name="name" frame="BODY | LOCAL | WIND">
90 : :
91 : : [<function> ... </function>]
92 : :
93 : : <location unit="{IN | M}">
94 : : <x> {number} </x>
95 : : <y> {number} </y>
96 : : <z> {number} </z>
97 : : </location>
98 : : [<direction> <!-- optional initial direction vector -->
99 : : <x> {number} </x>
100 : : <y> {number} </y>
101 : : <z> {number} </z>
102 : : </direction>]
103 : : </force>
104 : : @endcode
105 : :
106 : : The initial direction can optionally be set by specifying a unit vector
107 : : in the chosen frame (body, local, or wind). The direction is specified
108 : : at runtime through setting any/all of the following properties:
109 : :
110 : : @code
111 : : external_reactions/{force name}/x
112 : : external_reactions/{force name}/y
113 : : external_reactions/{force name}/z
114 : : @endcode
115 : :
116 : : As an example, a parachute can be defined oriented in the wind axis frame
117 : : so the drag always acts in the drag direction - opposite the positive X
118 : : axis. That does not include the effects of parachute oscillations, but
119 : : those could be handled in the calling application.
120 : :
121 : : The force direction is not actually required to be specified as a unit
122 : : vector, but prior to the force vector being calculated, the direction
123 : : vector is normalized.
124 : :
125 : : */
126 : :
127 : : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128 : : CLASS DECLARATION
129 : : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
130 : :
131 : : class FGExternalForce : public FGForce
132 : : {
133 : : public:
134 : : /** Constructor.
135 : : @param FDMExec pointer to the main executive class.
136 : : */
137 : : FGExternalForce(FGFDMExec *FDMExec);
138 : :
139 : : /** Constructor.
140 : : @param FDMExec pointer to the main executive class.
141 : : @param el pointer to the XML element defining an individual force.
142 : : @param index the position of this force object in the whole list.
143 : : */
144 : : FGExternalForce(FGFDMExec *FDMExec, Element *el, int index);
145 : :
146 : : /** Copy Constructor
147 : : @param extForce a reference to an existing FGExternalForce object
148 : : */
149 : : FGExternalForce(const FGExternalForce& extForce);
150 : :
151 : : /// Destructor
152 : : ~FGExternalForce();
153 : :
154 : : void SetMagnitude(double mag);
155 : 0 : void SetAzimuth(double az) {azimuth = az;}
156 : :
157 : : FGColumnVector3& GetBodyForces(void);
158 : 0 : double GetMagnitude(void) const {return magnitude;}
159 : 0 : double GetAzimuth(void) const {return azimuth;}
160 : 0 : double GetX(void) const {return vDirection(eX);}
161 : 0 : double GetY(void) const {return vDirection(eY);}
162 : 0 : double GetZ(void) const {return vDirection(eZ);}
163 : 0 : void SetX(double x) {vDirection(eX) = x;}
164 : 0 : void SetY(double y) {vDirection(eY) = y;}
165 : 0 : void SetZ(double z) {vDirection(eZ) = z;}
166 : :
167 : : private:
168 : :
169 : : string Frame;
170 : : string Name;
171 : : FGPropertyManager* PropertyManager;
172 : : FGPropertyManager* Magnitude_Node;
173 : : FGFunction* Magnitude_Function;
174 : : string BasePropertyName;
175 : : FGColumnVector3 vDirection;
176 : : double magnitude;
177 : : double azimuth;
178 : : void unbind(FGPropertyManager *node);
179 : : void Debug(int from);
180 : : };
181 : : }
182 : : #endif
183 : :
|