1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 Header: FGExternalForce.h
4 Author: Jon Berndt, Dave Culp
7 ------------- Copyright (C) 2007 Jon S. Berndt (jon@jsbsim.org) -------------
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
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
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.
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.
28 --------------------------------------------------------------------------------
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
35 #ifndef FGEXTERNALFORCE_H
36 #define FGEXTERNALFORCE_H
38 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 #include "FGFDMExec.h"
44 #include "FGJSBBase.h"
45 #include "models/propulsion/FGForce.h"
46 #include "input_output/FGPropertyManager.h"
47 #include "math/FGColumnVector3.h"
48 #include "math/FGFunction.h"
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54 #define ID_EXTERNALFORCE "$Id: FGExternalForce.h,v 1.9 2010/11/18 12:38:06 jberndt Exp $"
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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:
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
83 Much of the substance of this class is located in the FGForce base class, from
84 which this class is derived.
86 Here is the XML definition of a force (optional items are in []):
89 <force name="name" frame="BODY | LOCAL | WIND">
91 [<function> ... </function>]
93 <location unit="{IN | M}">
98 [<direction> <!-- optional initial direction vector -->
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:
111 external_reactions/{force name}/x
112 external_reactions/{force name}/y
113 external_reactions/{force name}/z
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.
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.
127 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
131 class FGExternalForce : public FGForce
135 @param FDMExec pointer to the main executive class.
137 FGExternalForce(FGFDMExec *FDMExec);
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.
144 FGExternalForce(FGFDMExec *FDMExec, Element *el, int index);
147 @param extForce a reference to an existing FGExternalForce object
149 FGExternalForce(const FGExternalForce& extForce);
154 void SetMagnitude(double mag);
155 void SetAzimuth(double az) {azimuth = az;}
157 FGColumnVector3& GetBodyForces(void);
158 double GetMagnitude(void) const {return magnitude;}
159 double GetAzimuth(void) const {return azimuth;}
160 double GetX(void) const {return vDirection(eX);}
161 double GetY(void) const {return vDirection(eY);}
162 double GetZ(void) const {return vDirection(eZ);}
163 void SetX(double x) {vDirection(eX) = x;}
164 void SetY(double y) {vDirection(eY) = y;}
165 void SetZ(double z) {vDirection(eZ) = z;}
171 FGPropertyManager* PropertyManager;
172 FGPropertyManager* Magnitude_Node;
173 FGFunction* Magnitude_Function;
174 string BasePropertyName;
175 FGColumnVector3 vDirection;
178 void unbind(FGPropertyManager *node);
179 void Debug(int from);