Debian Codegraph @

src/FDM/JSBSim/models/FGExternalForce.h

raw symbols SCIP
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 ([email protected]) -------------
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
11 Software Foundation; either version 2 of the License, or (at your option) any
12 later 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
20 with this program; if not, write to the Free Software Foundation, Inc., 59
21 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 Further information about the GNU Lesser General Public License can also be
24 found on 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 "models/propulsion/FGForce.h"
43 #include "simgear/props/propertyObject.hxx"
44
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 FORWARD DECLARATIONS
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49 namespace JSBSim {
50
51 class FGParameter;
52 class Element;
53 class FGPropertyManager;
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 CLASS DECLARATION
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 class FGPropertyVector3
60 {
61 public:
62 FGPropertyVector3(void) {}
63 FGPropertyVector3(FGPropertyManager* pm, const std::string& baseName,
64 const std::string& xcmp, const std::string& ycmp,
65 const std::string& zcmp);
66
67 FGPropertyVector3& operator=(const FGColumnVector3& v) {
68 data[0] = v(1);
69 data[1] = v(2);
70 data[2] = v(3);
71
72 return *this;
73 }
74
75 operator FGColumnVector3() const {
76 return FGColumnVector3(data[0], data[1], data[2]);
77 }
78
79 FGColumnVector3 operator*(double a) const {
80 return FGColumnVector3(a * data[0], a * data[1], a * data[2]);
81 }
82
83 private:
84 SGPropObjDouble data[3];
85 };
86
87 inline FGColumnVector3 operator*(double a, const FGPropertyVector3& v) {
88 return v*a;
89 }
90
91 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 CLASS DOCUMENTATION
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
94
95 /** Encapsulates code that models an individual arbitrary force, moment or a
96 combination thereof.
97 This class encapsulates an individual reaction applied at the specified
98 location on the vehicle, and oriented as specified in one of three frames:
99
100 - BODY frame is defined with the X axis positive forward, the Y axis
101 positive out the right wing, and the Z axis completing the set
102 positive downward out the belly of the aircraft.
103 - LOCAL frame is a world-based frame, with X positive north, Y positive east
104 and Z completing the right handed system positive down towards
105 the center of the Earth.
106 - WIND frame (rotated) has X negative into the wind vector (in other words
107 drag is along the positive X axis), the Z axis is perpendicular to
108 X and positive up (lift) but in the aircraft XZ plane, and Y
109 completes the right handed system. This is modified from a normal
110 wind frame definition, which is rotated about the Y axis 180 degrees
111 from this WIND frame.
112 - INERTIAL frame refers to the ECI frame.
113
114 Much of the substance of this class is located in the FGForce base class,
115 from which this class is derived.
116
117 Here is the XML definition of a force (optional items are in []):
118
119 @code
120 <force name="name" frame="BODY | LOCAL | WIND">
121
122 [<function> ... </function>]
123
124 <location unit="{IN | M}">
125 <x> {number} </x>
126 <y> {number} </y>
127 <z> {number} </z>
128 </location>
129 [<direction> <!-- optional initial direction vector -->
130 <x> {number} </x>
131 <y> {number} </y>
132 <z> {number} </z>
133 </direction>]
134 </force>
135 @endcode
136
137 The location of the force vector, in structural coordinates, can be set at
138 runtime through the following properties:
139
140 @code
141 external_reactions/{force name}/location-x-in
142 external_reactions/{force name}/location-y-in
143 external_reactions/{force name}/location-z-in
144 @endcode
145
146 The XML definition of a moment (optional items are in []) is a bit simpler
147 because you do not need to specify the location:
148
149 @code
150 <moment name="name" frame="BODY | LOCAL | WIND">
151
152 [<function> ... </function>]
153
154 [<direction> <!-- optional initial direction vector -->
155 <x> {number} </x>
156 <y> {number} </y>
157 <z> {number} </z>
158 </direction>]
159 </moment>
160 @endcode
161
162 The initial direction can optionally be set by specifying a unit vector
163 in the chosen frame (body, local, or wind).
164
165 As an example, a parachute can be defined oriented in the wind axis frame
166 so the drag always acts in the drag direction - opposite the positive X
167 axis. That does not include the effects of parachute oscillations, but
168 those could be handled in the calling application.
169
170 The force (or moment) direction is not actually required to be specified as
171 a unit vector, but prior to the force (or moment) vector being calculated,
172 the direction vector is normalized when initialized.
173
174 The force direction can be specified at runtime through setting any/all of
175 the following properties:
176
177 @code
178 external_reactions/{force name}/x
179 external_reactions/{force name}/y
180 external_reactions/{force name}/z
181 @endcode
182
183 The moment direction can be specified at runtime through setting any/all of
184 the following properties:
185
186 @code
187 external_reactions/{moment name}/l
188 external_reactions/{moment name}/m
189 external_reactions/{moment name}/n
190 @endcode
191
192 However in that case, the direction is no longer normalized.
193
194 When no <function> has been provided in the force definition, its magnitude
195 can be specified through the following property:
196
197 @code
198 external_reactions/{force name}/magnitude
199 @endcode
200
201 When no <function> has been provided in the moment definition, its magnitude
202 can be specified through the following property:
203
204 @code
205 external_reactions/{moment name}/magnitude-lbsft
206 @endcode
207 */
208
209 class FGExternalForce : public FGForce
210 {
211 public:
212 /** Constructor.
213 @param FDMExec pointer to the main executive class.
214 @param el pointer to the XML element defining an individual force.
215 */
216 explicit FGExternalForce(FGFDMExec *FDMExec)
217 : FGForce(FDMExec), forceMagnitude(NULL), momentMagnitude(NULL)
218 { Debug(0); }
219
220 /** Copy Constructor
221 @param extForce a reference to an existing FGExternalForce object
222 */
223 FGExternalForce(const FGExternalForce& extForce);
224
225 /// Destructor
226 ~FGExternalForce() override;
227
228 void setForce(Element* el);
229 void setMoment(Element* el);
230 const FGColumnVector3& GetBodyForces(void) override;
231
232 private:
233 FGParameter* bind(Element* el, const std::string& baseName,
234 FGPropertyVector3& v);
235
236 std::string Name;
237 FGParameter *forceMagnitude, *momentMagnitude;
238 FGPropertyVector3 forceDirection, momentDirection;
239 void Debug(int from);
240 };
241 }
242 #endif