+++ /dev/null
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-\f
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-\f
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-\f
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-\f
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-\f
- Appendix: How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) 19yy name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
+++ /dev/null
-Basic Installation
-==================
-
- These are generic installation instructions.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, a file
-`config.cache' that saves the results of its tests to speed up
-reconfiguring, and a file `config.log' containing compiler output
-(useful mainly for debugging `configure').
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If at some point `config.cache'
-contains results you don't want to keep, you may remove or edit it.
-
- The file `configure.in' is used to create `configure' by a program
-called `autoconf'. You only need `configure.in' if you want to change
-it or regenerate `configure' using a newer version of `autoconf'.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
-
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
-Compilers and Options
-=====================
-
- Some systems require unusual options for compilation or linking that
-the `configure' script does not know about. You can give `configure'
-initial values for variables by setting them in the environment. Using
-a Bourne-compatible shell, you can do that on the command line like
-this:
- CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
-
-Or on systems that have the `env' program, you can do it like this:
- env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
-
-Compiling For Multiple Architectures
-====================================
-
- You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
- If you have to use a `make' that does not supports the `VPATH'
-variable, you have to compile the package for one architecture at a time
-in the source code directory. After you have installed the package for
-one architecture, use `make distclean' before reconfiguring for another
-architecture.
-
-Installation Names
-==================
-
- By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PATH'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PATH', the package will use
-PATH as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=PATH' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
- Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Specifying the System Type
-==========================
-
- There may be some features `configure' can not figure out
-automatically, but needs to determine by the type of host the package
-will run on. Usually `configure' can figure that out, but if it prints
-a message saying it can not guess the host type, give it the
-`--host=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name with three fields:
- CPU-COMPANY-SYSTEM
-
-See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the host type.
-
- If you are building compiler tools for cross-compiling, you can also
-use the `--target=TYPE' option to select the type of system they will
-produce code for and the `--build=TYPE' option to select the type of
-system on which you are compiling the package.
-
-Sharing Defaults
-================
-
- If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Operation Controls
-==================
-
- `configure' recognizes the following options to control how it
-operates.
-
-`--cache-file=FILE'
- Use and save the results of the tests in FILE instead of
- `./config.cache'. Set FILE to `/dev/null' to disable caching, for
- debugging `configure'.
-
-`--help'
- Print a summary of the options to `configure', and exit.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`--version'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`configure' also accepts some other, not widely useful, options.
-
+++ /dev/null
-SUBDIRS = Include Lib Simulator Tools Tests
-
-EXTRA_DIST = FG-FAQ.v3 README.Unix README.Linux README.MacOS README.Win32 \
- README.Win32-X README.autoconf README.gfc README.gpc README.plib \
- README.running Thanks VERSION acsite.m4 acconfig.h irix-hack.pl
-
-dist-hook:
- tar cf - Hints | (cd $(distdir); tar xvf -)
- tar cf - Simulator/FDM/JSBsim/aircraft Simulator/FDM/JSBsim/engine | (cd $(distdir); tar xvf -)
-
-
-##########################################################################
-# extra targets to do various things ...
-#
-# Use "make <target>"
-##########################################################################
-
-
-# make the base distribution with textures, sounds and a bit of
-# scenery, and all the other associated files
-
-fgfs-base: fgfs-base-tar fgfs-base-zip
-
-fgfs-base-tar:
- (cd $(HOME); \
- tar czvf fgfs-base-$(VERSION).tar.gz \
- FlightGear/[A-CE-R]* \
- FlightGear/Scenery/w120n30/w111n33 \
- FlightGear/Sounds \
- FlightGear/Textures FlightGear/Thanks \
- FlightGear/[m-r]* )
-
-fgfs-base-zip:
- (cd $(HOME); \
- zip -r fgfs-base-$(VERSION).zip \
- FlightGear/[A-CE-R]* \
- FlightGear/Scenery/w120n30/w111n33 \
- FlightGear/Sounds \
- FlightGear/Textures FlightGear/Thanks \
- FlightGear/[m-r]* )
-
-
-# make the documentation distribution
-
-fgfs-docs: fgfs-docs-tar fgfs-manual-zip
-
-fgfs-docs-tar:
- ( cd .. ; \
- tar czvf fgfs-docs-$(VERSION).tar.gz FlightGear/Docs )
-
-# fgfs-docs-zip:
-# ( cd .. ; \
-# zip -r fgfs-docs-$(VERSION).zip FlightGear/Docs )
-
-fgfs-manual-zip:
- ( cd .. ; \
- zip -r fgfs-manual-$(VERSION).zip FlightGear/Docs/InstallGuide )
-
-# make the win32-bin distribution
-
-fgfs-win32-bin:
- (cd $(HOME); \
- zip -r fgfs-win32-bin-$(VERSION).zip FlightGear/bin )
-
-# make the win32-libs distribution (depricated)
-win32-libs:
- ( zip -r ../win32-libs-$(VERSION).zip Win32/Makefile \
- Win32/README.glut Win32/cygwinb1.dll Win32/def \
- Win32/*.exp Win32/gen-def-from-errors.pl \
- Win32/glut.dll Win32/glut32.dll Win32/impdef.cpp \
- Win32/impdef.exe Win32/include \
- Win32/install.exe \
- Win32/lib Win32/zlib.lib )
-
-# make the MacOS (MWCWP3) devel support archive
-macos-devel:
- ( cd ..; zip -r MWCWP3_Support.zip FlightGear/MWCWP3_Support )
-
-# clean up dependencies
-clean-deps:
- rm -rf .deps \
- Lib/.deps Simulator/.deps Tools/.deps Test/.deps \
- Lib/*/.deps Simulator/*/.deps Tools/*/.deps \
- Lib/*/*/.deps Simulator/*/*/.deps Tools/*/*/.deps \
- Lib/*/*/*/.deps Lib/*/*/*/*/.deps \
- Tests/.deps
-
-# clean up after libtool
-clean-libs:
- rm -rf .libs Lib/.libs Simulator/.libs Tools/.libs \
- Lib/*/.libs Simulator/*/.libs Tools/*/.libs \
- Lib/*/*/.libs Simulator/*/*/.libs Tools/*/*/.libs
- rm -f Simulator/*/so_locations Lib/*/so_locations \
- Simulator/*/*/so_locations Lib/*/*/so_locations
-
-# clean up after winbloze spews random case for file names :-(
-clean-winbloze: clean-deps clean-libs
- rm -f makefile Include/makefile Lib/makefile Simulator/makefile \
- Tools/makefile \
- Lib/*/makefile Simulator/*/makefile Tools/*/makefile \
- Lib/*/*/makefile Simulator/*/*/makefile Tools/*/*/makefile \
- Tests/makefile
- rm -f Src/Main/fg.exe Tools/*/*.exe
-New in 0.6.2
-* MSVC++ and FreeBSD portability enhancements.
-* MACos fixes.
-* JSBsim updates.
-* c172 updates.
-
-New in 0.6.1
-* Tony Peden contributed a c172 flight model replacement for the
- Navion. Still needs to be debugged a bit before it is usable.
-* More MacOS portability fixes.
-* More Borland C++ fixes.
-* More IRIX fixes.
-* Fixed a bug in handling windows drive letter, colon "C:" notation.
-* Minor tweaks to the Astro sub section contributed by Durk Talsma.
-* GUI updated contributed by Norman Vine.
-* Fixed a problem with ambiguous constructors in the fgText class.
-* Updates to JSBsim contributed by Jon Berndt.
-* Created a tile load queue so that we only load one tile per frame.
- This isn't entirely satisfactory, but it reduces the length of the
- pause when crossing a tile boundary with several shorter pauses.
-* Fixed bug with passing PUI keystrokes on to glut.
-* Fixed a bug in tilecache size which caused occasional tiles to drop
- out when more than one row is scheduled "simultaneously".
-* Changes to scenery building tools to handle sliver detection and
- resolution.
-* Fixed several other minor bugs in the scenery creation tools.
-* Added urban area support to scenery creation tools.
-* Made the parallel scenery building tools a bit more robust if a
- requested client machine happens to be offline by pinging it first
- to see if it is alive.
-* Added support for libgpc's new hole tracking interface.
-
New in 0.6.0
* Tons of improvements with scenery creation. Inter-tile gaps have been
fixed, distorted textures have been fixed, real coastlines have been added,
You need to understand the concepts of 3D acceleration under Linux and
the needed libraries. An excellent source of information is the "Linux
-Quake-HOWTO" which can be found at
+3Dfx HOWTO" which can be found at
- http://www.linuxquake.com
+ http://www.gamers.org/dEngine/xf3D/howto/3Dfx-HOWTO.html
If anything seem to be wrong with your 3D setup, check there first!
grabbed the latest version of mesa, you should have everything you
need.
- Alternatively, you can use the 3D-stuff that came along with your
- Linux distribution. At least RedHat (5.3 and later) and S.u.S.E. 6.0
- (or later) contain all the things you need.
-
- - (optional) the 3DFX kernel module.
-
- Without this thingy installed, access to your accelerator board
- needs to be SUID root, which bad practice (and a _huge_ security
- hole). Get the 3DFX module from
-
- http://www.xs4all.nl/~carlo17/3dfx/index.html
-
- and install it:
-
- mkdir 3dfx
- cd 3dfx
- tar xvfz ../Dev3Dfx-2.7.tar.gz
- make
- cp 3dfx.o /lib/modules/`uname -r`/misc
- mknod /dev/3dfx c 107 0
- insmod 3dfx
-
- alternatively, you can get the RPM from there ind use rpm for
- installation.
-
- - Steve Baker's plib library.
-
- get it from
-
- http://www.woodsoup.org/projs/plib/
-
- and follow the instructions in README.plib.
-
- - (optional) the gpc and gfc libraries.
-
- Read the README.g[fp]c files to understand what they are good for
- and decide whether you need to download them. If you don't want to
- build your own sceneries, you might not need them.
-
2. Build FlightGear:
You will need the following files:
of the FlightGear binary is "fgfs".
Another problem with Linux/Glide is permission-related. All programs
-accessing the Accelerator board need root permissions (or the kernel
-module mentioned above installed). I _strongly_ recommend the latter.
+accessing the Accelerator board need root permissions. The solution is
+either to play as root or make the /usr/local/bin/fgfs binary "setuid
+root", i.e. when this binary is run root priviledges are given. Do
+this by issuing (as root)
+
+ chmod +s /usr/local/bin/fgfs
+A solution for this problem is upcoming, keep an eye on the 3Dfx
+website.
3. Install the data files
export CFLAGS="-mieee -mcpu=ev56 -Wa,-m21164a -pipe -g"
export CXXFLAGS="-mieee -mcpu=ev56 -Wa,-m21164a -pipe -g"
- ./configure
-
-
+ ./configure
\ No newline at end of file
Redid the Makefile system so it is simpler and more robust.
-WoodSoup Project http://www.woodsoup.org
+Vasily Lewis <vlewis@woodsoup.org> http://www.woodsoup.org
Provided computing resources and services so that the Flight Gear
project could have real home. This includes, web services, ftp services
shell accounts, email lists, dns services, etc.
+++ /dev/null
-dnl Process this file with autoconf to produce a configure script.
-dnl
-dnl The basis for this file was generated by autoscan(1) [pere 1998-03-19]
-dnl
-dnl $Id$
-
-AC_INIT(Simulator/Aircraft/aircraft.cxx)
-
-dnl Initialize the automake stuff
-AM_INIT_AUTOMAKE(FlightGear, 0.6.2)
-
-dnl configure other independant packages included with flight gear for
-dnl convenience
-dnl AC_CONFIG_SUBDIRS( Lib/plib )
-
-dnl Checks for programs.
-AC_PROG_MAKE_SET
-AC_PROG_CC
-AC_PROG_CXX
-AC_PROG_RANLIB
-AC_PROG_INSTALL
-AC_PROG_LN_S
-
-dnl Initialize libtool
-dnl AM_PROG_LIBTOOL
-
-dnl Initialize maintainer mode
-dnl AM_MAINTAINER_MODE
-
-dnl This is needed for AC_TRY_COMPILE later
-dnl AC_ISC_POSIX
-
-dnl Check to see if this `configure' is being run in the `Cygwin32' environment
-dnl AM_CYGWIN32
-
-dnl Specify if we want logging (testing build) or not (release build)
-# set logging default value
-# with_logging=yes
-AC_ARG_WITH(logging, [ --with-logging Include logging output (default)])
-if test "x$with_logging" = "xno" ; then
- AC_DEFINE(FG_NDEBUG)
-fi
-
-
-dnl specify if we are building with "checker"
-AC_ARG_WITH(efence, [ --with-efence Specify if we are building with "electric-fence"])
-
-if test "x$with_efence" = "xyes" ; then
- echo "Building with efence"
- LIBS= "$LIBS -lefence"
-fi
-
-dnl specify the compiled flight model
-AC_ARG_WITH(flight-model, [ --with-flight-model=xxx Specify the flight model (navion, c172)])
-
-if test "x$with_flight_model" = "xc172" ; then
- echo "Building with c172 flight model"
-else
- echo "Building with navion flight model"
-fi
-AM_CONDITIONAL(ENABLE_C172, test "x$with_flight_model" = "xc172")
-
-dnl Let the Win32 user specify if they want to build with the SGI
-dnl opengl.dll as opposed to the more standard openg32.dll
-AC_ARG_WITH(sgi-opengl, [ --with-sgi-opengl Build against SGI's opengl.dll glu.dll and glut.dll])
-
-dnl Check for MS Windows environment
-AC_CHECK_HEADER(windows.h)
-
-dnl extra library and include directories
-EXTRA_DIRS="/usr/local /usr/X11R6"
-
-if test -d /opt/X11R6 ; then
- EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6"
-fi
-
-if test "x$ac_cv_header_windows_h" = "xyes" ; then
- EXTRA_DIRS="${EXTRA_DIRS} `pwd`/Win32"
-# elif test `uname -s` = "SunOS" ; then
-# EXTRA_DIRS="${EXTRA_DIRS} `pwd`/SunOS"
-fi
-wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
-
-dnl Check for "plib" without which we cannot go on
-AC_CHECK_HEADER(plib/pu.h)
-if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
- echo
- echo "You *must* have the plib library installed on your system to build"
- echo "the FGFS simulator!"
- echo
- echo "Please see README.plib for more details."
- echo
- echo "configure aborted."
- exit
- AM_CONDITIONAL(ENABLE_PLIB_JOYSTICK, false )
-else
- dnl Use plib joystick lib
- AM_CONDITIONAL(ENABLE_PLIB_JOYSTICK, true )
-fi
-
-dnl Using AM_CONDITIONAL is a step out of the protected little
-dnl automake fold so it is potentially dangerous. But, we are
-dnl beginning to run into cases where the standard checks are not
-dnl enough. AM_CONDITIONALS are then referenced to conditionally
-dnl build a Makefile.in from a Makefile.am which lets us define custom
-dnl includes, compile alternative source files, etc.
-
-dnl Check for external variables daylight and timezone.
-AC_EXT_DAYLIGHT
-AM_CONDITIONAL(HAVE_DAYLIGHT, test "$have_daylight" = yes )
-
-AC_EXT_TIMEZONE
-AM_CONDITIONAL(HAVE_TIMEZONE, test "$have_timezone" = yes )
-
-dnl Check for Linux style audio support
-AM_CONDITIONAL(ENABLE_AUDIO_SUPPORT, \
- test -r /usr/include/soundcard.h \
- -o -r /usr/include/linux/soundcard.h \
- -o -r /usr/include/machine/soundcard.h \
- -o -r /usr/include/audio.h \
- -o "x$ac_cv_header_windows_h" = "xyes" )
-
-AM_CONDITIONAL(ENABLE_IRIX_AUDIO, test -r /usr/include/audio.h)
-
-AM_CONDITIONAL(ENABLE_WIN32_AUDIO, test "x$ac_cv_header_windows_h" = "xyes")
-
-dnl Enable serial support on Unix type systems
-AM_CONDITIONAL(ENABLE_UNIX_SERIAL, true)
-
-dnl Check for X11 (fancy)
-AC_PATH_XTRA
-
-dnl Checks for libraries.
-
-null_LIBS="$LIBS"
-
-AC_CHECK_LIB(m, cos)
-
-base_LIBS="$LIBS"
-
-AC_CHECK_LIB(socket, socket)
-AC_CHECK_LIB(X11, XCreateWindow)
-AC_CHECK_LIB(Xext, XShmCreateImage)
-AC_CHECK_LIB(Xi, XGetExtensionVersion)
-AC_CHECK_LIB(ICE, IceOpenConnection)
-AC_CHECK_LIB(SM, SmcOpenConnection)
-AC_CHECK_LIB(Xt, XtMalloc)
-AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
-
-dnl check for OpenGL related libraries
-
-if test "x$ac_cv_header_windows_h" != "xyes" ; then
- dnl Reasonable stuff for non-windoze variants ... :-)
-
- AC_CHECK_LIB(GLcore, glNewList)
- if test "x$ac_cv_lib_GLcore_glNewList" = "xno" ; then
- dnl if no GLcore, check for GL
- AC_CHECK_LIB(GL, glNewList)
- if test "x$ac_cv_lib_GL_glNewList" = "xno" ; then
- dnl if no GL, check for MesaGL
- AC_CHECK_LIB(MesaGL, glNewList)
- fi
- else
- dnl if GLcore found, then also check for GL
- AC_CHECK_LIB(GL, glXCreateContext)
- fi
-
- dnl if using mesa, check for xmesa.h
- if test "x$ac_cv_lib_MesaGL_glNewList" = "xyes" ; then
- AC_CHECK_HEADER(GL/xmesa.h)
- AM_CONDITIONAL(ENABLE_XMESA_FX, \
- test "x$ac_cv_header_GL_xmesa_h" = "xyes")
- else
- dnl force a failed check
- AM_CONDITIONAL(ENABLE_XMESA_FX, test "no" = "yes")
- fi
-
- AC_CHECK_LIB(GLU, gluLookAt)
- if test "x$ac_cv_lib_GLU_gluLookAt" = "xno" ; then
- dnl if no GLU, check for MesaGLU
- AC_CHECK_LIB(MesaGLU, gluLookAt)
- fi
-
- dnl check for glut
- AC_CHECK_LIB(glut, glutGetModifiers)
-
- dnl test for glutGameModeString, but avoid adding glut a second time into
- dnl the list of libraries
- save_LIBS="$LIBS"
- AC_CHECK_LIB(glut, glutGameModeString)
- LIBS="$save_LIBS"
-else
- dnl Win32 is a little wierd because it has to try to handle the various
- dnl winbloze-isms. We'll just do this manually for now.
-
- echo Win32 specific hacks...
- AC_DEFINE(WIN32)
-
- dnl force a failed check since we will be building under windoze
- AM_CONDITIONAL(ENABLE_XMESA_FX, test "no" = "yes")
-
- dnl just define these to true and hope for the best
- ac_cv_lib_glut_glutGetModifiers="yes"
- ac_cv_lib_glut_glutGameModeString="yes"
-
- if test "x$with_sgi_opengl" = "xyes" ; then
- echo "Building with glut.dll, glu.dll, and opengl.dll"
- WIN32_GLUT=glut
- WIN32_GLU=glu
- WIN32_OPENGL=opengl
- else
- echo "Building with glut32.dll, glu32.dll, and opengl32.dll"
- WIN32_GLUT=glut32
- WIN32_GLU=glu32
- WIN32_OPENGL=opengl32
- fi
-
- LIBS="$LIBS -l${WIN32_GLUT} -l${WIN32_GLU} -l${WIN32_OPENGL}"
- LIBS="$LIBS -luser32 -lgdi32"
- echo "Will link apps with $LIBS"
-fi
-
-if test "x$ac_cv_lib_glut_glutGetModifiers" = "xno"; then
- echo
- echo "Unable to find the necessary OpenGL or GLUT libraries."
- echo "See config.log for automated test details and results ..."
- exit 1
-fi
-
-if test "x$ac_cv_lib_glut_glutGameModeString" = "xno"; then
- echo
- echo "Your version of glut doesn't support game mode."
- echo "You need to fetch and install the latest version of glut from:"
- echo
- echo " http://reality.sgi.com/opengl/glut3/glut3.html"
- exit 1
-fi
-
-opengl_LIBS="$LIBS"
-LIBS="$base_LIBS"
-
-AC_SUBST(base_LIBS)
-AC_SUBST(opengl_LIBS)
-
-AM_CONDITIONAL(HAVE_XWINDOWS, test "x$ac_cv_lib_X11_XCreateWindow" = "xyes" )
-
-dnl Check if Generic Polygon Clipping library is installed
-dnl (from http://www.cs.man.ac.uk/aig/staff/alan/software/)
-AC_CHECK_HEADERS( gpc.h )
-if test "x$ac_cv_header_gpc_h" != "xyes"; then
- echo
- echo "You need to have the GPC library installed on your system to build"
- echo "some of the scenery generation tools, otherwise you won't be able."
- echo "to create scenery."
- echo
- echo "Please see README.gpc for more details."
- echo
- echo "(pausing 5 seconds)"
- sleep 5
- echo
-fi
-
-dnl Check if Geographic Foundation Classes library is installed
-dnl (from ftp://ftp.flightgear.org/pub/fgfs/Source/)
-AC_CHECK_HEADERS( gfc/gdbf.h )
-if test "x$ac_cv_header_gfc_gdbf_h" != "xyes"; then
- echo
- echo "You need to have the GFC library installed on your system to build"
- echo "some of the scenery generation tools, otherwise, they may fail."
- echo
- echo "Please see README.gfc for more details."
- echo
- echo "(pausing 5 seconds)"
- sleep 5
- echo
-fi
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS( \
- fcntl.h getopt.h malloc.h memory.h stdlib.h sys/stat.h sys/time.h \
- sys/timeb.h unistd.h windows.h winbase.h values.h )
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_TYPE_SIZE_T
-AC_HEADER_TIME
-AC_STRUCT_TM
-
-dnl Checks for library functions.
-AC_TYPE_SIGNAL
-AC_FUNC_VPRINTF
-AC_CHECK_FUNCS( ftime gettimeofday memcpy bcopy mktime strstr rand random \
- setitimer getitimer signal GetLocalTime rint getrusage )
-
-AM_CONFIG_HEADER(Include/config.h)
-
-AC_OUTPUT( \
- VERSION \
- Makefile \
- Include/Makefile \
- Lib/Makefile \
- Lib/Bucket/Makefile \
- Lib/Debug/Makefile \
- Lib/Math/Makefile \
- Lib/Misc/Makefile \
- Lib/Serial/Makefile \
- Lib/XGL/Makefile \
- Lib/zlib/Makefile \
- Simulator/Makefile \
- Simulator/Aircraft/Makefile \
- Simulator/Airports/Makefile \
- Simulator/Astro/Makefile \
- Simulator/Autopilot/Makefile \
- Simulator/Cockpit/Makefile \
- Simulator/Controls/Makefile \
- Simulator/FDM/External/Makefile \
- Simulator/FDM/JSBsim/Makefile \
- Simulator/FDM/LaRCsim/Makefile \
- Simulator/FDM/Slew/Makefile \
- Simulator/FDM/Makefile \
- Simulator/GUI/Makefile \
- Simulator/Joystick/Makefile \
- Simulator/Main/Makefile \
- Simulator/Main/runfgfs \
- Simulator/Main/runfgfs.bat \
- Simulator/Makefile \
- Simulator/Objects/Makefile \
- Simulator/Scenery/Makefile \
- Simulator/Time/Makefile \
- Simulator/Weather/Makefile \
- Tools/Makefile \
- Tools/Construct/Makefile \
- Tools/Construct/Array/Makefile \
- Tools/Construct/Clipper/Makefile \
- Tools/Construct/Combine/Makefile \
- Tools/Construct/GenOutput/Makefile \
- Tools/Construct/Match/Makefile \
- Tools/Construct/Triangulate/Makefile \
- Tools/Construct/Main/Makefile \
- Tools/Construct/Parallel/Makefile \
- Tools/Lib/Makefile \
- Tools/Lib/DEM/Makefile \
- Tools/Lib/Polygon/Makefile \
- Tools/Lib/Triangle/Makefile \
- Tools/Prep/Makefile \
- Tools/Prep/DemChop/Makefile \
- Tools/Prep/DemInfo/Makefile \
- Tools/Prep/DemRaw2ascii/Makefile \
- Tools/Prep/GenAirports/Makefile \
- Tools/Prep/ShapeFile/Makefile \
- Tools/Utils/Makefile \
- Tests/Makefile \
-)
-
-AC_OUTPUT_COMMANDS([chmod 755 Simulator/Main/runfgfs])
-
+++ /dev/null
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5 (mit/util/scripts/install.sh).
-#
-# Copyright 1991 by the Massachusetts Institute of Technology
-#
-# Permission to use, copy, modify, distribute, and sell this software and its
-# documentation for any purpose is hereby granted without fee, provided that
-# the above copyright notice appear in all copies and that both that
-# copyright notice and this permission notice appear in supporting
-# documentation, and that the name of M.I.T. not be used in advertising or
-# publicity pertaining to distribution of the software without specific,
-# written prior permission. M.I.T. makes no representations about the
-# suitability of this software for any purpose. It is provided "as is"
-# without express or implied warranty.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch. It can only install one file at a time, a restriction
-# shared with many OS's install programs.
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
+++ /dev/null
-#!/usr/bin/perl
-
-$file = shift(@ARGV);
-
-print "Fixing $file\n";
-
-open(IN, "<$file") || die "cannot open $file for reading\n";
-open(OUT, ">$file.new") || die "cannot open $file.new for writting\n";
-
-while (<IN>) {
- s/^AR = ar$/AR = CC -ar/;
- s/\$\(AR\) cru /\$\(AR\) -o /;
- print OUT $_;
-}
-
-rename("$file.new", "$file") || die "cannot rename $file.new to $file\n";
+++ /dev/null
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
-# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-if test $# -eq 0; then
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
-fi
-
-case "$1" in
-
- -h|--h|--he|--hel|--help)
- echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
- -h, --help display this help and exit
- -v, --version output version information and exit
-
-Supported PROGRAM values:
- aclocal touch file \`aclocal.m4'
- autoconf touch file \`configure'
- autoheader touch file \`config.h.in'
- automake touch all \`Makefile.in' files
- bison touch file \`y.tab.c'
- makeinfo touch the output file
- yacc touch file \`y.tab.c'"
- ;;
-
- -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
- echo "missing - GNU libit 0.0"
- ;;
-
- -*)
- echo 1>&2 "$0: Unknown \`$1' option"
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
- ;;
-
- aclocal)
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`acinclude.m4' or \`configure.in'. You might want
- to install the \`Automake' and \`Perl' packages. Grab them from
- any GNU archive site."
- touch aclocal.m4
- ;;
-
- autoconf)
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`configure.in'. You might want to install the
- \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
- archive site."
- touch configure
- ;;
-
- autoheader)
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`acconfig.h' or \`configure.in'. You might want
- to install the \`Autoconf' and \`GNU m4' packages. Grab them
- from any GNU archive site."
- touch config.h.in
- ;;
-
- automake)
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
- You might want to install the \`Automake' and \`Perl' packages.
- Grab them from any GNU archive site."
- find . -type f -name Makefile.am -print \
- | sed 's/^\(.*\).am$/touch \1.in/' \
- | sh
- ;;
-
- bison|yacc)
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified a \`.y' file. You may need the \`Bison' package
- in order for those modifications to take effect. You can get
- \`Bison' from any GNU archive site."
- touch y.tab.c
- ;;
-
- makeinfo)
- echo 1>&2 "\
-WARNING: \`$1' is missing on your system. You should only need it if
- you modified a \`.texi' or \`.texinfo' file, or any other file
- indirectly affecting the aspect of the manual. The spurious
- call might also be the consequence of using a buggy \`make' (AIX,
- DU, IRIX). You might want to install the \`Texinfo' package or
- the \`GNU make' package. Grab either from any GNU archive site."
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
- fi
- touch $file
- ;;
-
- *)
- echo 1>&2 "\
-WARNING: \`$1' is needed, and you do not seem to have it handy on your
- system. You might have modified some files without having the
- proper tools for further handling them. Check the \`README' file,
- it often tells you about the needed prerequirements for installing
- this package. You may also peek at any GNU archive site, in case
- some other package would contain this missing \`$1' program."
- exit 1
- ;;
-esac
-
-exit 0
+++ /dev/null
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain
-
-# $Id$
-
-errstatus=0
-
-for file
-do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
-
- pathcomp=
- for d
- do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
-
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp" 1>&2
-
- mkdir "$pathcomp" || lasterr=$?
-
- if test ! -d "$pathcomp"; then
- errstatus=$lasterr
- fi
- fi
-
- pathcomp="$pathcomp/"
- done
-done
-
-exit $errstatus
-
-# mkinstalldirs ends here
#include <Include/compiler.h>
#include <Debug/logstream.hxx>
-#include <Misc/fgpath.hxx>
#include <Misc/fgstream.hxx>
#include <Main/options.hxx>
fgAIRPORT a;
// build the path name to the airport file
- FGPath path( current_options.get_fg_root() );
- path.append( "Airports" );
- path.append( file );
+ string path = current_options.get_fg_root() + "/Airports/" + file;
airports.erase( airports.begin(), airports.end() );
- fg_gzifstream in( path.str() );
- if ( !in.is_open() ) {
- FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << path.str() );
+ fg_gzifstream in( path );
+ if ( !in ) {
+ FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << path );
exit(-1);
}
*/
// read in each line of the file
-
-#ifdef __MWERKS__
-
in >> skipcomment;
- char c = 0;
- while ( in.get(c) && c != '\0' ) {
- in.putback(c);
- in >> a;
- airports.insert(a);
- in >> skipcomment;
- }
-
-#else
-
- in >> skipcomment;
- while ( ! in.eof() ) {
+ while ( ! in.eof() )
+ {
in >> a;
airports.insert(a);
in >> skipcomment;
}
-#endif
-
return 1;
}
+++ /dev/null
-noinst_LIBRARIES = libAstro.a
-
-libAstro_a_SOURCES = \
- celestialBody.cxx celestialBody.hxx \
- jupiter.cxx jupiter.hxx \
- mars.cxx mars.hxx \
- mercury.cxx mercury.hxx \
- moon.cxx moon.hxx \
- neptune.cxx neptune.hxx \
- pluto.hxx \
- saturn.cxx saturn.hxx \
- sky.cxx sky.hxx \
- solarsystem.cxx solarsystem.hxx \
- star.cxx star.hxx \
- stars.cxx stars.hxx \
- uranus.cxx uranus.hxx \
- venus.cxx venus.hxx
-
-INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
+++ /dev/null
-/**************************************************************************
- * celestialBody.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#include "celestialBody.hxx"
-#include "star.hxx"
-#include <Debug/logstream.hxx>
-
-#ifdef FG_MATH_EXCEPTION_CLASH
-# define exception c_exception
-#endif
-#include <math.h>
-
-/**************************************************************************
- * void CelestialBody::updatePosition(fgTIME *t, Star *ourSun)
- *
- * Basically, this member function provides a general interface for
- * calculating the right ascension and declinaion. This function is
- * used for calculating the planetary positions. For the planets, an
- * overloaded member function is provided to additionally calculate the
- * planet's magnitude.
- * The sun and moon have their own overloaded updatePosition member, as their
- * position is calculated an a slightly different manner.
- *
- * arguments:
- * fgTIME t: provides the current time.
- * Star *ourSun: the sun's position is needed to convert heliocentric
- * coordinates into geocentric coordinates.
- *
- * return value: none
- *
- *************************************************************************/
-void CelestialBody::updatePosition(FGTime *t, Star *ourSun)
-{
- double eccAnom, v, ecl, actTime,
- xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
-
- updateOrbElements(t);
- actTime = fgCalcActTime(t);
-
- // calcualate the angle bewteen ecliptic and equatorial coordinate system
- ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 *actTime);
-
- eccAnom = fgCalcEccAnom(M, e); //calculate the eccentric anomaly
- xv = a * (cos(eccAnom) - e);
- yv = a * (sqrt (1.0 - e*e) * sin(eccAnom));
- v = atan2(yv, xv); // the planet's true anomaly
- r = sqrt (xv*xv + yv*yv); // the planet's distance
-
- // calculate the planet's position in 3D space
- xh = r * (cos(N) * cos(v+w) - sin(N) * sin(v+w) * cos(i));
- yh = r * (sin(N) * cos(v+w) + cos(N) * sin(v+w) * cos(i));
- zh = r * (sin(v+w) * sin(i));
-
- // calculate the ecliptic longitude and latitude
- xg = xh + ourSun->getxs();
- yg = yh + ourSun->getys();
- zg = zh;
-
- lonEcl = atan2(yh, xh);
- latEcl = atan2(zh, sqrt(xh*xh+yh*yh));
-
- xe = xg;
- ye = yg * cos(ecl) - zg * sin(ecl);
- ze = yg * sin(ecl) + zg * cos(ecl);
- rightAscension = atan2(ye, xe);
- declination = atan2(ze, sqrt(xe*xe + ye*ye));
- FG_LOG(FG_GENERAL, FG_INFO, "Planet found at : "
- << rightAscension << " (ra), " << declination << " (dec)" );
-
- //calculate some variables specific to calculating the magnitude
- //of the planet
- R = sqrt (xg*xg + yg*yg + zg*zg);
- s = ourSun->getDistance();
-
- // It is possible from these calculations for the argument to acos
- // to exceed the valid range for acos(). So we do a little extra
- // checking.
-
- double tmp = (r*r + R*R - s*s) / (2*r*R);
- if ( tmp > 1.0) {
- tmp = 1.0;
- } else if ( tmp < -1.0) {
- tmp = -1.0;
- }
-
- FV = RAD_TO_DEG * acos( tmp );
-};
-
-/****************************************************************************
- * double CelestialBody::fgCalcEccAnom(double M, double e)
- * this private member calculates the eccentric anomaly of a celestial body,
- * given its mean anomaly and eccentricity.
- *
- * -Mean anomaly: the approximate angle between the perihelion and the current
- * position. this angle increases uniformly with time.
- *
- * True anomaly: the actual angle between perihelion and current position.
- *
- * Eccentric anomaly: this is an auxilary angle, used in calculating the true
- * anomaly from the mean anomaly.
- *
- * -eccentricity. Indicates the amount in which the orbit deviates from a
- * circle (0 = circle, 0-1, is ellipse, 1 = parabola, > 1 = hyperbola).
- *
- * This function is also known as solveKeplersEquation()
- *
- * arguments:
- * M: the mean anomaly
- * e: the eccentricity
- *
- * return value:
- * the eccentric anomaly
- *
- ****************************************************************************/
-double CelestialBody::fgCalcEccAnom(double M, double e)
-{
- double
- eccAnom, E0, E1, diff;
-
- eccAnom = M + e * sin(M) * (1.0 + e * cos (M));
- // iterate to achieve a greater precision for larger eccentricities
- if (e > 0.05)
- {
- E0 = eccAnom;
- do
- {
- E1 = E0 - (E0 - e * sin(E0) - M) / (1 - e *cos(E0));
- diff = fabs(E0 - E1);
- E0 = E1;
- }
- while (diff > (DEG_TO_RAD * 0.001));
- return E0;
- }
- return eccAnom;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-/**************************************************************************
- * celestialBody.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-
-#ifndef _CELESTIALBODY_H_
-#define _CELESTIALBODY_H_
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-
-#include <Time/fg_time.hxx>
-#include <Include/fg_constants.h>
-
-class Star;
-
-class CelestialBody
-{
-protected: // make the data protected, in order to give the inherited
- // classes direct access to the data
- double NFirst; /* longitude of the ascending node first part */
- double NSec; /* longitude of the ascending node second part */
- double iFirst; /* inclination to the ecliptic first part */
- double iSec; /* inclination to the ecliptic second part */
- double wFirst; /* first part of argument of perihelion */
- double wSec; /* second part of argument of perihelion */
- double aFirst; /* semimayor axis first part*/
- double aSec; /* semimayor axis second part */
- double eFirst; /* eccentricity first part */
- double eSec; /* eccentricity second part */
- double MFirst; /* Mean anomaly first part */
- double MSec; /* Mean anomaly second part */
-
- double N, i, w, a, e, M; /* the resulting orbital elements, obtained from the former */
-
- double rightAscension, declination;
- double r, R, s, FV;
- double magnitude;
- double lonEcl, latEcl;
-
- double fgCalcEccAnom(double M, double e);
- double fgCalcActTime(FGTime *t);
- void updateOrbElements(FGTime *t);
-
-public:
- CelestialBody(double Nf, double Ns,
- double If, double Is,
- double wf, double ws,
- double af, double as,
- double ef, double es,
- double Mf, double Ms, FGTime *t);
- void getPos(double *ra, double *dec);
- void getPos(double *ra, double *dec, double *magnitude);
- double getLon();
- double getLat();
- void updatePosition(FGTime *t, Star *ourSun);
-};
-
-/*****************************************************************************
- * inline CelestialBody::CelestialBody
- * public constructor for a generic celestialBody object.
- * initializes the 6 primary orbital elements. The elements are:
- * N: longitude of the ascending node
- * i: inclination to the ecliptic
- * w: argument of perihelion
- * a: semi-major axis, or mean distance from the sun
- * e: eccenticity
- * M: mean anomaly
- * Each orbital element consists of a constant part and a variable part that
- * gradually changes over time.
- *
- * Argumetns:
- * the 13 arguments to the constructor constitute the first, constant
- * ([NiwaeM]f) and the second variable ([NiwaeM]s) part of the orbital
- * elements. The 13th argument is the current time. Note that the inclination
- * is written with a capital (If, Is), because 'if' is a reserved word in the
- * C/C++ programming language.
- ***************************************************************************/
-inline CelestialBody::CelestialBody(double Nf, double Ns,
- double If, double Is,
- double wf, double ws,
- double af, double as,
- double ef, double es,
- double Mf, double Ms, FGTime *t)
-{
- NFirst = Nf; NSec = Ns;
- iFirst = If; iSec = Is;
- wFirst = wf; wSec = ws;
- aFirst = af; aSec = as;
- eFirst = ef; eSec = es;
- MFirst = Mf; MSec = Ms;
- updateOrbElements(t);
-};
-
-/****************************************************************************
- * inline void CelestialBody::updateOrbElements(FGTime *t)
- * given the current time, this private member calculates the actual
- * orbital elements
- *
- * Arguments: FGTime *t: the current time:
- *
- * return value: none
- ***************************************************************************/
-inline void CelestialBody::updateOrbElements(FGTime *t)
-{
- double actTime = fgCalcActTime(t);
- M = DEG_TO_RAD * (MFirst + (MSec * actTime));
- w = DEG_TO_RAD * (wFirst + (wSec * actTime));
- N = DEG_TO_RAD * (NFirst + (NSec * actTime));
- i = DEG_TO_RAD * (iFirst + (iSec * actTime));
- e = eFirst + (eSec * actTime);
- a = aFirst + (aSec * actTime);
-}
-/*****************************************************************************
- * inline double CelestialBody::fgCalcActTime(FGTime *t)
- * this private member function returns the offset in days from the epoch for
- * wich the orbital elements are calculated (Jan, 1st, 2000).
- *
- * Argument: the current time
- *
- * return value: the (fractional) number of days until Jan 1, 2000.
- ****************************************************************************/
-inline double CelestialBody::fgCalcActTime(FGTime *t)
-{
- return (t->getMjd() - 36523.5);
-}
-
-/*****************************************************************************
- * inline void CelestialBody::getPos(double* ra, double* dec)
- * gives public access to Right Ascension and declination
- *
- ****************************************************************************/
-inline void CelestialBody::getPos(double* ra, double* dec)
-{
- *ra = rightAscension;
- *dec = declination;
-}
-
-/*****************************************************************************
- * inline void CelestialBody::getPos(double* ra, double* dec, double* magnitude
- * gives public acces to the current Right ascension, declination, and
- * magnitude
- ****************************************************************************/
-inline void CelestialBody::getPos(double* ra, double* dec, double* magn)
-{
- *ra = rightAscension;
- *dec = declination;
- *magn = magnitude;
-}
-
-inline double CelestialBody::getLon()
-{
- return lonEcl;
-}
-
-inline double CelestialBody::getLat()
-{
- return latEcl;
-}
-
-#endif // _CELESTIALBODY_H_
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-/**************************************************************************
- * jupiter.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-#include "jupiter.hxx"
-
-/*************************************************************************
- * Jupiter::Jupiter(FGTime *t)
- * Public constructor for class Jupiter
- * Argument: The current time.
- * the hard coded orbital elements for Jupiter are passed to
- * CelestialBody::CelestialBody();
- ************************************************************************/
-Jupiter::Jupiter(FGTime *t) :
- CelestialBody(100.4542, 2.7685400E-5,
- 1.3030, -1.557E-7,
- 273.8777, 1.6450500E-5,
- 5.2025600, 0.000000,
- 0.048498, 4.469E-9,
- 19.89500, 0.08308530010, t)
-{
-}
-
-/*************************************************************************
- * void Jupiter::updatePosition(FGTime *t, Star *ourSun)
- *
- * calculates the current position of Jupiter, by calling the base class,
- * CelestialBody::updatePosition(); The current magnitude is calculated using
- * a Jupiter specific equation
- *************************************************************************/
-void Jupiter::updatePosition(FGTime *t, Star *ourSun)
-{
- CelestialBody::updatePosition(t, ourSun);
- magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV;
-}
-
-
-
-
+++ /dev/null
-/**************************************************************************
- * jupiter.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _JUPITER_HXX_
-#define _JUPITER_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-#include "star.hxx"
-
-class Jupiter : public CelestialBody
-{
-public:
- Jupiter (FGTime *t);
- void updatePosition(FGTime *t, Star *ourSun);
-};
-
-#endif // _JUPITER_HXX_
+++ /dev/null
-/**************************************************************************
- * mars.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-#include "mars.hxx"
-
-/*************************************************************************
- * Mars::Mars(FGTime *t)
- * Public constructor for class Mars
- * Argument: The current time.
- * the hard coded orbital elements for Mars are passed to
- * CelestialBody::CelestialBody();
- ************************************************************************/
-Mars::Mars(FGTime *t) :
- CelestialBody(49.55740, 2.1108100E-5,
- 1.8497, -1.78E-8,
- 286.5016, 2.9296100E-5,
- 1.5236880, 0.000000,
- 0.093405, 2.516E-9,
- 18.60210, 0.52402077660, t)
-{
-}
-/*************************************************************************
- * void Mars::updatePosition(FGTime *t, Star *ourSun)
- *
- * calculates the current position of Mars, by calling the base class,
- * CelestialBody::updatePosition(); The current magnitude is calculated using
- * a Mars specific equation
- *************************************************************************/
-void Mars::updatePosition(FGTime *t, Star *ourSun)
-{
- CelestialBody::updatePosition(t, ourSun);
- magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV;
-}
+++ /dev/null
-/**************************************************************************
- * mars.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _MARS_HXX_
-#define _MARS_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-#include "star.hxx"
-
-class Mars : public CelestialBody
-{
-public:
- Mars ( FGTime *t);
- void updatePosition(FGTime *t, Star *ourSun);
-};
-
-#endif // _MARS_HXX_
+++ /dev/null
-/**************************************************************************
- * mercury.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-#include "mercury.hxx"
-
-/*************************************************************************
- * Mercury::Mercury(FGTime *t)
- * Public constructor for class Mercury
- * Argument: The current time.
- * the hard coded orbital elements for Mercury are passed to
- * CelestialBody::CelestialBody();
- ************************************************************************/
-Mercury::Mercury(FGTime *t) :
- CelestialBody (48.33130, 3.2458700E-5,
- 7.0047, 5.00E-8,
- 29.12410, 1.0144400E-5,
- 0.3870980, 0.000000,
- 0.205635, 5.59E-10,
- 168.6562, 4.09233443680, t)
-{
-}
-/*************************************************************************
- * void Mercury::updatePosition(FGTime *t, Star *ourSun)
- *
- * calculates the current position of Mercury, by calling the base class,
- * CelestialBody::updatePosition(); The current magnitude is calculated using
- * a Mercury specific equation
- *************************************************************************/
-void Mercury::updatePosition(FGTime *t, Star *ourSun)
-{
- CelestialBody::updatePosition(t, ourSun);
- magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6);
-}
-
-
+++ /dev/null
-/**************************************************************************
- * mercury.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _MERCURY_HXX_
-#define _MERCURY_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-#include "star.hxx"
-
-class Mercury : public CelestialBody
-{
-public:
- Mercury ( FGTime *t);
- void updatePosition(FGTime *t, Star* ourSun);
-};
-
-#endif // _MERURY_HXX_
+++ /dev/null
-/**************************************************************************
- * moon.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#include <FDM/flight.hxx>
-
-#include <string.h>
-#include "moon.hxx"
-
-#include <Debug/logstream.hxx>
-#include <Main/options.hxx>
-#include <Misc/fgpath.hxx>
-#include <Objects/texload.h>
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-
-/*************************************************************************
- * Moon::Moon(FGTime *t)
- * Public constructor for class Moon. Initializes the orbital elements and
- * sets up the moon texture.
- * Argument: The current time.
- * the hard coded orbital elements for Moon are passed to
- * CelestialBody::CelestialBody();
- ************************************************************************/
-Moon::Moon(FGTime *t) :
- CelestialBody(125.1228, -0.0529538083,
- 5.1454, 0.00000,
- 318.0634, 0.1643573223,
- 60.266600, 0.000000,
- 0.054900, 0.000000,
- 115.3654, 13.0649929509, t)
-{
- int width, height;
-
- FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
-#ifdef GL_VERSION_1_1
- xglGenTextures(1, &moon_texid);
- xglBindTexture(GL_TEXTURE_2D, moon_texid);
-#elif GL_EXT_texture_object
- xglGenTexturesEXT(1, &moon_texid);
- xglBindTextureEXT(GL_TEXTURE_2D, moon_texid);
-#else
-# error port me
-#endif
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- // load in the texture data
- FGPath tpath( current_options.get_fg_root() );
- tpath.append( "Textures" );
- tpath.append( "moon.rgb" );
-
- if ( (moon_texbuf = read_rgb_texture(tpath.c_str(), &width, &height))
- == NULL )
- {
- // Try compressed
- FGPath fg_tpath = tpath;
- fg_tpath.append( ".gz" );
- if ( (moon_texbuf = read_rgb_texture(fg_tpath.c_str(), &width, &height))
- == NULL )
- {
- FG_LOG( FG_GENERAL, FG_ALERT,
- "Error in loading moon texture " << tpath.str() );
- exit(-1);
- }
- }
-
- glTexImage2D( GL_TEXTURE_2D,
- 0,
- GL_RGB,
- 256, 256,
- 0,
- GL_RGB, GL_UNSIGNED_BYTE,
- moon_texbuf);
-
- // setup the halo texture
- FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
-#ifdef GL_VERSION_1_1
- xglGenTextures(1, &moon_halotexid);
- xglBindTexture(GL_TEXTURE_2D, moon_halotexid);
-#elif GL_EXT_texture_object
- xglGenTexturesEXT(1, &moon_halotexid);
- xglBindTextureEXT(GL_TEXTURE_2D, moon_halotexid);
-#else
-# error port me
-#endif
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- setHalo();
- glTexImage2D( GL_TEXTURE_2D,
- 0,
- GL_RGBA,
- 256, 256,
- 0,
- GL_RGBA, GL_UNSIGNED_BYTE,
- moon_halotexbuf);
- moonObject = gluNewQuadric();
-}
-
-Moon::~Moon()
-{
- //delete moonObject;
- delete moon_texbuf;
- delete moon_halotexbuf;
-}
-
-
-static int texWidth = 256; /* 64x64 is plenty */
-
-void Moon::setHalo()
-{
- int texSize;
- //void *textureBuf;
- GLubyte *p;
- int i,j;
- double radius;
-
- texSize = texWidth*texWidth;
-
- moon_halotexbuf = new GLubyte[texSize*4];
- if (!moon_halotexbuf)
- return; // Ugly!
-
- p = moon_halotexbuf;
-
- radius = (double)(texWidth / 2);
-
- for (i=0; i < texWidth; i++) {
- for (j=0; j < texWidth; j++) {
- double x, y, d;
-
- x = fabs((double)(i - (texWidth / 2)));
- y = fabs((double)(j - (texWidth / 2)));
-
- d = sqrt((x * x) + (y * y));
- if (d < radius)
- {
- double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
- // inverse square looks nice
- *p = (int)((double)0xff * (t * t));
- *(p+1) = (int)((double) 0xff * (t*t));
- *(p+2) = (int)((double) 0xff * (t*t));
- *(p+3) = 0x11;
- }
- else
- {
- *p = 0x00;
- *(p+1) = 0x00;
- *(p+2) = 0x00;
- *(p+3) = 0x11;
- }
- p += 4;
- }
- }
- //gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
- // GL_LUMINANCE,
- // GL_UNSIGNED_BYTE, textureBuf);
- //free(textureBuf);
-}
-
-
-/*****************************************************************************
- * void Moon::updatePosition(FGTime *t, Star *ourSun)
- * this member function calculates the actual topocentric position (i.e.)
- * the position of the moon as seen from the current position on the surface
- * of the moon.
- ****************************************************************************/
-void Moon::updatePosition(FGTime *t, Star *ourSun)
-{
- double
- eccAnom, ecl, actTime,
- xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
- Ls, Lm, D, F, mpar, gclat, rho, HA, g,
- geoRa, geoDec;
-
- fgAIRCRAFT *air;
- FGInterface *f;
-
- air = ¤t_aircraft;
- f = air->fdm_state;
-
- updateOrbElements(t);
- actTime = fgCalcActTime(t);
-
- // calculate the angle between ecliptic and equatorial coordinate system
- // in Radians
- ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
- eccAnom = fgCalcEccAnom(M, e); // Calculate the eccentric anomaly
- xv = a * (cos(eccAnom) - e);
- yv = a * (sqrt(1.0 - e*e) * sin(eccAnom));
- v = atan2(yv, xv); // the moon's true anomaly
- r = sqrt (xv*xv + yv*yv); // and its distance
-
- // estimate the geocentric rectangular coordinates here
- xh = r * (cos(N) * cos (v+w) - sin (N) * sin(v+w) * cos(i));
- yh = r * (sin(N) * cos (v+w) + cos (N) * sin(v+w) * cos(i));
- zh = r * (sin(v+w) * sin(i));
-
- // calculate the ecliptic latitude and longitude here
- lonEcl = atan2 (yh, xh);
- latEcl = atan2(zh, sqrt(xh*xh + yh*yh));
-
- /* Calculate a number of perturbatioin, i.e. disturbances caused by the
- * gravitational infuence of the sun and the other major planets.
- * The largest of these even have a name */
- Ls = ourSun->getM() + ourSun->getw();
- Lm = M + w + N;
- D = Lm - Ls;
- F = Lm - N;
-
- lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D)
- +0.658 * sin (2*D)
- -0.186 * sin(ourSun->getM())
- -0.059 * sin(2*M - 2*D)
- -0.057 * sin(M - 2*D + ourSun->getM())
- +0.053 * sin(M + 2*D)
- +0.046 * sin(2*D - ourSun->getM())
- +0.041 * sin(M - ourSun->getM())
- -0.035 * sin(D)
- -0.031 * sin(M + ourSun->getM())
- -0.015 * sin(2*F - 2*D)
- +0.011 * sin(M - 4*D)
- );
- latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D)
- -0.055 * sin(M - F - 2*D)
- -0.046 * sin(M + F - 2*D)
- +0.033 * sin(F + 2*D)
- +0.017 * sin(2*M + F)
- );
- r += (-0.58 * cos(M - 2*D)
- -0.46 * cos(2*D)
- );
- FG_LOG(FG_GENERAL, FG_INFO, "Running moon update");
- xg = r * cos(lonEcl) * cos(latEcl);
- yg = r * sin(lonEcl) * cos(latEcl);
- zg = r * sin(latEcl);
-
- xe = xg;
- ye = yg * cos(ecl) -zg * sin(ecl);
- ze = yg * sin(ecl) +zg * cos(ecl);
-
- geoRa = atan2(ye, xe);
- geoDec = atan2(ze, sqrt(xe*xe + ye*ye));
-
- /* FG_LOG( FG_GENERAL, FG_INFO,
- "(geocentric) geoRa = (" << (RAD_TO_DEG * geoRa)
- << "), geoDec= (" << (RAD_TO_DEG * geoDec) << ")" ); */
-
-
- // Given the moon's geocentric ra and dec, calculate its
- // topocentric ra and dec. i.e. the position as seen from the
- // surface of the earth, instead of the center of the earth
-
- // First calculate the moon's parrallax, that is, the apparent size of the
- // (equatorial) radius of the earth, as seen from the moon
- mpar = asin ( 1 / r);
- // FG_LOG( FG_GENERAL, FG_INFO, "r = " << r << " mpar = " << mpar );
- // FG_LOG( FG_GENERAL, FG_INFO, "lat = " << f->get_Latitude() );
-
- gclat = f->get_Latitude() - 0.003358 *
- sin (2 * DEG_TO_RAD * f->get_Latitude() );
- // FG_LOG( FG_GENERAL, FG_INFO, "gclat = " << gclat );
-
- rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * f->get_Latitude());
- // FG_LOG( FG_GENERAL, FG_INFO, "rho = " << rho );
-
- if (geoRa < 0)
- geoRa += (2*FG_PI);
-
- HA = t->getLst() - (3.8197186 * geoRa);
- /* FG_LOG( FG_GENERAL, FG_INFO, "t->getLst() = " << t->getLst()
- << " HA = " << HA ); */
-
- g = atan (tan(gclat) / cos ((HA / 3.8197186)));
- // FG_LOG( FG_GENERAL, FG_INFO, "g = " << g );
-
- rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec);
- declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g);
-
- /* FG_LOG( FG_GENERAL, FG_INFO,
- "Ra = (" << (RAD_TO_DEG *rightAscension)
- << "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); */
-}
-
-
-/************************************************************************
- * void Moon::newImage()
- *
- * This function regenerates a new visual image of the moon, which is added to
- * solarSystem display list.
- *
- * Arguments: Right Ascension and declination
- *
- * return value: none
- **************************************************************************/
-void Moon::newImage()
-{
- fgLIGHT *l = &cur_light_params;
- float moon_angle = l->moon_angle;
-
- /*double x_2, x_4, x_8, x_10;
- GLfloat ambient;
- GLfloat amb[4];*/
- int moonSize = 750;
-
- GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
- GLfloat black[4] = {0.0, 0.0, 0.0, 1.0};
- GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
-
- if( moon_angle*RAD_TO_DEG < 100 )
- {
- FG_LOG( FG_ASTRO, FG_INFO, "Generating Moon Image" );
-
- xglPushMatrix();
- {
- xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
- xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
-
- FG_LOG( FG_GENERAL, FG_INFO,
- "Ra = (" << (RAD_TO_DEG *rightAscension)
- << "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
- xglTranslatef(0.0, 60000.0, 0.0);
- glEnable(GL_BLEND); // BLEND ENABLED
-
- // Draw the halo...
- if (current_options.get_textures())
- {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glBindTexture(GL_TEXTURE_2D, moon_halotexid);
-
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
- glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
- glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
- glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
- glEnd();
- }
-
- xglEnable(GL_LIGHTING); // LIGHTING ENABLED
- xglEnable( GL_LIGHT0 );
- // set lighting parameters
- xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
- xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
- // xglEnable( GL_CULL_FACE );
- xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
- xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
-
- //glEnable(GL_TEXTURE_2D);
-
- glBlendFunc(GL_ONE, GL_ONE);
-
- //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- // Draw the moon-proper
-
- if (current_options.get_textures())
- {
- glBindTexture(GL_TEXTURE_2D, moon_texid);
- gluQuadricTexture(moonObject, GL_TRUE );
- }
- gluSphere(moonObject, moonSize, 12, 12 );
- glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
- glDisable(GL_BLEND); // BLEND DISABLED
- }
- xglPopMatrix();
- glDisable(GL_LIGHTING); // Lighting Disabled.
-
- }
- else
- {
- }
-}
+++ /dev/null
-/**************************************************************************
- * moon.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _MOON_HXX_
-#define _MOON_HXX_
-
-#include <Aircraft/aircraft.hxx>
-#include <Include/fg_constants.h>
-#include <Main/views.hxx>
-#include <Time/fg_time.hxx>
-
-#include "celestialBody.hxx"
-#include "star.hxx"
-
-class Moon : public CelestialBody
-{
-private:
- void TexInit(); // This should move to the constructor eventually.
-
- GLUquadricObj *moonObject;
- GLuint Sphere;
- GLuint moon_texid;
- GLuint moon_halotexid;
- GLubyte *moon_texbuf;
- GLubyte *moon_halotexbuf;
-
- void setHalo();
-public:
- Moon ( FGTime *t);
- ~Moon();
- void updatePosition(FGTime *t, Star *ourSun);
- void newImage();
-};
-
-
-#endif // _MOON_HXX_
+++ /dev/null
-/**************************************************************************
- * neptune.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-#include "neptune.hxx"
-
-/*************************************************************************
- * Neptune::Neptune(FGTime *t)
- * Public constructor for class Neptune
- * Argument: The current time.
- * the hard coded orbital elements for Neptune are passed to
- * CelestialBody::CelestialBody();
- ************************************************************************/
-Neptune::Neptune(FGTime *t) :
- CelestialBody(131.7806, 3.0173000E-5,
- 1.7700, -2.550E-7,
- 272.8461, -6.027000E-6,
- 30.058260, 3.313E-8,
- 0.008606, 2.150E-9,
- 260.2471, 0.00599514700, t)
-{
-}
-/*************************************************************************
- * void Neptune::updatePosition(FGTime *t, Star *ourSun)
- *
- * calculates the current position of Neptune, by calling the base class,
- * CelestialBody::updatePosition(); The current magnitude is calculated using
- * a Neptune specific equation
- *************************************************************************/
-void Neptune::updatePosition(FGTime *t, Star *ourSun)
-{
- CelestialBody::updatePosition(t, ourSun);
- magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV;
-}
+++ /dev/null
-/**************************************************************************
- * neptune.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _NEPTUNE_HXX_
-#define _NEPTUNE_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-#include "star.hxx"
-
-class Neptune : public CelestialBody
-{
-public:
- Neptune ( FGTime *t);
- void updatePosition(FGTime *t, Star *ourSun);
-};
-
-#endif // _NEPTUNE_HXX_
+++ /dev/null
-/**************************************************************************
- * pluto.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _PLUTO_HXX_
-#define _PLUTO_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-
-class Pluto : public CelestialBody
-{
-public:
- Pluto ( FGTime t);
-};
-
-#endif // _PLUTO_HXX_
+++ /dev/null
-/**************************************************************************
- * saturn.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-#include "saturn.hxx"
-
-/*************************************************************************
- * Saturn::Saturn(FGTime *t)
- * Public constructor for class Saturn
- * Argument: The current time.
- * the hard coded orbital elements for Saturn are passed to
- * CelestialBody::CelestialBody();
- ************************************************************************/
-Saturn::Saturn(FGTime *t) :
- CelestialBody(113.6634, 2.3898000E-5,
- 2.4886, -1.081E-7,
- 339.3939, 2.9766100E-5,
- 9.5547500, 0.000000,
- 0.055546, -9.499E-9,
- 316.9670, 0.03344422820, t)
-{
-}
-
-/*************************************************************************
- * void Saturn::updatePosition(FGTime *t, Star *ourSun)
- *
- * calculates the current position of Saturn, by calling the base class,
- * CelestialBody::updatePosition(); The current magnitude is calculated using
- * a Saturn specific equation
- *************************************************************************/
-void Saturn::updatePosition(FGTime *t, Star *ourSun)
-{
- CelestialBody::updatePosition(t, ourSun);
-
- double actTime = fgCalcActTime(t);
- double ir = 0.4897394;
- double Nr = 2.9585076 + 6.6672E-7*actTime;
- double B = asin (sin(declination) * cos(ir) -
- cos(declination) * sin(ir) *
- sin(rightAscension - Nr));
- double ring_magn = -2.6 * sin(fabs(B)) + 1.2 * pow(sin(B), 2);
- magnitude = -9.0 + 5*log10(r*R) + 0.044 * FV + ring_magn;
-}
-
+++ /dev/null
-/**************************************************************************
- * saturn.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _SATURN_HXX_
-#define _SATURN_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-#include "star.hxx"
-
-class Saturn : public CelestialBody
-{
-public:
- Saturn ( FGTime *t);
- void updatePosition(FGTime *t, Star *ourSun);
-};
-
-#endif // _SATURN_HXX_
-
-
-
-
-
-
-
+++ /dev/null
-// sky.cxx -- model sky with an upside down "bowl"
-//
-// Written by Curtis Olson, started December 1997.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <math.h>
-
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <Aircraft/aircraft.hxx>
-#include <Debug/logstream.hxx>
-#include <FDM/flight.hxx>
-#include <Include/fg_constants.h>
-#include <Main/views.hxx>
-#include <Math/fg_random.h>
-#include <Time/event.hxx>
-#include <Time/fg_time.hxx>
-
-#include "sky.hxx"
-
-
-#ifdef __MWERKS__
-# pragma global_optimizer off
-#endif
-
-
-// in meters of course
-#define CENTER_ELEV 25000.0
-
-#define INNER_RADIUS 50000.0
-#define INNER_ELEV 20000.0
-
-#define MIDDLE_RADIUS 70000.0
-#define MIDDLE_ELEV 8000.0
-
-#define OUTER_RADIUS 80000.0
-#define OUTER_ELEV 0.0
-
-#define BOTTOM_RADIUS 50000.0
-#define BOTTOM_ELEV -2000.0
-
-
-static float inner_vertex[12][3];
-static float middle_vertex[12][3];
-static float outer_vertex[12][3];
-static float bottom_vertex[12][3];
-
-static float inner_color[12][4];
-static float middle_color[12][4];
-static float outer_color[12][4];
-
-
-// Calculate the sky structure vertices
-void fgSkyVerticesInit( void ) {
- float theta;
- int i;
-
- FG_LOG(FG_ASTRO, FG_INFO, " Generating the sky dome vertices.");
-
- for ( i = 0; i < 12; i++ ) {
- theta = (i * 30.0) * DEG_TO_RAD;
-
- inner_vertex[i][0] = cos(theta) * INNER_RADIUS;
- inner_vertex[i][1] = sin(theta) * INNER_RADIUS;
- inner_vertex[i][2] = INNER_ELEV;
-
- // printf(" %.2f %.2f\n", cos(theta) * INNER_RADIUS,
- // sin(theta) * INNER_RADIUS);
-
- middle_vertex[i][0] = cos((double)theta) * MIDDLE_RADIUS;
- middle_vertex[i][1] = sin((double)theta) * MIDDLE_RADIUS;
- middle_vertex[i][2] = MIDDLE_ELEV;
-
- outer_vertex[i][0] = cos((double)theta) * OUTER_RADIUS;
- outer_vertex[i][1] = sin((double)theta) * OUTER_RADIUS;
- outer_vertex[i][2] = OUTER_ELEV;
-
- bottom_vertex[i][0] = cos((double)theta) * BOTTOM_RADIUS;
- bottom_vertex[i][1] = sin((double)theta) * BOTTOM_RADIUS;
- bottom_vertex[i][2] = BOTTOM_ELEV;
- }
-}
-
-
-// (Re)calculate the sky colors at each vertex
-void fgSkyColorsInit( void ) {
- fgLIGHT *l;
- double sun_angle, diff;
- double outer_param[3], outer_amt[3], outer_diff[3];
- double middle_param[3], middle_amt[3], middle_diff[3];
- int i, j;
-
- l = &cur_light_params;
-
- FG_LOG( FG_ASTRO, FG_INFO,
- " Generating the sky colors for each vertex." );
-
- // setup for the possibility of sunset effects
- sun_angle = l->sun_angle * RAD_TO_DEG;
- // fgPrintf( FG_ASTRO, FG_INFO,
- // " Sun angle in degrees = %.2f\n", sun_angle);
-
- if ( (sun_angle > 80.0) && (sun_angle < 100.0) ) {
- // 0.0 - 0.4
- outer_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 20.0;
- outer_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
- outer_param[2] = -(10.0 - fabs(90.0 - sun_angle)) / 30.0;
- // outer_param[2] = 0.0;
-
- middle_param[0] = (10.0 - fabs(90.0 - sun_angle)) / 40.0;
- middle_param[1] = (10.0 - fabs(90.0 - sun_angle)) / 80.0;
- middle_param[2] = 0.0;
-
- outer_diff[0] = outer_param[0] / 6.0;
- outer_diff[1] = outer_param[1] / 6.0;
- outer_diff[2] = outer_param[2] / 6.0;
-
- middle_diff[0] = middle_param[0] / 6.0;
- middle_diff[1] = middle_param[1] / 6.0;
- middle_diff[2] = middle_param[2] / 6.0;
- } else {
- outer_param[0] = outer_param[1] = outer_param[2] = 0.0;
- middle_param[0] = middle_param[1] = middle_param[2] = 0.0;
-
- outer_diff[0] = outer_diff[1] = outer_diff[2] = 0.0;
- middle_diff[0] = middle_diff[1] = middle_diff[2] = 0.0;
- }
- // printf(" outer_red_param = %.2f outer_red_diff = %.2f\n",
- // outer_red_param, outer_red_diff);
-
- // calculate transition colors between sky and fog
- for ( j = 0; j < 3; j++ ) {
- outer_amt[j] = outer_param[j];
- middle_amt[j] = middle_param[j];
- }
-
- for ( i = 0; i < 6; i++ ) {
- for ( j = 0; j < 3; j++ ) {
- diff = l->sky_color[j] - l->fog_color[j];
-
- // printf("sky = %.2f fog = %.2f diff = %.2f\n",
- // l->sky_color[j], l->fog_color[j], diff);
-
- inner_color[i][j] = l->sky_color[j] - diff * 0.3;
- middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
- outer_color[i][j] = l->fog_color[j] + outer_amt[j];
-
- if ( inner_color[i][j] > 1.00 ) { inner_color[i][j] = 1.00; }
- if ( inner_color[i][j] < 0.10 ) { inner_color[i][j] = 0.10; }
- if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
- if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
- if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
- if ( outer_color[i][j] < 0.10 ) { outer_color[i][j] = 0.10; }
- }
- inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
- l->sky_color[3];
-
- for ( j = 0; j < 3; j++ ) {
- outer_amt[j] -= outer_diff[j];
- middle_amt[j] -= middle_diff[j];
- }
-
- /*
- printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
- inner_color[i][1], inner_color[i][2], inner_color[i][3]);
- printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- middle_color[i][0], middle_color[i][1], middle_color[i][2],
- middle_color[i][3]);
- printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- outer_color[i][0], outer_color[i][1], outer_color[i][2],
- outer_color[i][3]);
- */
- }
-
- for ( j = 0; j < 3; j++ ) {
- outer_amt[j] = 0.0;
- middle_amt[j] = 0.0;
- }
-
- for ( i = 6; i < 12; i++ ) {
-
- for ( j = 0; j < 3; j++ ) {
- diff = l->sky_color[j] - l->fog_color[j];
-
- // printf("sky = %.2f fog = %.2f diff = %.2f\n",
- // l->sky_color[j], l->fog_color[j], diff);
-
- inner_color[i][j] = l->sky_color[j] - diff * 0.3;
- middle_color[i][j] = l->sky_color[j] - diff * 0.9 + middle_amt[j];
- outer_color[i][j] = l->fog_color[j] + outer_amt[j];
-
- if ( inner_color[i][j] > 1.00 ) { inner_color[i][j] = 1.00; }
- if ( inner_color[i][j] < 0.10 ) { inner_color[i][j] = 0.10; }
- if ( middle_color[i][j] > 1.00 ) { middle_color[i][j] = 1.00; }
- if ( middle_color[i][j] < 0.10 ) { middle_color[i][j] = 0.10; }
- if ( outer_color[i][j] > 1.00 ) { outer_color[i][j] = 1.00; }
- if ( outer_color[i][j] < 0.15 ) { outer_color[i][j] = 0.15; }
- }
- inner_color[i][3] = middle_color[i][3] = outer_color[i][3] =
- l->sky_color[3];
-
- for ( j = 0; j < 3; j++ ) {
- outer_amt[j] += outer_diff[j];
- middle_amt[j] += middle_diff[j];
- }
-
- /*
- printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
- inner_color[i][1], inner_color[i][2], inner_color[i][3]);
- printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- middle_color[i][0], middle_color[i][1], middle_color[i][2],
- middle_color[i][3]);
- printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- outer_color[i][0], outer_color[i][1], outer_color[i][2],
- outer_color[i][3]);
- */
- }
-}
-
-
-// Initialize the sky structure and colors
-void fgSkyInit( void ) {
- FG_LOG( FG_ASTRO, FG_INFO, "Initializing the sky" );
-
- fgSkyVerticesInit();
-
- // regester fgSkyColorsInit() as an event to be run periodically
- global_events.Register( "fgSkyColorsInit()", fgSkyColorsInit,
- fgEVENT::FG_EVENT_READY, 30000);
-}
-
-
-// Draw the Sky
-void fgSkyRender( void ) {
- FGInterface *f;
- fgLIGHT *l;
- float inner_color[4];
- float middle_color[4];
- float outer_color[4];
- double diff;
- int i;
-
- f = current_aircraft.fdm_state;
- l = &cur_light_params;
-
- // printf("Rendering the sky.\n");
-
- // calculate the proper colors
- for ( i = 0; i < 3; i++ ) {
- diff = l->sky_color[i] - l->adj_fog_color[i];
-
- // printf("sky = %.2f fog = %.2f diff = %.2f\n",
- // l->sky_color[j], l->adj_fog_color[j], diff);
-
- inner_color[i] = l->sky_color[i] - diff * 0.3;
- middle_color[i] = l->sky_color[i] - diff * 0.9;
- outer_color[i] = l->adj_fog_color[i];
- }
- inner_color[3] = middle_color[3] = outer_color[3] = l->adj_fog_color[3];
-
- xglPushMatrix();
-
- // Translate to view position
- Point3D zero_elev = current_view.get_cur_zero_elev();
- xglTranslatef( zero_elev.x(), zero_elev.y(), zero_elev.z() );
- // printf(" Translated to %.2f %.2f %.2f\n",
- // zero_elev.x, zero_elev.y, zero_elev.z );
-
- // Rotate to proper orientation
- // printf(" lon = %.2f lat = %.2f\n", FG_Longitude * RAD_TO_DEG,
- // FG_Latitude * RAD_TO_DEG);
- xglRotatef( f->get_Longitude() * RAD_TO_DEG, 0.0, 0.0, 1.0 );
- xglRotatef( 90.0 - f->get_Latitude() * RAD_TO_DEG, 0.0, 1.0, 0.0 );
- xglRotatef( l->sun_rotation * RAD_TO_DEG, 0.0, 0.0, 1.0 );
-
- // Draw inner/center section of sky*/
- xglBegin( GL_TRIANGLE_FAN );
- xglColor4fv(l->sky_color);
- xglVertex3f(0.0, 0.0, CENTER_ELEV);
- for ( i = 11; i >= 0; i-- ) {
- xglColor4fv( inner_color );
- xglVertex3fv( inner_vertex[i] );
- }
- xglColor4fv( inner_color );
- xglVertex3fv( inner_vertex[11] );
- xglEnd();
-
- // Draw the middle ring
- xglBegin( GL_TRIANGLE_STRIP );
- for ( i = 0; i < 12; i++ ) {
- xglColor4fv( middle_color );
- // printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- // middle_color[i][0], middle_color[i][1], middle_color[i][2],
- // middle_color[i][3]);
- // xglColor4f(1.0, 0.0, 0.0, 1.0);
- xglVertex3fv( middle_vertex[i] );
- xglColor4fv( inner_color );
- // printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i,
- // inner_color[i][0], inner_color[i][1], inner_color[i][2],
- // inner_color[i][3]);
- // xglColor4f(0.0, 0.0, 1.0, 1.0);
- xglVertex3fv( inner_vertex[i] );
- }
- xglColor4fv( middle_color );
- // xglColor4f(1.0, 0.0, 0.0, 1.0);
- xglVertex3fv( middle_vertex[0] );
- xglColor4fv( inner_color );
- // xglColor4f(0.0, 0.0, 1.0, 1.0);
- xglVertex3fv( inner_vertex[0] );
- xglEnd();
-
- // Draw the outer ring
- xglBegin( GL_TRIANGLE_STRIP );
- for ( i = 0; i < 12; i++ ) {
- xglColor4fv( outer_color );
- xglVertex3fv( outer_vertex[i] );
- xglColor4fv( middle_color );
- xglVertex3fv( middle_vertex[i] );
- }
- xglColor4fv( outer_color );
- xglVertex3fv( outer_vertex[0] );
- xglColor4fv( middle_color );
- xglVertex3fv( middle_vertex[0] );
- xglEnd();
-
- // Draw the bottom skirt
- xglBegin( GL_TRIANGLE_STRIP );
- xglColor4fv( outer_color );
- for ( i = 0; i < 12; i++ ) {
- xglVertex3fv( bottom_vertex[i] );
- xglVertex3fv( outer_vertex[i] );
- }
- xglVertex3fv( bottom_vertex[0] );
- xglVertex3fv( outer_vertex[0] );
- xglEnd();
-
- xglPopMatrix();
-}
-
-
+++ /dev/null
-// sky.hxx -- model sky with an upside down "bowl"
-//
-// Written by Curtis Olson, started December 1997.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _SKY_HXX
-#define _SKY_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-
-// (Re)generate the display list
-void fgSkyInit( void );
-
-// (Re)calculate the sky colors at each vertex
-void fgSkyColorsInit( void );
-
-// Draw the Sky
-void fgSkyRender( void );
-
-
-#endif // _SKY_HXX
-
-
+++ /dev/null
-/**************************************************************************
- * solarsystem.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-#include <Debug/logstream.hxx>
-#include <Time/sunpos.hxx>
-#include <Time/moonpos.hxx>
-#include "solarsystem.hxx"
-
-/***************************************************************************
- * default constructor for class SolarSystem:
- * or course there can only be one way to create an entire solar system -:) )
- * the FGTime argument is needed to properly initialize the the current orbital
- * elements
- *************************************************************************/
-SolarSystem::SolarSystem(FGTime *t)
-{
- if (theSolarSystem)
- {
- FG_LOG( FG_GENERAL, FG_ALERT, "Error: only one solarsystem allowed" );
- exit(-1);
- }
- theSolarSystem = this;
- ourSun = new Star(t);
- earthsMoon = new Moon(t);
- mercury = new Mercury(t);
- venus = new Venus(t);
- mars = new Mars(t);
- jupiter = new Jupiter(t);
- saturn = new Saturn(t);
- uranus = new Uranus(t);
- neptune = new Neptune(t);
-
- displayList = 0;
-};
-
-/**************************************************************************
- * the destructor for class SolarSystem;
- **************************************************************************/
-SolarSystem::~SolarSystem()
-{
- delete ourSun;
- delete earthsMoon;
- delete mercury;
- delete venus;
- delete mars;
- delete jupiter;
- delete saturn;
- delete uranus;
- delete neptune;
-}
-/****************************************************************************
- * void SolarSystem::rebuild()
- *
- * this member function updates the positions for the sun, moon, and planets,
- * and then rebuilds the display list.
- *
- * arguments: none
- * return value: none
- ***************************************************************************/
-void SolarSystem::rebuild()
-{
- //fgLIGHT *l = &cur_light_params;
- FGTime *t = FGTime::cur_time_params;
- //float x, y, z;
- //double sun_angle;
- double ra, dec;
- //double x_2, x_4, x_8, x_10;*/
- double magnitude;
- //GLfloat ambient;
- //GLfloat amb[4];
-
- glDisable(GL_LIGHTING);
-
- // Step 1: update all the positions
- ourSun->updatePosition(t);
- earthsMoon->updatePosition(t, ourSun);
- mercury->updatePosition(t, ourSun);
- venus->updatePosition(t, ourSun);
- mars->updatePosition(t, ourSun);
- jupiter->updatePosition(t, ourSun);
- saturn->updatePosition(t, ourSun);
- uranus->updatePosition(t, ourSun);
- neptune->updatePosition(t, ourSun);
-
- fgUpdateSunPos(); // get the right sun angle (especially important when
- // running for the first time).
- fgUpdateMoonPos();
-
- if (displayList)
- xglDeleteLists(displayList, 1);
-
- displayList = xglGenLists(1);
-
- FG_LOG( FG_ASTRO, FG_INFO, "Rebuilding astro display list" );
-
- // Step 2: rebuild the display list
- xglNewList( displayList, GL_COMPILE);
- {
- // Step 2a: Add the moon...
- // Not that it is preferred to draw the moon first, and the sun next, in order to mime a
- // solar eclipse. This is yet untested though...
- // Euhh, actually the ecplise doesn't work...
-
- earthsMoon->newImage();
- // Step 2b: Add the sun
- ourSun->newImage();
- // Step 2c: Add the planets
- xglBegin(GL_POINTS);
- mercury->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
- venus ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
- mars ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
- jupiter->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
- saturn ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
- uranus ->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
- neptune->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
- xglEnd();
- xglEnable(GL_LIGHTING);
- }
- xglEndList();
-}
-
-/*****************************************************************************
- * double SolarSystem::scaleMagnitude(double magn)
- * This private member function rescales the original magnitude, as used in the
- * astronomical sense of the word, into a value used by OpenGL to draw a
- * convincing Star or planet
- *
- * Argument: the astronomical magnitude
- *
- * return value: the rescaled magnitude
- ****************************************************************************/
-double SolarSystem::scaleMagnitude(double magn)
-{
- double magnitude = (0.0 - magn) / 5.0 + 1.0;
- magnitude = magnitude * 0.7 + (3 * 0.1);
- if (magnitude > 1.0) magnitude = 1.0;
- if (magnitude < 0.0) magnitude = 0.0;
- return magnitude;
-}
-
-/***************************************************************************
- * void SolarSytem::addPlanetToList(double ra, double dec, double magn);
- *
- * This private member function first causes the magnitude to be properly
- * rescaled, and then adds the planet to the display list.
- *
- * arguments: Right Ascension, declination, and magnitude
- *
- * return value: none
- **************************************************************************/
-void SolarSystem::addPlanetToList(double ra, double dec, double magn)
-{
- double
- magnitude = scaleMagnitude ( magn );
-
- fgLIGHT *l = &cur_light_params;
-
- if ((double) (l->sun_angle - FG_PI_2) >
- ((magnitude - 1.0) * - 20 * DEG_TO_RAD))
- {
- xglColor3f (magnitude, magnitude, magnitude);
- xglVertex3f( 50000.0 * cos (ra) * cos (dec),
- 50000.0 * sin (ra) * cos (dec),
- 50000.0 * sin (dec));
- }
-}
-
-
-SolarSystem* SolarSystem::theSolarSystem = 0;
-
-/******************************************************************************
- * void solarSystemRebuild()
- * this a just a wrapper function, provided for use as an interface to the
- * event manager
- *****************************************************************************/
-void solarSystemRebuild()
-{
- SolarSystem::theSolarSystem->rebuild();
-}
+++ /dev/null
-/**************************************************************************
- * solarsystem.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _SOLARSYSTEM_H_
-#define _SOLARSYSTEM_H_
-
-#include <Time/light.hxx>
-#include <Time/fg_time.hxx>
-#include <Main/views.hxx>
-
-#include "star.hxx"
-#include "moon.hxx"
-#include "mercury.hxx"
-#include "venus.hxx"
-#include "mars.hxx"
-#include "jupiter.hxx"
-#include "saturn.hxx"
-#include "uranus.hxx"
-#include "neptune.hxx"
-#include "pluto.hxx"
-
-
-class SolarSystem
-{
-private:
- Star* ourSun;
- Moon* earthsMoon;
- Mercury* mercury;
- Venus* venus;
- Mars* mars;
- Jupiter* jupiter;
- Saturn* saturn;
- Uranus* uranus;
- Neptune* neptune;
- //Pluto* pluto;
-
- GLint displayList;
- double scaleMagnitude(double magn);
- void addPlanetToList(double ra, double dec, double magn);
-
-
-public:
- SolarSystem(FGTime *t);
- CelestialBody *getSun();
- CelestialBody *getMoon();
- ~SolarSystem();
-
- static SolarSystem *theSolarSystem; // thanks to Bernie Bright!
- void rebuild();
- friend void solarSystemRebuild();
- void draw();
-};
-
-inline CelestialBody* SolarSystem::getSun()
-{
- return ourSun;
-}
-
-inline CelestialBody* SolarSystem::getMoon()
-{
- return earthsMoon;
-}
-
-inline void SolarSystem::draw()
-{
- xglCallList(displayList);
-}
-
-extern void solarSystemRebuild();
-
-#endif // _SOLARSYSTEM_H_
+++ /dev/null
-/**************************************************************************
- * star.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-#include <Time/sunpos.hxx>
-#include <Debug/logstream.hxx>
-#include <Time/light.hxx>
-#include <Main/options.hxx>
-#include "star.hxx"
-
-/*************************************************************************
- * Star::Star(FGTime *t)
- * Public constructor for class Star
- * Argument: The current time.
- * the hard coded orbital elements our sun are passed to
- * CelestialBody::CelestialBody();
- * note that the word sun is avoided, in order to prevent some compilation
- * problems on sun systems
- ************************************************************************/
-Star::Star(FGTime *t) :
- CelestialBody (0.000000, 0.0000000000,
- 0.0000, 0.00000,
- 282.9404, 4.7093500E-5,
- 1.0000000, 0.000000,
- 0.016709, -1.151E-9,
- 356.0470, 0.98560025850, t)
-{
-
- FG_LOG( FG_GENERAL, FG_INFO, "Initializing Sun Texture");
-#ifdef GL_VERSION_1_1
- xglGenTextures(1, &sun_texid);
- xglBindTexture(GL_TEXTURE_2D, sun_texid);
-#elif GL_EXT_texture_object
- xglGenTexturesEXT(1, &sun_texid);
- xglBindTextureEXT(GL_TEXTURE_2D, sun_texid);
-#else
-# error port me
-#endif
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- setTexture();
- glTexImage2D( GL_TEXTURE_2D,
- 0,
- GL_RGBA,
- 256, 256,
- 0,
- GL_RGBA, GL_UNSIGNED_BYTE,
- sun_texbuf);
-
- SunObject = gluNewQuadric();
- if(SunObject == NULL)
- {
- printf("gluNewQuadric(SunObject) failed !\n");
- exit(0);
- }
-
- //SunList = 0;
- distance = 0.0;
-}
-
-Star::~Star()
-{
- //delete SunObject;
- delete [] sun_texbuf;
-}
-
-
-
-static int texWidth = 256; /* 64x64 is plenty */
-
-void Star::setTexture()
-{
- int texSize;
- //void *textureBuf;
- GLubyte *p;
- int i,j;
- double radius;
-
- texSize = texWidth*texWidth;
-
- sun_texbuf = new GLubyte[texSize*4];
- if (!sun_texbuf)
- return; // Ugly!
-
- p = sun_texbuf;
-
- radius = (double)(texWidth / 2);
-
- for (i=0; i < texWidth; i++) {
- for (j=0; j < texWidth; j++) {
- double x, y, d;
-
- x = fabs((double)(i - (texWidth / 2)));
- y = fabs((double)(j - (texWidth / 2)));
-
- d = sqrt((x * x) + (y * y));
- if (d < radius)
- {
- double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
- // inverse square looks nice
- *p = (int)((double)0xff * (t * t));
- *(p+1) = (int)((double) 0xff * (t*t));
- *(p+2) = (int)((double) 0xff * (t*t));
- *(p+3) = (int)((double) 0xff * (t*t));
- }
- else
- {
- *p = 0x00;
- *(p+1) = 0x00;
- *(p+2) = 0x00;
- *(p+3) = 0x00;
- }
- p += 4;
- }
- }
- //gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
- // GL_LUMINANCE,
- // GL_UNSIGNED_BYTE, textureBuf);
- //free(textureBuf);
-}
-/*************************************************************************
- * void Jupiter::updatePosition(FGTime *t, Star *ourSun)
- *
- * calculates the current position of our sun.
- *************************************************************************/
-void Star::updatePosition(FGTime *t)
-{
- double
- actTime, eccAnom,
- xv, yv, v, r,
- xe, ye, ze, ecl;
-
- updateOrbElements(t);
-
- actTime = fgCalcActTime(t);
- ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle in Radians
- eccAnom = fgCalcEccAnom(M, e); // Calculate the eccentric Anomaly (also known as solving Kepler's equation)
-
- xv = cos(eccAnom) - e;
- yv = sqrt (1.0 - e*e) * sin(eccAnom);
- v = atan2 (yv, xv); // the sun's true anomaly
- distance = r = sqrt (xv*xv + yv*yv); // and its distance
-
- lonEcl = v + w; // the sun's true longitude
- latEcl = 0;
-
- // convert the sun's true longitude to ecliptic rectangular
- // geocentric coordinates (xs, ys)
- xs = r * cos (lonEcl);
- ys = r * sin (lonEcl);
-
- // convert ecliptic coordinates to equatorial rectangular
- // geocentric coordinates
-
- xe = xs;
- ye = ys * cos (ecl);
- ze = ys * sin (ecl);
-
- // And finally, calculate right ascension and declination
- rightAscension = atan2 (ye, xe);
- declination = atan2 (ze, sqrt (xe*xe + ye*ye));
-}
-
-void Star::newImage(void)
-{
- /*static float stars[3];
- stars[0] = 0.0;
- stars[1] = 0.0;
- stars[2] = 1.0;*/
-
- fgLIGHT *l = &cur_light_params;
- float sun_angle = l->sun_angle;
-
- if( sun_angle*RAD_TO_DEG < 100 ) { // else no need to draw sun
-
-
- double x_2, x_4, x_8, x_10;
- GLfloat ambient;
- GLfloat amb[4];
- int sun_size = 750;
-
- // daily variation sun gets larger near horizon
- /*if(sun_angle*RAD_TO_DEG > 84.0 && sun_angle*RAD_TO_DEG < 95)
- {
- double sun_grow = 9*fabs(94-sun_angle*RAD_TO_DEG);
- sun_size = (int)(sun_size + sun_size * cos(sun_grow*DEG_TO_RAD));
- }*/
- x_2 = sun_angle * sun_angle;
- x_4 = x_2 * x_2;
- x_8 = x_4 * x_4;
- x_10 = x_8 * x_2;
- ambient = (float)(0.4 * pow (1.1, - x_10 / 30.0));
- if (ambient < 0.3) ambient = 0.3;
- if (ambient > 1.0) ambient = 1.0;
-
- amb[0] = ((ambient * 6.0) - 1.0); // minimum value = 0.8
- amb[1] = ((ambient * 11.0) - 3.0); // minimum value = 0.3
- amb[2] = ((ambient * 12.0) - 3.6); // minimum value = 0.0
- amb[3] = 1.00;
-
- if (amb[0] > 1.0) amb[0] = 1.0;
- if (amb[1] > 1.0) amb[1] = 1.0;
- if (amb[2] > 1.0) amb[2] = 1.0;
- xglColor3fv(amb);
- glPushMatrix();
- {
- xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
- xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
- xglTranslatef(0,60000,0);
- if (current_options.get_textures())
- {
- glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
- glEnable(GL_BLEND); // BLEND ENABLED
-
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glBindTexture(GL_TEXTURE_2D, sun_texid);
-
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
- glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
- glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000);
- glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
- glEnd();
- }
- xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
- xglDisable(GL_BLEND); // BLEND DISABLED
- }
-
- glPopMatrix();
- glDisable(GL_LIGHTING); //LIGHTING DISABLED
- glDisable(GL_BLEND); //BLEND DISABLED
- glPushMatrix();
- {
- xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
- xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
- xglColor4fv(amb);
- xglTranslatef(0,60000,0);
- gluSphere( SunObject, sun_size, 10, 10 );
- }
- glPopMatrix();
- glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
- glDisable(GL_BLEND); // BLEND DISABLED
- }
-}
+++ /dev/null
-/**************************************************************************
- * star.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _STAR_HXX_
-#define _STAR_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-
-
-class Star : public CelestialBody
-{
-private:
- //double longitude; // the sun's true longitude - this is depreciated by
- // CelestialBody::lonEcl
- double xs, ys; // the sun's rectangular geocentric coordinates
- double distance; // the sun's distance to the earth
- GLUquadricObj *SunObject;
- GLuint sun_texid;
- GLubyte *sun_texbuf;
-
- void setTexture();
-public:
- Star (FGTime *t);
- ~Star();
- void updatePosition(FGTime *t);
- double getM();
- double getw();
- //double getLon();
- double getxs();
- double getys();
- double getDistance();
- void newImage();
-};
-
-
-
-inline double Star::getM()
-{
- return M;
-}
-
-inline double Star::getw()
-{
- return w;
-}
-
-inline double Star::getxs()
-{
- return xs;
-}
-
-inline double Star::getys()
-{
- return ys;
-}
-
-inline double Star::getDistance()
-{
- return distance;
-}
-
-
-#endif // _STAR_HXX_
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-// stars.cxx -- data structures and routines for managing and rendering stars.
-//
-// Written by Curtis Olson, started August 1997.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-//*************************************************************************/
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include "Include/compiler.h"
-#ifdef FG_HAVE_STD_INCLUDES
-# include <cmath>
-# include <cstdio>
-# include <cstring>
-# include <ctime>
-#else
-# include <math.h>
-# include <stdio.h>
-# include <string.h>
-# include <time.h>
-#endif
-
-#include <string>
-
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <Aircraft/aircraft.hxx>
-#include <Debug/logstream.hxx>
-#include <Include/fg_constants.h>
-#include <Misc/fgpath.hxx>
-#include <Misc/fgstream.hxx>
-#include <Misc/stopwatch.hxx>
-#include <Main/options.hxx>
-#include <Main/views.hxx>
-#include <Time/fg_time.hxx>
-#include "Misc/stopwatch.hxx"
-
-#include "stars.hxx"
-
-FG_USING_STD(getline);
-
-#define EpochStart (631065600)
-#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
-#define FG_MAX_STARS 3500
-
-// Define four structures, each with varying amounts of stars
-static GLint stars[FG_STAR_LEVELS];
-
-
-// Initialize the Star Management Subsystem
-int fgStarsInit( void ) {
- // -dw- avoid local data > 32k error by dynamic allocation of the
- // array, problem for some compilers
- Point3D *starlist = new Point3D[FG_MAX_STARS];
- // struct CelestialCoord pltPos;
- double right_ascension, declination, magnitude;
- double min_magnitude[FG_STAR_LEVELS];
- // double ra_save, decl_save;
- // double ra_save1, decl_save1;
- int i, j, starcount, count;
-
- FG_LOG( FG_ASTRO, FG_INFO, "Initializing stars" );
-
- if ( FG_STAR_LEVELS < 4 ) {
- FG_LOG( FG_ASTRO, FG_ALERT, "Big whups in stars.cxx" );
- exit(-1);
- }
-
- // build the full path name to the stars data base file
- FGPath path ( current_options.get_fg_root() );
- path.append( "Astro/stars" );
- FG_LOG( FG_ASTRO, FG_INFO, " Loading stars from " << path.str() );
-
- fg_gzifstream in( path.str() );
- if ( ! in ) {
- FG_LOG( FG_ASTRO, FG_ALERT, "Cannot open star file: " << path.str() );
- exit(-1);
- }
-
- starcount = 0;
-
- StopWatch timer;
- timer.start();
-
- // read in each line of the file
- while ( ! in.eof() && starcount < FG_MAX_STARS )
- {
- in >> skipcomment;
- string name;
- getline( in, name, ',' );
- in >> starlist[starcount];
- ++starcount;
- }
-
- timer.stop();
- FG_LOG( FG_ASTRO, FG_INFO,
- "Loaded " << starcount << " stars in "
- << timer.elapsedSeconds() << " seconds" );
-
- min_magnitude[0] = 4.2;
- min_magnitude[1] = 3.6;
- min_magnitude[2] = 3.0;
- min_magnitude[3] = 2.4;
- min_magnitude[4] = 1.8;
- min_magnitude[5] = 1.2;
- min_magnitude[6] = 0.6;
- min_magnitude[7] = 0.0;
-
- // build the various star display lists
- for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
-
- stars[i] = xglGenLists(1);
- xglNewList( stars[i], GL_COMPILE );
- xglBegin( GL_POINTS );
-
- count = 0;
-
- for ( j = 0; j < starcount; j++ ) {
- magnitude = starlist[j].z();
- // printf("magnitude = %.2f\n", magnitude);
-
- if ( magnitude < min_magnitude[i] ) {
- right_ascension = starlist[j].x();
- declination = starlist[j].y();
-
- count++;
-
- // scale magnitudes to (0.0 - 1.0)
- magnitude = (0.0 - magnitude) / 5.0 + 1.0;
-
- // scale magnitudes again so they look ok
- if ( magnitude > 1.0 ) { magnitude = 1.0; }
- if ( magnitude < 0.0 ) { magnitude = 0.0; }
- // magnitude =
- // magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.042);
-
- magnitude = magnitude * 0.9 +
- (((FG_STAR_LEVELS - 1) - i) * 0.014);
- // printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
- // name, right_ascension, declination, magnitude);
-
- xglColor3f( magnitude, magnitude, magnitude );
- //xglColor3f(0,0,0);*/
- xglVertex3f( 50000.0*cos(right_ascension)*cos(declination),
- 50000.0*sin(right_ascension)*cos(declination),
- 50000.0*sin(declination) );
- }
- } // while
-
- xglEnd();
-
- /*
- xglBegin(GL_LINE_LOOP);
- xglColor3f(1.0, 0.0, 0.0);
- xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save-0.2),
- 50000.0 * sin(ra_save-0.2) * cos(decl_save-0.2),
- 50000.0 * sin(decl_save-0.2) );
- xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save-0.2),
- 50000.0 * sin(ra_save+0.2) * cos(decl_save-0.2),
- 50000.0 * sin(decl_save-0.2) );
- xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save+0.2),
- 50000.0 * sin(ra_save+0.2) * cos(decl_save+0.2),
- 50000.0 * sin(decl_save+0.2) );
- xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save+0.2),
- 50000.0 * sin(ra_save-0.2) * cos(decl_save+0.2),
- 50000.0 * sin(decl_save+0.2) );
- xglEnd();
- */
-
- /*
- xglBegin(GL_LINE_LOOP);
- xglColor3f(0.0, 1.0, 0.0);
- xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2),
- 50000.0 * sin(ra_save1-0.2) * cos(decl_save1-0.2),
- 50000.0 * sin(decl_save1-0.2) );
- xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2),
- 50000.0 * sin(ra_save1+0.2) * cos(decl_save1-0.2),
- 50000.0 * sin(decl_save1-0.2) );
- xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2),
- 50000.0 * sin(ra_save1+0.2) * cos(decl_save1+0.2),
- 50000.0 * sin(decl_save1+0.2) );
- xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2),
- 50000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2),
- 50000.0 * sin(decl_save1+0.2) );
- xglEnd();
- */
-
- xglEndList();
-
- FG_LOG( FG_ASTRO, FG_INFO,
- " Loading " << count << " stars brighter than "
- << min_magnitude[i] );
- }
-
- return 1; // OK, we got here because initialization worked.
-}
-
-
-// Draw the Stars
-void fgStarsRender( void ) {
- FGInterface *f;
- fgLIGHT *l;
- FGTime *t;
- int i;
-
- f = current_aircraft.fdm_state;
- l = &cur_light_params;
- t = FGTime::cur_time_params;
-
- // FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise
-
- // t->sun_angle = 3.0; // to force stars to be drawn (for testing)
-
- // render the stars
- if ( l->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
- // determine which star structure to draw
- if ( l->sun_angle > (FG_PI_2 + 10.0 * DEG_TO_RAD ) ) {
- i = 0;
- } else if ( l->sun_angle > (FG_PI_2 + 8.8 * DEG_TO_RAD ) ) {
- i = 1;
- } else if ( l->sun_angle > (FG_PI_2 + 7.5 * DEG_TO_RAD ) ) {
- i = 2;
- } else if ( l->sun_angle > (FG_PI_2 + 7.0 * DEG_TO_RAD ) ) {
- i = 3;
- } else if ( l->sun_angle > (FG_PI_2 + 6.5 * DEG_TO_RAD ) ) {
- i = 4;
- } else if ( l->sun_angle > (FG_PI_2 + 6.0 * DEG_TO_RAD ) ) {
- i = 5;
- } else if ( l->sun_angle > (FG_PI_2 + 5.5 * DEG_TO_RAD ) ) {
- i = 6;
- } else {
- i = 7;
- }
-
- // printf("RENDERING STARS = %d (night)\n", i);
-
- xglCallList(stars[i]);
- } else {
- // printf("not RENDERING STARS (day)\n");
- }
-}
-
-
+++ /dev/null
-// stars.hxx -- data structures and routines for managing and rendering stars.
-//
-// Written by Curtis Olson, started August 1997.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@me.umn.edu
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _STARS_HXX
-#define _STARS_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <Time/fg_time.hxx>
-
-#define FG_STAR_LEVELS 8 // how many star transitions
-
-// Initialize the Star Management Subsystem
-int fgStarsInit( void );
-
-// Draw the Stars
-void fgStarsRender( void );
-
-// [no longer used?] extern FGTime cur_time_params;
-
-
-#endif // _STARS_HXX
-
-
+++ /dev/null
-/**************************************************************************
- * uranus.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-#include "uranus.hxx"
-
-/*************************************************************************
- * Uranus::Uranus(FGTime *t)
- * Public constructor for class Uranus
- * Argument: The current time.
- * the hard coded orbital elements for Uranus are passed to
- * CelestialBody::CelestialBody();
- ************************************************************************/
-Uranus::Uranus(FGTime *t) :
- CelestialBody(74.00050, 1.3978000E-5,
- 0.7733, 1.900E-8,
- 96.66120, 3.0565000E-5,
- 19.181710, -1.55E-8,
- 0.047318, 7.450E-9,
- 142.5905, 0.01172580600, t)
-{
-}
-
-/*************************************************************************
- * void Uranus::updatePosition(FGTime *t, Star *ourSun)
- *
- * calculates the current position of Uranus, by calling the base class,
- * CelestialBody::updatePosition(); The current magnitude is calculated using
- * a Uranus specific equation
- *************************************************************************/
-void Uranus::updatePosition(FGTime *t, Star *ourSun)
-{
- CelestialBody::updatePosition(t, ourSun);
- magnitude = -7.15 + 5*log10( r*R) + 0.001 * FV;
-}
+++ /dev/null
-/**************************************************************************
- * uranus.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _URANUS_HXX_
-#define _URANUS_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-#include "star.hxx"
-
-class Uranus : public CelestialBody
-{
-public:
- Uranus ( FGTime *t);
- void updatePosition(FGTime *t, Star *ourSun);
-};
-
-#endif // _URANUS_HXX_
+++ /dev/null
-/**************************************************************************
- * venus.cxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-#ifdef __BORLANDC__
-# define exception c_exception
-#endif
-#include <math.h>
-
-#include "venus.hxx"
-
-/*************************************************************************
- * Venus::Venus(FGTime *t)
- * Public constructor for class Venus
- * Argument: The current time.
- * the hard coded orbital elements for Venus are passed to
- * CelestialBody::CelestialBody();
- ************************************************************************/
-Venus::Venus(FGTime *t) :
- CelestialBody(76.67990, 2.4659000E-5,
- 3.3946, 2.75E-8,
- 54.89100, 1.3837400E-5,
- 0.7233300, 0.000000,
- 0.006773, -1.302E-9,
- 48.00520, 1.60213022440, t)
-{
-}
-
-/*************************************************************************
- * void Venus::updatePosition(FGTime *t, Star *ourSun)
- *
- * calculates the current position of Venus, by calling the base class,
- * CelestialBody::updatePosition(); The current magnitude is calculated using
- * a Venus specific equation
- *************************************************************************/
-void Venus::updatePosition(FGTime *t, Star *ourSun)
-{
- CelestialBody::updatePosition(t, ourSun);
- magnitude = -4.34 + 5*log10( r*R ) + 0.013 * FV + 4.2E-07 * pow(FV,3);
-}
+++ /dev/null
-/**************************************************************************
- * venus.hxx
- * Written by Durk Talsma. Originally started October 1997, for distribution
- * with the FlightGear project. Version 2 was written in August and
- * September 1998. This code is based upon algorithms and data kindly
- * provided by Mr. Paul Schlyter. (pausch@saaf.se).
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-#ifndef _VENUS_HXX_
-#define _VENUS_HXX_
-
-#include <Time/fg_time.hxx>
-#include "celestialBody.hxx"
-#include "star.hxx"
-
-class Venus : public CelestialBody
-{
-public:
- Venus ( FGTime *t);
- void updatePosition(FGTime *t, Star *ourSun);
-};
-
-#endif // _VENUS_HXX_
}
char *gmt_str = get_formated_gmt_time();
- HUD_TextList.add( fgText( 40, 10, gmt_str ) );
+ HUD_TextList.add( fgText( gmt_str, 40, 10) );
HUD_TextList.draw();
FG_USING_STD(deque);
FG_USING_STD(vector);
-FG_USING_NAMESPACE(std);
#ifndef WIN32
typedef struct {
class fgText {
private:
- float x, y;
char msg[32];
+ float x, y;
public:
+ fgText( char *c = NULL, float x = 0, float y =0 )
+ : x(x), y(y) {strncpy(msg,c,32-1);}
+
fgText( float x = 0, float y = 0, char *c = NULL )
: x(x), y(y) {strncpy(msg,c,32-1);}
}
void TextString( char *msg, float x, float y )
{
- HUD_TextList.add(fgText(x, y, msg));
+ HUD_TextList.add(fgText(msg, x, y));
}
int getStringWidth ( char *str )
{
+++ /dev/null
-noinst_LIBRARIES = libExternal.a
-
-libExternal_a_SOURCES = external.cxx external.hxx
-
-INCLUDES += -I$(top_builddir) -I$(top_builddir)/Simulator
+++ /dev/null
-// external.cxx -- externally driven flight model
-//
-// Written by Curtis Olson, started January 1998.
-//
-// Copyright (C) 1998 Curtis L. Olson - curt@flightgear.org
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#include <math.h>
-
-#include "external.hxx"
-
-#include <FDM/flight.hxx>
-#include <Include/fg_constants.h>
-
-
-// reset flight params to a specific position
-void fgExternalInit( FGInterface &f ) {
-}
-
-
-// update position based on inputs, positions, velocities, etc.
-void fgExternalUpdate( FGInterface& f, int multiloop ) {
-
-}
-
-
+++ /dev/null
-// external.hxx -- the "external" flight model (driven from other
-// external input)
-//
-// Written by Curtis Olson, started December 1998.
-//
-// Copyright (C) 1998 Curtis L. Olson - curt@flightgear.org
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _EXTERNAL_HXX
-#define _EXTERNAL_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-
-#include <Time/fg_time.hxx>
-#include <Time/timestamp.hxx>
-
-
-/*
-class fgFDM_EXTERNAL {
-
-public:
-
- // Time Stamp
-
- // The time at which these values are correct (for extrapolating
- // later frames between position updates)
- FGTimeStamp t;
-
- // Positions
-
- // placement in geodetic coordinates
- double Latitude;
- double Longitude;
- double Altitude;
-
- // orientation in euler angles relative to local frame (or ground
- // position)
- double Phi; // roll
- double Theta; // pitch
- double Psi; // heading
-
- // Velocities
-
- // velocities in geodetic coordinates
- double Latitude_dot; // rad/sec
- double Longitude_dot; // rad/sec
- double Altitude_dot; // feet/sec
-
- // rotational rates
- double Phi_dot;
- double Theta_dot;
- double Psi_dot;
-};
-*/
-
-
-// reset flight params to a specific position
-void fgExternalInit( FGInterface& f );
-
-
-#endif // _EXTERNAL_HXX
-
-
--- /dev/null
+// JSBsim.cxx -- interface to the JSBsim flight model
+//
+// Written by Curtis Olson, started February 1999.
+//
+// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+
+#include <Include/compiler.h>
+
+#ifdef FG_MATH_EXCEPTION_CLASH
+# include <math.h>
+#endif
+
+#include STL_STRING
+
+#include <Aircraft/aircraft.hxx>
+#include <Controls/controls.hxx>
+#include <Debug/logstream.hxx>
+#include <Include/fg_constants.h>
+#include <Main/options.hxx>
+#include <Math/fg_geodesy.hxx>
+#include <Misc/fgpath.hxx>
+
+#include <FDM/JSBsim/FGFDMExec.h>
+#include <FDM/JSBsim/FGAircraft.h>
+#include <FDM/JSBsim/FGFCS.h>
+#include <FDM/JSBsim/FGPosition.h>
+#include <FDM/JSBsim/FGRotation.h>
+#include <FDM/JSBsim/FGState.h>
+#include <FDM/JSBsim/FGTranslation.h>
+
+#include "JSBsim.hxx"
+
+
+// The default aircraft
+FGFDMExec FDMExec;
+
+
+// Initialize the JSBsim flight model, dt is the time increment for
+// each subsequent iteration through the EOM
+int fgJSBsimInit(double dt) {
+ FG_LOG( FG_FLIGHT, FG_INFO, "Starting initializing JSBsim" );
+
+ FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" );
+
+ FGPath aircraft_path( current_options.get_fg_root() );
+ aircraft_path.append( "Aircraft" );
+
+ FGPath engine_path( current_options.get_fg_root() );
+ engine_path.append( "Engine" );
+
+ FDMExec.GetAircraft()->LoadAircraftEx(aircraft_path.str(),
+ engine_path.str(), "X15");
+ FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" );
+
+ FDMExec.GetState()->Reset(aircraft_path.str(), "Reset00");
+ FG_LOG( FG_FLIGHT, FG_INFO, " loaded initial conditions" );
+
+ FDMExec.GetState()->Setdt(dt);
+ FG_LOG( FG_FLIGHT, FG_INFO, " set dt" );
+
+ FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing JSBsim" );
+
+ return 1;
+}
+
+
+// Run an iteration of the EOM (equations of motion)
+int fgJSBsimUpdate(FGInterface& f, int multiloop) {
+ double save_alt = 0.0;
+
+ // lets try to avoid really screwing up the JSBsim model
+ if ( f.get_Altitude() < -9000 ) {
+ save_alt = f.get_Altitude();
+ f.set_Altitude( 0.0 );
+ }
+
+ // copy control positions into the JSBsim structure
+ FDMExec.GetFCS()->SetDa( controls.get_aileron() );
+ FDMExec.GetFCS()->SetDe( controls.get_elevator()
+ + controls.get_elevator_trim() );
+ FDMExec.GetFCS()->SetDr( controls.get_rudder() );
+ FDMExec.GetFCS()->SetDf( 0.0 );
+ FDMExec.GetFCS()->SetDs( 0.0 );
+ FDMExec.GetFCS()->SetThrottle( FGControls::ALL_ENGINES,
+ controls.get_throttle( 0 ) );
+ // FCS->SetBrake( controls.get_brake( 0 ) );
+
+ // Inform JSBsim of the local terrain altitude
+ // Runway_altitude = f.get_Runway_altitude();
+
+ // old -- FGInterface_2_JSBsim() not needed except for Init()
+ // translate FG to JSBsim structure
+ // FGInterface_2_JSBsim(f);
+ // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
+ // printf("Altitude = %.2f\n", Altitude * 0.3048);
+ // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
+
+ /* FDMExec.GetState()->Setsim_time(State->Getsim_time()
+ + State->Getdt() * multiloop); */
+
+ for ( int i = 0; i < multiloop; i++ ) {
+ FDMExec.Run();
+ }
+
+ // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
+ // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
+
+ // translate JSBsim back to FG structure so that the
+ // autopilot (and the rest of the sim can use the updated
+ // values
+
+ fgJSBsim_2_FGInterface(f);
+
+ // but lets restore our original bogus altitude when we are done
+ if ( save_alt < -9000.0 ) {
+ f.set_Altitude( save_alt );
+ }
+
+ return 1;
+}
+
+
+// Convert from the FGInterface struct to the JSBsim generic_ struct
+int FGInterface_2_JSBsim (FGInterface& f) {
+
+ return 1;
+}
+
+
+// Convert from the JSBsim generic_ struct to the FGInterface struct
+int fgJSBsim_2_FGInterface (FGInterface& f) {
+
+ // Velocities
+ f.set_Velocities_Local( FDMExec.GetPosition()->GetVn(),
+ FDMExec.GetPosition()->GetVe(),
+ FDMExec.GetPosition()->GetVd() );
+ // f.set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
+ // V_down_rel_ground );
+ // f.set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
+ // V_down_airmass );
+ // f.set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
+ // V_east_rel_airmass, V_down_rel_airmass );
+ // f.set_Velocities_Gust( U_gust, V_gust, W_gust );
+ // f.set_Velocities_Wind_Body( U_body, V_body, W_body );
+
+ // f.set_V_rel_wind( V_rel_wind );
+ // f.set_V_true_kts( V_true_kts );
+ // f.set_V_rel_ground( V_rel_ground );
+ // f.set_V_inertial( V_inertial );
+ // f.set_V_ground_speed( V_ground_speed );
+ // f.set_V_equiv( V_equiv );
+
+ /* ***FIXME*** */ f.set_V_equiv_kts( FDMExec.GetState()->GetVt() );
+ // f.set_V_calibrated( V_calibrated );
+ // f.set_V_calibrated_kts( V_calibrated_kts );
+
+ f.set_Omega_Body( FDMExec.GetRotation()->GetP(),
+ FDMExec.GetRotation()->GetQ(),
+ FDMExec.GetRotation()->GetR() );
+ // f.set_Omega_Local( P_local, Q_local, R_local );
+ // f.set_Omega_Total( P_total, Q_total, R_total );
+
+ // f.set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
+ // ***FIXME*** f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
+
+ // Positions
+ double lat_geoc = FDMExec.GetState()->Getlatitude();
+ double lon = FDMExec.GetState()->Getlongitude();
+ double alt = FDMExec.GetState()->Geth();
+ double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
+ fgGeocToGeod( lat_geoc, EQUATORIAL_RADIUS_M + alt * FEET_TO_METER,
+ &lat_geod, &tmp_alt, &sl_radius1 );
+ fgGeodToGeoc( lat_geod, alt * FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
+
+ FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon << " lat_geod = " << lat_geod
+ << " lat_geoc = " << lat_geoc
+ << " alt = " << alt << " tmp_alt = " << tmp_alt * METER_TO_FEET
+ << " sl_radius1 = " << sl_radius1 * METER_TO_FEET
+ << " sl_radius2 = " << sl_radius2 * METER_TO_FEET
+ << " Equator = " << EQUATORIAL_RADIUS_FT );
+
+ f.set_Geocentric_Position( lat_geoc, lon,
+ sl_radius2 * METER_TO_FEET + alt );
+ f.set_Geodetic_Position( lat_geod, lon, alt );
+ f.set_Euler_Angles( FDMExec.GetRotation()->Getphi(),
+ FDMExec.GetRotation()->Gettht(),
+ FDMExec.GetRotation()->Getpsi() );
+
+ // Miscellaneous quantities
+ // f.set_T_Local_to_Body(T_local_to_body_m);
+ // f.set_Gravity( Gravity );
+ // f.set_Centrifugal_relief( Centrifugal_relief );
+
+ f.set_Alpha( FDMExec.GetTranslation()->Getalpha() );
+ f.set_Beta( FDMExec.GetTranslation()->Getbeta() );
+ // f.set_Alpha_dot( Alpha_dot );
+ // f.set_Beta_dot( Beta_dot );
+
+ // f.set_Cos_alpha( Cos_alpha );
+ // f.set_Sin_alpha( Sin_alpha );
+ // f.set_Cos_beta( Cos_beta );
+ // f.set_Sin_beta( Sin_beta );
+
+ // f.set_Cos_phi( Cos_phi );
+ // f.set_Sin_phi( Sin_phi );
+ // f.set_Cos_theta( Cos_theta );
+ // f.set_Sin_theta( Sin_theta );
+ // f.set_Cos_psi( Cos_psi );
+ // f.set_Sin_psi( Sin_psi );
+
+ // ***ATTENDTOME*** f.set_Gamma_vert_rad( Gamma_vert_rad );
+ // f.set_Gamma_horiz_rad( Gamma_horiz_rad );
+
+ // f.set_Sigma( Sigma );
+ // f.set_Density( Density );
+ // f.set_V_sound( V_sound );
+ // f.set_Mach_number( Mach_number );
+
+ // f.set_Static_pressure( Static_pressure );
+ // f.set_Total_pressure( Total_pressure );
+ // f.set_Impact_pressure( Impact_pressure );
+ // f.set_Dynamic_pressure( Dynamic_pressure );
+
+ // f.set_Static_temperature( Static_temperature );
+ // f.set_Total_temperature( Total_temperature );
+
+ /* **FIXME*** */ f.set_Sea_level_radius( sl_radius2 * METER_TO_FEET );
+ /* **FIXME*** */ f.set_Earth_position_angle( 0.0 );
+
+ /* ***FIXME*** */ f.set_Runway_altitude( 0.0 );
+ // f.set_Runway_latitude( Runway_latitude );
+ // f.set_Runway_longitude( Runway_longitude );
+ // f.set_Runway_heading( Runway_heading );
+ // f.set_Radius_to_rwy( Radius_to_rwy );
+
+ // f.set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
+ // f.set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
+ // f.set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
+ // D_pilot_above_rwy );
+ // f.set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
+
+ f.set_sin_lat_geocentric( lat_geoc );
+ f.set_cos_lat_geocentric( lat_geoc );
+ f.set_sin_cos_longitude( lon );
+ f.set_sin_cos_latitude( lat_geod );
+
+ return 0;
+}
+
+
--- /dev/null
+// JSBsim.hxx -- interface to the "JSBsim" flight model
+//
+// Written by Curtis Olson, started February 1999.
+//
+// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+
+#ifndef _JSBSIM_HXX
+#define _JSBSIM_HXX
+
+#include <FDM/JSBsim/FGFDMExec.h>
+#undef MAX_ENGINES
+
+#include <Aircraft/aircraft.hxx>
+
+
+// reset flight params to a specific position
+int fgJSBsimInit(double dt);
+
+// update position based on inputs, positions, velocities, etc.
+int fgJSBsimUpdate(FGInterface& f, int multiloop);
+
+// Convert from the FGInterface struct to the JSBsim generic_ struct
+int FGInterface_2_JSBsim (FGInterface& f);
+
+// Convert from the JSBsim generic_ struct to the FGInterface struct
+int fgJSBsim_2_FGInterface (FGInterface& f);
+
+
+#endif // _JSBSIM_HXX
+
+
--- /dev/null
+/*******************************************************************************
+
+ Module: FGAircraft.cpp
+ Author: Jon S. Berndt
+ Date started: 12/12/98
+ Purpose: Encapsulates an aircraft
+ Called by: FGFDMExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+Models the aircraft reactions and forces. This class is instantiated by the
+FGFDMExec class and scheduled as an FDM entry. LoadAircraft() is supplied with a
+name of a valid, registered aircraft, and the data file is parsed.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/12/98 JSB Created
+04/03/99 JSB Changed Aero() method to correct body axis force calculation
+ from wind vector. Fix provided by Tony Peden.
+05/03/99 JSB Changed (for the better?) the way configurations are read in.
+
+********************************************************************************
+COMMENTS, REFERENCES, and NOTES
+********************************************************************************
+[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
+ Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
+ School, January 1994
+[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
+ JSC 12960, July 1977
+[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
+ NASA-Ames", NASA CR-2497, January 1975
+[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
+ Wiley & Sons, 1979 ISBN 0-471-03032-5
+[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
+ 1982 ISBN 0-471-08936-2
+
+The aerodynamic coefficients used in this model are:
+
+Longitudinal
+ CL0 - Reference lift at zero alpha
+ CD0 - Reference drag at zero alpha
+ CDM - Drag due to Mach
+ CLa - Lift curve slope (w.r.t. alpha)
+ CDa - Drag curve slope (w.r.t. alpha)
+ CLq - Lift due to pitch rate
+ CLM - Lift due to Mach
+ CLadt - Lift due to alpha rate
+
+ Cmadt - Pitching Moment due to alpha rate
+ Cm0 - Reference Pitching moment at zero alpha
+ Cma - Pitching moment slope (w.r.t. alpha)
+ Cmq - Pitch damping (pitch moment due to pitch rate)
+ CmM - Pitch Moment due to Mach
+
+Lateral
+ Cyb - Side force due to sideslip
+ Cyr - Side force due to yaw rate
+
+ Clb - Dihedral effect (roll moment due to sideslip)
+ Clp - Roll damping (roll moment due to roll rate)
+ Clr - Roll moment due to yaw rate
+ Cnb - Weathercocking stability (yaw moment due to sideslip)
+ Cnp - Rudder adverse yaw (yaw moment due to roll rate)
+ Cnr - Yaw damping (yaw moment due to yaw rate)
+
+Control
+ CLDe - Lift due to elevator
+ CDDe - Drag due to elevator
+ CyDr - Side force due to rudder
+ CyDa - Side force due to aileron
+
+ CmDe - Pitch moment due to elevator
+ ClDa - Roll moment due to aileron
+ ClDr - Roll moment due to rudder
+ CnDr - Yaw moment due to rudder
+ CnDa - Yaw moment due to aileron
+
+This class expects to be run in a directory which contains the subdirectory
+structure shown below (where example aircraft X-15 is shown):
+
+aircraft/
+ X-15/
+ X-15.dat reset00 reset01 reset02 ...
+ CDRAG/
+ a0 a M De
+ CSIDE/
+ b r Dr Da
+ CLIFT/
+ a0 a M adt De
+ CROLL/
+ b p r Da Dr
+ CPITCH/
+ a0 a adt q M De
+ CYAW/
+ b p r Dr Da
+ F-16/
+ F-16.dat reset00 reset01 ...
+ CDRAG/
+ a0 a M De
+ ...
+
+The General Idea
+
+The file structure is arranged so that various modeled aircraft are stored in
+their own subdirectory. Each aircraft subdirectory is named after the aircraft.
+There should be a file present in the specific aircraft subdirectory (e.g.
+aircraft/X-15) with the same name as the directory with a .dat appended. This
+file contains mass properties information, name of aircraft, etc. for the
+aircraft. In that same directory are reset files numbered starting from 0 (two
+digit numbers), e.g. reset03. Within each reset file are values for important
+state variables for specific flight conditions (altitude, airspeed, etc.). Also
+within this directory are the directories containing lookup tables for the
+stability derivatives for the aircraft.
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#ifdef FGFS
+# ifndef __BORLANDC__
+# include <Include/compiler.h>
+# endif
+# ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+# else
+# include <math.h>
+# endif
+#else
+# include <cmath>
+#endif
+
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGFCS.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ int i;
+
+ Name = "FGAircraft";
+
+ for (i=0;i<6;i++) coeff_ctr[i] = 0;
+}
+
+
+FGAircraft::~FGAircraft(void)
+{
+}
+
+bool FGAircraft::LoadAircraftEx(string aircraft_path, string engine_path, string fname)
+{
+ string path;
+ string fullpath;
+ string filename;
+ string aircraftDef;
+ string tag;
+ string holding_string;
+ char scratch[128];
+ ifstream coeffInFile;
+
+ aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
+ ifstream aircraftfile(aircraftDef.c_str());
+ cout << "Reading Aircraft Configuration File: " << aircraftDef << endl;
+
+ numTanks = numEngines = 0;
+ numSelectedOxiTanks = numSelectedFuelTanks = 0;
+
+ while (!aircraftfile.fail()) {
+ holding_string.erase();
+ aircraftfile >> holding_string;
+ // if (holding_string.compare("//",0,2) != 0) {
+ if ( !(holding_string.substr(0, 2) == "//") ) {
+
+ if (holding_string == "AIRCRAFT") {
+ cout << "Reading in Aircraft parameters ..." << endl;
+ } else if (holding_string == "AERODYNAMICS") {
+ cout << "Reading in Aerodynamic parameters ..." << endl;
+ } else if (holding_string == "AC_NAME") {
+ aircraftfile >> AircraftName; // String with no embedded spaces
+ cout << "Aircraft Name: " << AircraftName << endl;
+ } else if (holding_string == "AC_WINGAREA") {
+ aircraftfile >> WingArea;
+ cout << "Aircraft Wing Area: " << WingArea << endl;
+ } else if (holding_string == "AC_WINGSPAN") {
+ aircraftfile >> WingSpan;
+ cout << "Aircraft WingSpan: " << WingSpan << endl;
+ } else if (holding_string == "AC_CHORD") {
+ aircraftfile >> cbar;
+ cout << "Aircraft Chord: " << cbar << endl;
+ } else if (holding_string == "AC_IXX") {
+ aircraftfile >> Ixx;
+ cout << "Aircraft Ixx: " << Ixx << endl;
+ } else if (holding_string == "AC_IYY") {
+ aircraftfile >> Iyy;
+ cout << "Aircraft Iyy: " << Iyy << endl;
+ } else if (holding_string == "AC_IZZ") {
+ aircraftfile >> Izz;
+ cout << "Aircraft Izz: " << Izz << endl;
+ } else if (holding_string == "AC_IXZ") {
+ aircraftfile >> Ixz;
+ cout << "Aircraft Ixz: " << Ixz << endl;
+ } else if (holding_string == "AC_EMPTYWT") {
+ aircraftfile >> EmptyWeight;
+ EmptyMass = EmptyWeight / GRAVITY;
+ cout << "Aircraft Empty Weight: " << EmptyWeight << endl;
+ } else if (holding_string == "AC_CGLOC") {
+ aircraftfile >> Xcg >> Ycg >> Zcg;
+ cout << "Aircraft C.G.: " << Xcg << " " << Ycg << " " << Zcg << endl;
+ } else if (holding_string == "AC_EYEPTLOC") {
+ aircraftfile >> Xep >> Yep >> Zep;
+ cout << "Pilot Eyepoint: " << Xep << " " << Yep << " " << Zep << endl;
+ } else if (holding_string == "AC_TANK") {
+ Tank[numTanks] = new FGTank(aircraftfile);
+ switch(Tank[numTanks]->GetType()) {
+ case FGTank::ttFUEL:
+ numSelectedFuelTanks++;
+ cout << "Reading in Fuel Tank #" << numSelectedFuelTanks << " parameters ..." << endl;
+ break;
+ case FGTank::ttOXIDIZER:
+ numSelectedOxiTanks++;
+ cout << "Reading in Oxidizer Tank #" << numSelectedOxiTanks << " parameters ..." << endl;
+ break;
+ }
+ numTanks++;
+
+ } else if (holding_string == "AC_ENGINE") {
+
+ aircraftfile >> tag;
+ cout << "Reading in " << tag << " Engine parameters ..." << endl;
+ Engine[numEngines] = new FGEngine(FDMExec, engine_path, tag, numEngines);
+ numEngines++;
+
+ } else if (holding_string == "}") {
+
+ } else if (holding_string == "{") {
+
+ } else if (holding_string == "LIFT") {
+
+ cout << " Lift Coefficients ..." << endl;
+ aircraftfile >> tag;
+ streampos gpos = aircraftfile.tellg();
+ aircraftfile >> tag;
+ if ( !(tag == "}") ) {
+ aircraftfile.seekg(gpos);
+ Coeff[LiftCoeff][coeff_ctr[LiftCoeff]] = new FGCoefficient(FDMExec, aircraftfile);
+ coeff_ctr[LiftCoeff]++;
+ } else {
+ cout << " None found ..." << endl;
+ }
+
+ } else if (holding_string == "DRAG") {
+
+ cout << " Drag Coefficients ..." << endl;
+ aircraftfile >> tag;
+ streampos gpos = aircraftfile.tellg();
+ aircraftfile >> tag;
+ if ( !(tag == "}") ) {
+ aircraftfile.seekg(gpos);
+ Coeff[DragCoeff][coeff_ctr[DragCoeff]] = new FGCoefficient(FDMExec, aircraftfile);
+ coeff_ctr[DragCoeff]++;
+ } else {
+ cout << " None found ..." << endl;
+ }
+
+ } else if (holding_string == "SIDE") {
+
+ cout << " Side Coefficients ..." << endl;
+ aircraftfile >> tag;
+ streampos gpos = aircraftfile.tellg();
+ aircraftfile >> tag;
+ if ( !(tag == "}") ) {
+ aircraftfile.seekg(gpos);
+ Coeff[SideCoeff][coeff_ctr[SideCoeff]] = new FGCoefficient(FDMExec, aircraftfile);
+ coeff_ctr[SideCoeff]++;
+ } else {
+ cout << " None found ..." << endl;
+ }
+
+ } else if (holding_string == "ROLL") {
+
+ cout << " Roll Coefficients ..." << endl;
+ aircraftfile >> tag;
+ streampos gpos = aircraftfile.tellg();
+ aircraftfile >> tag;
+ if ( !(tag == "}") ) {
+ aircraftfile.seekg(gpos);
+ Coeff[RollCoeff][coeff_ctr[RollCoeff]] = new FGCoefficient(FDMExec, aircraftfile);
+ coeff_ctr[RollCoeff]++;
+ } else {
+ cout << " None found ..." << endl;
+ }
+
+ } else if (holding_string == "PITCH") {
+
+ cout << " Pitch Coefficients ..." << endl;
+ aircraftfile >> tag;
+ streampos gpos = aircraftfile.tellg();
+ aircraftfile >> tag;
+ if ( !(tag == "}") ) {
+ aircraftfile.seekg(gpos);
+ Coeff[PitchCoeff][coeff_ctr[PitchCoeff]] = new FGCoefficient(FDMExec, aircraftfile);
+ coeff_ctr[PitchCoeff]++;
+ } else {
+ cout << " None found ..." << endl;
+ }
+
+ } else if (holding_string == "YAW") {
+
+ cout << " Yaw Coefficients ..." << endl;
+ aircraftfile >> tag;
+ streampos gpos = aircraftfile.tellg();
+ aircraftfile >> tag;
+ if ( !(tag == "}") ) {
+ aircraftfile.seekg(gpos);
+ Coeff[YawCoeff][coeff_ctr[YawCoeff]] = new FGCoefficient(FDMExec, aircraftfile);
+ coeff_ctr[YawCoeff]++;
+ } else {
+ cout << " None found ..." << endl;
+ }
+
+ } else {
+ }
+
+ } else {
+ aircraftfile.getline(scratch, 127);
+ }
+ }
+ cout << "End of Configuration File Parsing." << endl;
+ return true;
+}
+
+
+bool FGAircraft::Run(void)
+{
+ if (!FGModel::Run()) { // if false then execute this Run()
+ GetState();
+
+ for (int i = 0; i < 3; i++) Forces[i] = Moments[i] = 0.0;
+
+ MassChange();
+
+ FProp(); FAero(); FGear(); FMass();
+ MProp(); MAero(); MGear(); MMass();
+
+ PutState();
+ } else { // skip Run() execution this time
+ }
+ return false;
+}
+
+
+void FGAircraft::MassChange()
+{
+ // UPDATE TANK CONTENTS
+ //
+ // For each engine, cycle through the tanks and draw an equal amount of
+ // fuel (or oxidizer) from each active tank. The needed amount of fuel is
+ // determined by the engine in the FGEngine class. If more fuel is needed
+ // than is available in the tank, then that amount is considered a shortage,
+ // and will be drawn from the next tank. If the engine cannot be fed what it
+ // needs, it will be considered to be starved, and will shut down.
+
+ float Oshortage, Fshortage;
+
+ for (int e=0; e<numEngines; e++) {
+ Fshortage = Oshortage = 0.0;
+ for (int t=0; t<numTanks; t++) {
+ switch(Engine[e]->GetType()) {
+ case FGEngine::etRocket:
+
+ switch(Tank[t]->GetType()) {
+ case FGTank::ttFUEL:
+ if (Tank[t]->GetSelected()) {
+ Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
+ numSelectedFuelTanks)*(dt*rate) + Fshortage);
+ }
+ break;
+ case FGTank::ttOXIDIZER:
+ if (Tank[t]->GetSelected()) {
+ Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
+ numSelectedOxiTanks)*(dt*rate) + Oshortage);
+ }
+ break;
+ }
+ break;
+
+ case FGEngine::etPiston:
+ case FGEngine::etTurboJet:
+ case FGEngine::etTurboProp:
+
+ if (Tank[t]->GetSelected()) {
+ Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
+ numSelectedFuelTanks)*(dt*rate) + Fshortage);
+ }
+ break;
+ }
+ }
+ if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
+ else Engine[e]->SetStarved(false);
+ }
+
+ Weight = EmptyWeight;
+ for (int t=0; t<numTanks; t++)
+ Weight += Tank[t]->GetContents();
+
+ Mass = Weight / GRAVITY;
+}
+
+
+void FGAircraft::FAero(void)
+{
+ float F[3];
+
+ F[0] = F[1] = F[2] = 0.0;
+
+ for (int axis_ctr = 0; axis_ctr < 3; axis_ctr++)
+ for (int ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++)
+ F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
+
+ Forces[0] += F[DragCoeff]*cos(alpha)*cos(beta) - F[SideCoeff]*cos(alpha)*sin(beta) - F[LiftCoeff]*sin(alpha);
+ Forces[1] += F[DragCoeff]*sin(beta) + F[SideCoeff]*cos(beta);
+ Forces[2] += F[DragCoeff]*sin(alpha)*cos(beta) - F[SideCoeff]*sin(alpha)*sin(beta) + F[LiftCoeff]*cos(alpha);
+}
+
+
+void FGAircraft::FGear(void)
+{
+ if (GearUp) {
+ } else {
+ }
+}
+
+
+void FGAircraft::FMass(void)
+{
+ Forces[0] += -GRAVITY*sin(tht) * Mass;
+ Forces[1] += GRAVITY*sin(phi)*cos(tht) * Mass;
+ Forces[2] += GRAVITY*cos(phi)*cos(tht) * Mass;
+}
+
+
+void FGAircraft::FProp(void)
+{
+ for (int i=0;i<numEngines;i++) {
+ Forces[0] += Engine[i]->CalcThrust();
+ }
+}
+
+
+void FGAircraft::MAero(void)
+{
+ int axis_ctr, ctr;
+
+ for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
+ for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
+ Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue();
+ }
+ }
+}
+
+
+void FGAircraft::MGear(void)
+{
+ if (GearUp) {
+ } else {
+ }
+}
+
+
+void FGAircraft::MMass(void)
+{
+}
+
+
+void FGAircraft::MProp(void)
+{
+}
+
+
+void FGAircraft::GetState(void)
+{
+ dt = State->Getdt();
+
+ alpha = Translation->Getalpha();
+ beta = Translation->Getbeta();
+ phi = Rotation->Getphi();
+ tht = Rotation->Gettht();
+ psi = Rotation->Getpsi();
+}
+
+
+void FGAircraft::PutState(void)
+{
+}
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGAircraft.h
+ Author: Jon S. Berndt
+ Date started: 12/12/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/12/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGAIRCRAFT_H
+#define FGAIRCRAFT_H
+
+/*******************************************************************************
+COMMENTS, REFERENCES, and NOTES
+*******************************************************************************/
+/**
+The aerodynamic coefficients used in this model typically are:
+<PRE>
+<b>Longitudinal</b>
+ CL0 - Reference lift at zero alpha
+ CD0 - Reference drag at zero alpha
+ CDM - Drag due to Mach
+ CLa - Lift curve slope (w.r.t. alpha)
+ CDa - Drag curve slope (w.r.t. alpha)
+ CLq - Lift due to pitch rate
+ CLM - Lift due to Mach
+ CLadt - Lift due to alpha rate
+
+ Cmadt - Pitching Moment due to alpha rate
+ Cm0 - Reference Pitching moment at zero alpha
+ Cma - Pitching moment slope (w.r.t. alpha)
+ Cmq - Pitch damping (pitch moment due to pitch rate)
+ CmM - Pitch Moment due to Mach
+
+<b>Lateral</b>
+ Cyb - Side force due to sideslip
+ Cyr - Side force due to yaw rate
+
+ Clb - Dihedral effect (roll moment due to sideslip)
+ Clp - Roll damping (roll moment due to roll rate)
+ Clr - Roll moment due to yaw rate
+ Cnb - Weathercocking stability (yaw moment due to sideslip)
+ Cnp - Rudder adverse yaw (yaw moment due to roll rate)
+ Cnr - Yaw damping (yaw moment due to yaw rate)
+
+<b>Control</b>
+ CLDe - Lift due to elevator
+ CDDe - Drag due to elevator
+ CyDr - Side force due to rudder
+ CyDa - Side force due to aileron
+
+ CmDe - Pitch moment due to elevator
+ ClDa - Roll moment due to aileron
+ ClDr - Roll moment due to rudder
+ CnDr - Yaw moment due to rudder
+ CnDa - Yaw moment due to aileron
+</PRE>
+This class expects to be run in a directory which contains the subdirectory
+structure shown below (where example aircraft X-15 is shown):
+
+<PRE>
+aircraft/
+ X-15/
+ X-15.dat reset00 reset01 reset02 ...
+ CDRAG/
+ a0 a M De
+ CSIDE/
+ b r Dr Da
+ CLIFT/
+ a0 a M adt De
+ CROLL/
+ b p r Da Dr
+ CPITCH/
+ a0 a adt q M De
+ CYAW/
+ b p r Dr Da
+ F-16/
+ F-16.dat reset00 reset01 ...
+ CDRAG/
+ a0 a M De
+ ...
+</PRE>
+
+The General Idea
+
+The file structure is arranged so that various modeled aircraft are stored in
+their own subdirectory. Each aircraft subdirectory is named after the aircraft.
+There should be a file present in the specific aircraft subdirectory (e.g.
+aircraft/X-15) with the same name as the directory with a .dat appended. This
+file contains mass properties information, name of aircraft, etc. for the
+aircraft. In that same directory are reset files numbered starting from 0 (two
+digit numbers), e.g. reset03. Within each reset file are values for important
+state variables for specific flight conditions (altitude, airspeed, etc.). Also
+within this directory are the directories containing lookup tables for the
+stability derivatives for the aircraft.
+@author Jon S. Berndt
+@memo Encompasses all aircraft functionality and objects
+@see <ll>
+<li>[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
+ Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
+ School, January 1994</li>
+<li>[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
+ JSC 12960, July 1977</li>
+<li>[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
+ NASA-Ames", NASA CR-2497, January 1975</li>
+<li>[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
+ Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
+<li>[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
+ 1982 ISBN 0-471-08936-2</li>
+</ll>
+*/
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <fstream>
+# else
+# include <fstream.h>
+# endif
+# include STL_STRING
+ FG_USING_STD(string);
+#else
+# include <fstream>
+#endif
+
+#include "FGModel.h"
+#include "FGCoefficient.h"
+#include "FGEngine.h"
+#include "FGTank.h"
+
+/*******************************************************************************
+DEFINITIONS
+*******************************************************************************/
+
+#ifndef FGFS
+using namespace std;
+#endif
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGAircraft : public FGModel
+{
+public:
+ // ***************************************************************************
+ /** @memo Constructor
+ @param FGFDMExec* - a pointer to the "owning" FDM Executive
+ */
+ FGAircraft(FGFDMExec*);
+
+ // ***************************************************************************
+ /** Destructor */
+ ~FGAircraft(void);
+
+ // ***************************************************************************
+ /** This must be called for each dt to execute the model algorithm */
+ bool Run(void);
+
+ // ***************************************************************************
+ /** This function must be called with the name of an aircraft which
+ has an associated .dat file in the appropriate subdirectory. The paths
+ to the appropriate subdirectories are given as the first two parameters.
+ @memo Loads the given aircraft.
+ @param string Path to the aircraft files
+ @param string Path to the engine files
+ @param string The name of the aircraft to be loaded, e.g. "X15".
+ @return True - if successful
+ */
+ bool LoadAircraft(string, string, string);
+
+ // ***************************************************************************
+ /** This function must be called with the name of an aircraft which
+ has an associated .dat file in the appropriate subdirectory. The paths
+ to the appropriate subdirectories are given as the first two parameters.
+ @memo Loads the given aircraft.
+ @param string Path to the aircraft files
+ @param string Path to the engine files
+ @param string The name of the aircraft to be loaded, e.g. "X15".
+ @return True - if successful
+ */
+ bool LoadAircraftEx(string, string, string);
+
+ // ***************************************************************************
+ /** @memo Gets the aircraft name as defined in the aircraft config file.
+ @param
+ @return string Aircraft name.
+ */
+ inline string GetAircraftName(void) {return AircraftName;}
+
+ // ***************************************************************************
+ /** @memo Sets the GearUp flag
+ @param boolean true or false
+ @return
+ */
+ inline void SetGearUp(bool tt) {GearUp = tt;}
+
+ // ***************************************************************************
+ /** @memo Returns the state of the GearUp flag
+ @param
+ @return boolean true or false
+ */
+ inline bool GetGearUp(void) {return GearUp;}
+
+ // ***************************************************************************
+ /** @memo Returns the area of the wing
+ @param
+ @return float wing area S, in square feet
+ */
+ inline float GetWingArea(void) {return WingArea;}
+
+ // ***************************************************************************
+ /** @memo Returns the wing span
+ @param
+ @return float wing span in feet
+ */
+ inline float GetWingSpan(void) {return WingSpan;}
+
+ // ***************************************************************************
+ /** @memo Returns the average wing chord
+ @param
+ @return float wing chord in feet
+ */
+ inline float Getcbar(void) {return cbar;}
+
+ // ***************************************************************************
+ /** @memo Returns an engine object
+ @param int The engine number
+ @return FGEengine* The pointer to the requested engine object.
+ */
+ inline FGEngine* GetEngine(int tt) {return Engine[tt];}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline FGTank* GetTank(int tt) {return Tank[tt];}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetWeight(void) {return Weight;}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetMass(void) {return Mass;}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetL(void) {return Moments[0];}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetM(void) {return Moments[1];}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetN(void) {return Moments[2];}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetFx(void) {return Forces[0];}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetFy(void) {return Forces[1];}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetFz(void) {return Forces[2];}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetIxx(void) {return Ixx;}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetIyy(void) {return Iyy;}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetIzz(void) {return Izz;}
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ inline float GetIxz(void) {return Ixz;}
+
+private:
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void GetState(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void PutState(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void FAero(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void FGear(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void FMass(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void FProp(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void MAero(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void MGear(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void MMass(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void MProp(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ void MassChange(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ float Moments[3];
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ float Forces[3];
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ string AircraftName;
+
+ // ***************************************************************************
+ ///
+ float Ixx, Iyy, Izz, Ixz, EmptyMass, Mass;
+ ///
+ float Xcg, Ycg, Zcg;
+ ///
+ float Xep, Yep, Zep;
+ ///
+ float rho, qbar, Vt;
+ ///
+ float alpha, beta;
+ ///
+ float WingArea, WingSpan, cbar;
+ ///
+ float phi, tht, psi;
+ ///
+ float Weight, EmptyWeight;
+ ///
+ float dt;
+
+ ///
+ int numTanks;
+ ///
+ int numEngines;
+ ///
+ int numSelectedOxiTanks;
+ ///
+ int numSelectedFuelTanks;
+ ///
+ FGTank* Tank[MAX_TANKS];
+ ///
+ FGEngine *Engine[MAX_ENGINES];
+
+ ///
+ FGCoefficient *Coeff[6][10];
+ ///
+ int coeff_ctr[6];
+
+ ///
+ bool GearUp;
+
+ ///
+ enum Param {LiftCoeff,
+ DragCoeff,
+ SideCoeff,
+ RollCoeff,
+ PitchCoeff,
+ YawCoeff,
+ numCoeffs};
+
+ ///
+ string Axis[6];
+
+protected:
+
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGAtmosphere.cpp
+ Author: Jon Berndt
+ Date started: 11/24/98
+ Purpose: Models the atmosphere
+ Called by: FGSimExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+Models the atmosphere. The equation used below was determined by a third order
+curve fit using Excel. The data is from the ICAO atmosphere model.
+
+HISTORY
+--------------------------------------------------------------------------------
+11/24/98 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ Name = "FGAtmosphere";
+}
+
+
+FGAtmosphere::~FGAtmosphere()
+{
+}
+
+
+bool FGAtmosphere::Run(void)
+{
+ if (!FGModel::Run()) { // if false then execute this Run()
+ rho = 0.002377 - 7.0E-08*State->Geth()
+ + 7.0E-13*State->Geth()*State->Geth()
+ - 2.0E-18*State->Geth()*State->Geth()*State->Geth();
+
+ State->SetMach(State->GetVt()/State->Geta());
+ } else { // skip Run() execution this time
+ }
+ return false;
+}
--- /dev/null
+/*******************************************************************************
+
+ Header: FGAtmosphere.h
+ Author: Jon Berndt
+ Date started: 11/24/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+11/24/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGATMOSPHERE_H
+#define FGATMOSPHERE_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGModel.h"
+
+/*******************************************************************************
+COMMENTS, REFERENCES, and NOTES
+*******************************************************************************/
+/**
+The equation used in this model was determined by a third order curve fit using
+Excel. The data is from the ICAO atmosphere model.
+@memo Models the atmosphere.
+@author Jon S. Berndt
+*/
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+using namespace std;
+
+class FGAtmosphere : public FGModel
+{
+public:
+ // ***************************************************************************
+ /** @memo Constructor
+ @param FGFDMExec* - a pointer to the "owning" FDM Executive
+ */
+ FGAtmosphere(FGFDMExec*);
+
+ // ***************************************************************************
+ /** @memo Destructor
+ */
+ ~FGAtmosphere(void);
+
+ // ***************************************************************************
+ /** This must be called for each dt to execute the model algorithm */
+ bool Run(void);
+
+ // ***************************************************************************
+ /** @memo Returns the air density
+ @return float air density in slugs/cubic foot
+ */
+ inline float Getrho(void) {return rho;}
+
+protected:
+
+private:
+ float rho;
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGAuxiliary.cpp
+ Author: Jon Berndt
+ Date started: 01/26/99
+ Purpose: Calculates additional parameters needed by the visual system, etc.
+ Called by: FGSimExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class calculates various auxiliary parameters, mostly used by the visual
+system
+
+HISTORY
+--------------------------------------------------------------------------------
+01/26/99 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGAuxiliary.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGPosition.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ Name = "FGAuxiliary";
+}
+
+
+FGAuxiliary::~FGAuxiliary()
+{
+}
+
+
+bool FGAuxiliary::Run()
+{
+ if (!FGModel::Run()) {
+ } else {
+ }
+ return false;
+}
+
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGAuxiliary.h
+ Author: Jon Berndt
+ Date started: 01/26/99
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+11/22/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGAUXILIARY_H
+#define FGAUXILIARY_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+#include "FGModel.h"
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGAuxiliary : public FGModel
+{
+public:
+ FGAuxiliary(FGFDMExec*);
+ ~FGAuxiliary(void);
+
+ bool Run(void);
+
+protected:
+
+private:
+
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGCoefficient.cpp
+ Author: Jon S. Berndt
+ Date started: 12/28/98
+ Purpose: Encapsulates the stability derivative class FGCoefficient;
+ Called by: FGAircraft
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class models the stability derivative coefficient lookup tables or
+equations. Note that the coefficients need not be calculated each delta-t.
+
+The coefficient files are located in the axis subdirectory for each aircraft.
+For instance, for the X-15, you would find subdirectories under the
+aircraft/X-15/ directory named CLIFT, CDRAG, CSIDE, CROLL, CPITCH, CYAW. Under
+each of these directories would be files named a, a0, q, and so on. The file
+named "a" under the CLIFT directory would contain data for the stability
+derivative modeling lift due to a change in alpha. See the FGAircraft.cpp file
+for additional information. The coefficient files have the following format:
+
+<name of coefficient>
+<short description of coefficient with no embedded spaces>
+<method used in calculating the coefficient: TABLE | EQUATION | VECTOR | VALUE>
+ <parameter identifier for table row (if required)>
+ <parameter identifier for table column (if required)>
+<OR'ed list of parameter identifiers needed to turn this coefficient into a force>
+<number of rows in table (if required)>
+<number of columns in table (if required)>
+
+<value of parameter indexing into the column of a table or vector - or value
+ itself for a VALUE coefficient>
+<values of parameter indexing into row of a table if TABLE type> <Value of
+ coefficient at this row and column>
+
+<... repeat above for each column of data in table ...>
+
+As an example for the X-15, for the lift due to mach:
+
+CLa0
+Lift_at_zero_alpha
+Table 8 3
+16384
+32768
+16387
+
+0.00
+0.0 0.0
+0.5 0.4
+0.9 0.9
+1.0 1.6
+1.1 1.3
+1.4 1.0
+2.0 0.5
+3.0 0.5
+
+30000.00
+0.0 0.0
+0.5 0.5
+0.9 1.0
+1.0 1.7
+1.1 1.4
+1.4 1.1
+2.0 0.6
+3.0 0.6
+
+70000.00
+0.0 0.0
+0.5 0.6
+0.9 1.1
+1.0 1.7
+1.1 1.5
+1.4 1.2
+2.0 0.7
+3.0 0.7
+
+Note that the values in a row which index into the table must be the same value
+for each column of data, so the first column of numbers for each altitude are
+seen to be equal, and there are the same number of values for each altitude.
+
+See the header file FGCoefficient.h for the values of the identifiers.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/28/98 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGCoefficient.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile)
+{
+ int r, c;
+ float ftrashcan;
+ string strashcan;
+
+ FDMExec = fdex;
+ State = FDMExec->GetState();
+ Atmosphere = FDMExec->GetAtmosphere();
+ FCS = FDMExec->GetFCS();
+ Aircraft = FDMExec->GetAircraft();
+ Translation = FDMExec->GetTranslation();
+ Rotation = FDMExec->GetRotation();
+ Position = FDMExec->GetPosition();
+ Auxiliary = FDMExec->GetAuxiliary();
+ Output = FDMExec->GetOutput();
+
+ if (coeffDefFile) {
+ if (!coeffDefFile.fail()) {
+ coeffDefFile >> name;
+ cout << " " << name << endl;
+ coeffDefFile >> strashcan;
+ coeffDefFile >> description;
+ cout << " " << description << endl;
+ coeffDefFile >> method;
+ cout << " " << method << endl;
+
+ if (method == "EQUATION") type = EQUATION;
+ else if (method == "TABLE") type = TABLE;
+ else if (method == "VECTOR") type = VECTOR;
+ else if (method == "VALUE") type = VALUE;
+ else type = UNKNOWN;
+
+ if (type == VECTOR || type == TABLE) {
+ coeffDefFile >> rows;
+ cout << " Rows: " << rows << " ";
+ if (type == TABLE) {
+ coeffDefFile >> columns;
+ cout << "Cols: " << columns;
+ }
+ coeffDefFile >> LookupR;
+ cout << endl;
+ cout << " Row indexing parameter: " << LookupR << endl;
+ }
+
+ if (type == TABLE) {
+ coeffDefFile >> LookupC;
+ cout << " Column indexing parameter: " << LookupC << endl;
+ }
+
+ coeffDefFile >> multipliers;
+ cout << " Non-Dimensionalized by: ";
+
+ mult_count = 0;
+ if (multipliers & FG_QBAR) {
+ mult_idx[mult_count] = FG_QBAR;
+ mult_count++;
+ cout << "qbar ";
+ }
+ if (multipliers & FG_WINGAREA) {
+ mult_idx[mult_count] = FG_WINGAREA;
+ mult_count++;
+ cout << "S ";
+ }
+ if (multipliers & FG_WINGSPAN) {
+ mult_idx[mult_count] = FG_WINGSPAN;
+ mult_count++;
+ cout << "b ";
+ }
+ if (multipliers & FG_CBAR) {
+ mult_idx[mult_count] = FG_CBAR;
+ mult_count++;
+ cout << "c ";
+ }
+ if (multipliers & FG_ALPHA) {
+ mult_idx[mult_count] = FG_ALPHA;
+ mult_count++;
+ cout << "alpha ";
+ }
+ if (multipliers & FG_ALPHADOT) {
+ mult_idx[mult_count] = FG_ALPHADOT;
+ mult_count++;
+ cout << "alphadot ";
+ }
+ if (multipliers & FG_BETA) {
+ mult_idx[mult_count] = FG_BETA;
+ mult_count++;
+ cout << "beta ";
+ }
+ if (multipliers & FG_BETADOT) {
+ mult_idx[mult_count] = FG_BETADOT;
+ mult_count++;
+ cout << "betadot ";
+ }
+ if (multipliers & FG_PITCHRATE) {
+ mult_idx[mult_count] = FG_PITCHRATE;
+ mult_count++;
+ cout << "q ";
+ }
+ if (multipliers & FG_ROLLRATE) {
+ mult_idx[mult_count] = FG_ROLLRATE;
+ mult_count++;
+ cout << "p ";
+ }
+ if (multipliers & FG_YAWRATE) {
+ mult_idx[mult_count] = FG_YAWRATE;
+ mult_count++;
+ cout << "r ";
+ }
+ if (multipliers & FG_ELEVATOR) {
+ mult_idx[mult_count] = FG_ELEVATOR;
+ mult_count++;
+ cout << "De ";
+ }
+ if (multipliers & FG_AILERON) {
+ mult_idx[mult_count] = FG_AILERON;
+ mult_count++;
+ cout << "Da ";
+ }
+ if (multipliers & FG_RUDDER) {
+ mult_idx[mult_count] = FG_RUDDER;
+ mult_count++;
+ cout << "Dr ";
+ }
+ if (multipliers & FG_MACH) {
+ mult_idx[mult_count] = FG_MACH;
+ mult_count++;
+ cout << "Mach ";
+ }
+ if (multipliers & FG_ALTITUDE) {
+ mult_idx[mult_count] = FG_ALTITUDE;
+ mult_count++;
+ cout << "h ";
+ }
+ cout << endl;
+
+ switch(type) {
+ case VALUE:
+ coeffDefFile >> StaticValue;
+ break;
+ case VECTOR:
+ Allocate(rows,2);
+
+ for (r=1;r<=rows;r++) {
+ coeffDefFile >> Table3D[r][0];
+ coeffDefFile >> Table3D[r][1];
+ }
+
+ for (r=0;r<=rows;r++) {
+ cout << " ";
+ for (c=0;c<=columns;c++) {
+ cout << Table3D[r][c] << " ";
+ }
+ cout << endl;
+ }
+
+ break;
+ case TABLE:
+ Allocate(rows, columns);
+
+ for (c=1;c<=columns;c++) {
+ coeffDefFile >> Table3D[0][c];
+ for (r=1;r<=rows;r++) {
+ if ( c==1 ) coeffDefFile >> Table3D[r][0];
+ else coeffDefFile >> ftrashcan;
+ coeffDefFile >> Table3D[r][c];
+ }
+ }
+
+ for (r=0;r<=rows;r++) {
+ cout << " ";
+ for (c=0;c<=columns;c++) {
+ cout << Table3D[r][c] << " ";
+ }
+ cout << endl;
+ }
+
+ break;
+ }
+ } else {
+ cerr << "Empty file" << endl;
+ }
+ }
+}
+
+
+FGCoefficient::~FGCoefficient(void)
+{
+}
+
+
+bool FGCoefficient::Allocate(int r, int c)
+{
+ rows = r;
+ columns = c;
+ Table3D = new float*[r+1];
+ for (int i=0;i<=r;i++) Table3D[i] = new float[c+1];
+ return true;
+}
+
+
+bool FGCoefficient::Allocate(int n)
+{
+ rows = n;
+ columns = 0;
+ Table2D = new float[n+1];
+ return true;
+}
+
+
+float FGCoefficient::Value(float rVal, float cVal)
+{
+ float rFactor, cFactor, col1temp, col2temp, Value;
+ int r, c, midx;
+
+ if (rows < 2 || columns < 2) return 0.0;
+
+ for (r=1;r<=rows;r++) if (Table3D[r][0] >= rVal) break;
+ for (c=1;c<=columns;c++) if (Table3D[0][c] >= cVal) break;
+
+ c = c < 2 ? 2 : (c > columns ? columns : c);
+ r = r < 2 ? 2 : (r > rows ? rows : r);
+
+ rFactor = (rVal - Table3D[r-1][0]) / (Table3D[r][0] - Table3D[r-1][0]);
+ cFactor = (cVal - Table3D[0][c-1]) / (Table3D[0][c] - Table3D[0][c-1]);
+
+ col1temp = rFactor*(Table3D[r][c-1] - Table3D[r-1][c-1]) + Table3D[r-1][c-1];
+ col2temp = rFactor*(Table3D[r][c] - Table3D[r-1][c]) + Table3D[r-1][c];
+
+ Value = col1temp + cFactor*(col2temp - col1temp);
+
+//cout << "Value for " << description << " is " << Value;
+
+ for (midx=0;midx<mult_count;midx++) {
+ Value *= GetCoeffVal(mult_idx[midx]);
+ }
+
+//cout << " after multipliers it is: " << Value << endl;
+
+ return Value;
+}
+
+
+float FGCoefficient::Value(float Val)
+{
+ float Factor, Value;
+ int r, midx;
+
+ if (rows < 2) return 0.0;
+
+ for (r=1;r<=rows;r++) if (Table3D[r][0] >= Val) break;
+ r = r < 2 ? 2 : (r > rows ? rows : r);
+
+ // make sure denominator below does not go to zero.
+ if (Table3D[r][0] != Table3D[r-1][0]) {
+ Factor = (Val - Table3D[r-1][0]) / (Table3D[r][0] - Table3D[r-1][0]);
+ } else {
+ Factor = 1.0;
+ }
+
+ Value = Factor*(Table3D[r][1] - Table3D[r-1][1]) + Table3D[r-1][1];
+
+// cout << "Value for " << description << " is " << Value;
+
+ for (midx=0;midx<mult_count;midx++) {
+ Value *= GetCoeffVal(mult_idx[midx]);
+ }
+
+//cout << " after multipliers it is: " << Value << endl;
+
+ return Value;
+}
+
+
+float FGCoefficient::Value(void)
+{
+ float Value;
+ int midx;
+
+ Value = StaticValue;
+
+// cout << "Value for " << description << " is " << Value << endl;
+
+ for (midx=0;midx<mult_count;midx++) {
+ Value *= GetCoeffVal(mult_idx[midx]);
+ }
+
+// cout << " after multipliers it is: " << Value << endl;
+
+ return Value;
+}
+
+float FGCoefficient::TotalValue()
+{
+ switch(type) {
+ case 0:
+ return -1;
+ case 1:
+ return (Value());
+ case 2:
+ return (Value(GetCoeffVal(LookupR)));
+ case 3:
+ return (Value(GetCoeffVal(LookupR),GetCoeffVal(LookupC)));
+ case 4:
+ return 0.0;
+ }
+ return 0;
+}
+
+float FGCoefficient::GetCoeffVal(int val_idx)
+{
+ switch(val_idx) {
+ case FG_QBAR:
+//cout << "Qbar: " << State->Getqbar() << endl;
+ return State->Getqbar();
+ case FG_WINGAREA:
+//cout << "S: " << Aircraft->GetWingArea() << endl;
+ return Aircraft->GetWingArea();
+ case FG_WINGSPAN:
+//cout << "b: " << Aircraft->GetWingSpan() << endl;
+ return Aircraft->GetWingSpan();
+ case FG_CBAR:
+//cout << "Cbar: " << Aircraft->Getcbar() << endl;
+ return Aircraft->Getcbar();
+ case FG_ALPHA:
+//cout << "Alpha: " << Translation->Getalpha() << endl;
+ return Translation->Getalpha();
+ case FG_ALPHADOT:
+//cout << "Adot: " << State->Getadot() << endl;
+ return State->Getadot();
+ case FG_BETA:
+//cout << "Beta: " << Translation->Getbeta() << endl;
+ return Translation->Getbeta();
+ case FG_BETADOT:
+//cout << "Bdot: " << State->Getbdot() << endl;
+ return State->Getbdot();
+ case FG_PITCHRATE:
+//cout << "Q: " << Rotation->GetQ() << endl;
+ return Rotation->GetQ();
+ case FG_ROLLRATE:
+//cout << "P: " << Rotation->GetP() << endl;
+ return Rotation->GetP();
+ case FG_YAWRATE:
+//cout << "R: " << Rotation->GetR() << endl;
+ return Rotation->GetR();
+ case FG_ELEVATOR:
+//cout << "De: " << FCS->GetDe() << endl;
+ return FCS->GetDe();
+ case FG_AILERON:
+//cout << "Da: " << FCS->GetDa() << endl;
+ return FCS->GetDa();
+ case FG_RUDDER:
+//cout << "Dr: " << FCS->GetDr() << endl;
+ return FCS->GetDr();
+ case FG_MACH:
+//cout << "Mach: " << State->GetMach() << endl;
+ return State->GetMach();
+ case FG_ALTITUDE:
+//cout << "h: " << State->Geth() << endl;
+ return State->Geth();
+ }
+ return 0;
+}
--- /dev/null
+/*******************************************************************************
+
+ Header: FGCoefficient.h
+ Author: Jon Berndt
+ Date started: 12/28/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/28/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGCOEFFICIENT_H
+#define FGCOEFFICIENT_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+#ifdef FGFS
+# include <Include/compiler.h>
+# include STL_STRING
+# ifdef FG_HAVE_STD_INCLUDES
+# include <fstream>
+# else
+# include <fstream.h>
+# endif
+ FG_USING_STD(string);
+#else
+# include <string>
+# include <fstream>
+#endif
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+using namespace std;
+
+#define FG_QBAR 1
+#define FG_WINGAREA 2
+#define FG_WINGSPAN 4
+#define FG_CBAR 8
+#define FG_ALPHA 16
+#define FG_ALPHADOT 32
+#define FG_BETA 64
+#define FG_BETADOT 128
+#define FG_PITCHRATE 256
+#define FG_ROLLRATE 512
+#define FG_YAWRATE 1024
+#define FG_ELEVATOR 2048
+#define FG_AILERON 4096
+#define FG_RUDDER 8192
+#define FG_MACH 16384
+#define FG_ALTITUDE 32768L
+
+/*******************************************************************************
+FORWARD DECLARATIONS
+*******************************************************************************/
+class FGFDMExec;
+class FGState;
+class FGAtmosphere;
+class FGFCS;
+class FGAircraft;
+class FGTranslation;
+class FGRotation;
+class FGPosition;
+class FGAuxiliary;
+class FGOutput;
+
+/*******************************************************************************
+COMMENTS, REFERENCES, and NOTES
+*******************************************************************************/
+/**
+This class models the stability derivative coefficient lookup tables or
+equations. Note that the coefficients need not be calculated each delta-t.
+
+The coefficient files are located in the axis subdirectory for each aircraft.
+For instance, for the X-15, you would find subdirectories under the
+aircraft/X-15/ directory named CLIFT, CDRAG, CSIDE, CROLL, CPITCH, CYAW. Under
+each of these directories would be files named a, a0, q, and so on. The file
+named "a" under the CLIFT directory would contain data for the stability
+derivative modeling lift due to a change in alpha. See the FGAircraft.cpp file
+for additional information. The coefficient files have the following format:
+
+<name of coefficient>
+<short description of coefficient with no embedded spaces>
+<method used in calculating the coefficient: TABLE | EQUATION | VECTOR | VALUE>
+ <parameter identifier for table row (if required)>
+ <parameter identifier for table column (if required)>
+<OR'ed list of parameter identifiers needed to turn this coefficient into a force>
+<number of rows in table (if required)>
+<number of columns in table (if required)>
+
+<value of parameter indexing into the column of a table or vector - or value
+ itself for a VALUE coefficient>
+<values of parameter indexing into row of a table if TABLE type> <Value of
+ coefficient at this row and column>
+
+<... repeat above for each column of data in table ...>
+
+As an example for the X-15, for the lift due to mach:
+<PRE>
+
+CLa0
+Lift_at_zero_alpha
+Table 8 3
+16384
+32768
+16387
+
+0.00
+0.0 0.0
+0.5 0.4
+0.9 0.9
+1.0 1.6
+1.1 1.3
+1.4 1.0
+2.0 0.5
+3.0 0.5
+
+30000.00
+0.0 0.0
+0.5 0.5
+0.9 1.0
+1.0 1.7
+1.1 1.4
+1.4 1.1
+2.0 0.6
+3.0 0.6
+
+70000.00
+0.0 0.0
+0.5 0.6
+0.9 1.1
+1.0 1.7
+1.1 1.5
+1.4 1.2
+2.0 0.7
+3.0 0.7
+</PRE>
+
+Note that the values in a row which index into the table must be the same value
+for each column of data, so the first column of numbers for each altitude are
+seen to be equal, and there are the same number of values for each altitude.
+
+<PRE>
+FG_QBAR 1
+FG_WINGAREA 2
+FG_WINGSPAN 4
+FG_CBAR 8
+FG_ALPHA 16
+FG_ALPHADOT 32
+FG_BETA 64
+FG_BETADOT 128
+FG_PITCHRATE 256
+FG_ROLLRATE 512
+FG_YAWRATE 1024
+FG_ELEVATOR 2048
+FG_AILERON 4096
+FG_RUDDER 8192
+FG_MACH 16384
+FG_ALTITUDE 32768L
+</PRE>
+@author Jon S. Berndt
+@memo This class models the stability derivative coefficient lookup tables or equations.
+*/
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGCoefficient
+{
+public:
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ FGCoefficient(FGFDMExec*, ifstream&);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ ~FGCoefficient(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ bool Allocate(int);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ bool Allocate(int, int);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ float Value(float, float);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ float Value(float);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ float Value(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ float TotalValue(void);
+
+ // ***************************************************************************
+ /** @memo
+ @param
+ @return
+ */
+ enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
+
+protected:
+
+private:
+ string filename;
+ string description;
+ string name;
+ string method;
+ float StaticValue;
+ float *Table2D;
+ float **Table3D;
+ float LookupR, LookupC;
+ long int mult_idx[10];
+ int rows, columns;
+ Type type;
+ int multipliers;
+ int mult_count;
+
+ float GetCoeffVal(int);
+
+ FGFDMExec* FDMExec;
+ FGState* State;
+ FGAtmosphere* Atmosphere;
+ FGFCS* FCS;
+ FGAircraft* Aircraft;
+ FGTranslation* Translation;
+ FGRotation* Rotation;
+ FGPosition* Position;
+ FGAuxiliary* Auxiliary;
+ FGOutput* Output;
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+// controls.cxx -- defines a standard interface to all flight sim controls
+//
+// Written by Curtis Olson, started May 1997.
+//
+// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+// (Log is kept at end of this file)
+
+
+#include "FGControls.h"
+
+
+FGControls controls;
+
+
+// Constructor
+FGControls::FGControls() :
+ aileron( 0.0 ),
+ elevator( 0.0 ),
+ elevator_trim( 1.969572E-03 ),
+ rudder( 0.0 )
+{
+ for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
+ throttle[engine] = 0.0;
+ }
+
+ for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
+ brake[wheel] = 0.0;
+ }
+}
+
+
+// Destructor
+FGControls::~FGControls() {
+}
+
+
+// $Log$
+// Revision 1.1 1999/06/17 18:07:34 curt
+// Initial revision
+//
+// Revision 1.3 1999/05/08 03:19:15 curt
+// Incorporated latest JSBsim updates.
+//
+// Revision 1.1 1999/02/13 01:12:03 curt
+// Initial Revision.
+//
+// Revision 1.1 1999/02/09 04:51:32 jon
+// Initial revision
+//
+// Revision 1.3 1998/12/05 16:13:12 curt
+// Renamed class fgCONTROLS to class FGControls.
+//
+// Revision 1.2 1998/10/25 14:08:41 curt
+// Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
+//
+// Revision 1.1 1998/10/18 01:51:05 curt
+// c++-ifying ...
+//
+// Revision 1.8 1998/09/29 02:01:31 curt
+// Added a brake.
+//
+// Revision 1.7 1998/02/07 15:29:36 curt
+// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+// <chotchkiss@namg.us.anritsu.com>
+//
+// Revision 1.6 1998/01/19 19:27:02 curt
+// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+// This should simplify things tremendously.
+//
+// Revision 1.5 1998/01/19 18:40:22 curt
+// Tons of little changes to clean up the code and to remove fatal errors
+// when building with the c++ compiler.
+//
+// Revision 1.4 1997/12/10 22:37:41 curt
+// Prepended "fg" on the name of all global structures that didn't have it yet.
+// i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
+//
+// Revision 1.3 1997/08/27 03:30:01 curt
+// Changed naming scheme of basic shared structures.
+//
+// Revision 1.2 1997/06/21 17:12:48 curt
+// Capitalized subdirectory names.
+//
+// Revision 1.1 1997/05/31 19:24:04 curt
+// Initial revision.
+//
+
--- /dev/null
+// controls.hxx -- defines a standard interface to all flight sim controls
+//
+// Written by Curtis Olson, started May 1997.
+//
+// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+// (Log is kept at end of this file)
+
+
+#ifndef _CONTROLS_HXX
+#define _CONTROLS_HXX
+
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+//using namespace std;
+
+// Define a structure containing the control parameters
+
+class FGControls {
+
+public:
+
+ static const int ALL_ENGINES = -1;
+ static const int MAX_ENGINES = 10;
+
+ static const int ALL_WHEELS = -1;
+ static const int MAX_WHEELS = 3;
+
+private:
+
+ double aileron;
+ double elevator;
+ double elevator_trim;
+ double rudder;
+ double throttle[MAX_ENGINES];
+ double brake[MAX_WHEELS];
+
+public:
+
+ FGControls();
+ ~FGControls();
+
+ // Query functions
+ inline double get_aileron() const { return aileron; }
+ inline double get_elevator() const { return elevator; }
+ inline double get_elevator_trim() const { return elevator_trim; }
+ inline double get_rudder() const { return rudder; }
+ inline double get_throttle(int engine) const { return throttle[engine]; }
+ inline double get_brake(int wheel) const { return brake[wheel]; }
+
+ // Update functions
+ inline void set_aileron( double pos ) {
+ aileron = pos;
+ if ( aileron < -1.0 ) aileron = -1.0;
+ if ( aileron > 1.0 ) aileron = 1.0;
+ }
+ inline void move_aileron( double amt ) {
+ aileron += amt;
+ if ( aileron < -1.0 ) aileron = -1.0;
+ if ( aileron > 1.0 ) aileron = 1.0;
+ }
+ inline void set_elevator( double pos ) {
+ elevator = pos;
+ if ( elevator < -1.0 ) elevator = -1.0;
+ if ( elevator > 1.0 ) elevator = 1.0;
+ }
+ inline void move_elevator( double amt ) {
+ elevator += amt;
+ if ( elevator < -1.0 ) elevator = -1.0;
+ if ( elevator > 1.0 ) elevator = 1.0;
+ }
+ inline void set_elevator_trim( double pos ) {
+ elevator_trim = pos;
+ if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
+ if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
+ }
+ inline void move_elevator_trim( double amt ) {
+ elevator_trim += amt;
+ if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
+ if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
+ }
+ inline void set_rudder( double pos ) {
+ rudder = pos;
+ if ( rudder < -1.0 ) rudder = -1.0;
+ if ( rudder > 1.0 ) rudder = 1.0;
+ }
+ inline void move_rudder( double amt ) {
+ rudder += amt;
+ if ( rudder < -1.0 ) rudder = -1.0;
+ if ( rudder > 1.0 ) rudder = 1.0;
+ }
+ inline void set_throttle( int engine, double pos ) {
+ if ( engine == ALL_ENGINES ) {
+ for ( int i = 0; i < MAX_ENGINES; i++ ) {
+ throttle[i] = pos;
+ if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
+ if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
+ }
+ } else {
+ if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
+ throttle[engine] = pos;
+ if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
+ if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
+ }
+ }
+ }
+ inline void move_throttle( int engine, double amt ) {
+ if ( engine == ALL_ENGINES ) {
+ for ( int i = 0; i < MAX_ENGINES; i++ ) {
+ throttle[i] += amt;
+ if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
+ if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
+ }
+ } else {
+ if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
+ throttle[engine] += amt;
+ if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
+ if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
+ }
+ }
+ }
+ inline void set_brake( int wheel, double pos ) {
+ if ( wheel == ALL_WHEELS ) {
+ for ( int i = 0; i < MAX_WHEELS; i++ ) {
+ brake[i] = pos;
+ if ( brake[i] < 0.0 ) brake[i] = 0.0;
+ if ( brake[i] > 1.0 ) brake[i] = 1.0;
+ }
+ } else {
+ if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
+ brake[wheel] = pos;
+ if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
+ if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
+ }
+ }
+ }
+ inline void move_brake( int wheel, double amt ) {
+ if ( wheel == ALL_WHEELS ) {
+ for ( int i = 0; i < MAX_WHEELS; i++ ) {
+ brake[i] += amt;
+ if ( brake[i] < 0.0 ) brake[i] = 0.0;
+ if ( brake[i] > 1.0 ) brake[i] = 1.0;
+ }
+ } else {
+ if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
+ brake[wheel] += amt;
+ if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
+ if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
+ }
+ }
+ }
+};
+
+
+extern FGControls controls;
+
+
+#endif // _CONTROLS_HXX
+
+
+// $Log$
+// Revision 1.1 1999/06/17 18:07:34 curt
+// Initial revision
+//
+// Revision 1.3 1999/05/08 03:19:16 curt
+// Incorporated latest JSBsim updates.
+//
+// Revision 1.1 1999/02/13 01:12:03 curt
+// Initial Revision.
+//
+// Revision 1.3 1998/12/05 16:13:13 curt
+// Renamed class fgCONTROLS to class FGControls.
+//
+// Revision 1.2 1998/10/25 14:08:42 curt
+// Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
+//
+// Revision 1.1 1998/10/18 01:51:07 curt
+// c++-ifying ...
+//
+// Revision 1.17 1998/09/29 14:57:00 curt
+// c++-ified some comments.
+//
+// Revision 1.16 1998/09/29 02:01:32 curt
+// Added a brake.
+//
+// Revision 1.15 1998/04/25 22:06:27 curt
+// Edited cvs log messages in source files ... bad bad bad!
+//
+// Revision 1.14 1998/04/22 13:26:19 curt
+// C++ - ifing the code a bit.
+//
+// Revision 1.13 1998/04/21 17:02:35 curt
+// Prepairing for C++ integration.
+//
+// Revision 1.12 1998/02/09 22:56:48 curt
+// Removed "depend" files from cvs control. Other minor make tweaks.
+//
+// Revision 1.11 1998/02/07 15:29:36 curt
+// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+// <chotchkiss@namg.us.anritsu.com>
+//
+// Revision 1.10 1998/01/27 00:47:52 curt
+// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
+// system and commandline/config file processing code.
+//
+// Revision 1.9 1998/01/22 02:59:31 curt
+// Changed #ifdef FILE_H to #ifdef _FILE_H
+//
+// Revision 1.8 1998/01/19 18:40:22 curt
+// Tons of little changes to clean up the code and to remove fatal errors
+// when building with the c++ compiler.
+//
+// Revision 1.7 1997/12/15 23:54:36 curt
+// Add xgl wrappers for debugging.
+// Generate terrain normals on the fly.
+//
+// Revision 1.6 1997/12/10 22:37:41 curt
+// Prepended "fg" on the name of all global structures that didn't have it yet.
+// i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
+//
+// Revision 1.5 1997/08/27 03:30:02 curt
+// Changed naming scheme of basic shared structures.
+//
+// Revision 1.4 1997/07/23 21:52:18 curt
+// Put comments around the text after an #endif for increased portability.
+//
+// Revision 1.3 1997/05/31 19:16:27 curt
+// Elevator trim added.
+//
+// Revision 1.2 1997/05/23 15:40:33 curt
+// Added GNU copyright headers.
+//
+// Revision 1.1 1997/05/16 15:59:48 curt
+// Initial revision.
+//
--- /dev/null
+/*******************************************************************************
+
+ Header: FGDefs.h
+ Author: Jon S. Berndt
+ Date started: 02/01/99
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+02/01/99 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGDEFS_H
+#define FGDEFS_H
+
+#define MAX_ENGINES 10
+#define MAX_TANKS 30
+#define GRAVITY 32.174
+#define EARTHRAD 20898908.00 // feet
+#define OMEGAEARTH 7.2685E-3 // rad/sec
+#define EARTHRADSQRD 437882827922500.0
+#define ONESECOND 4.848136811E-6
+#define ECCENT 0.996647186
+#define ECCENTSQRD 0.99330561
+#define INVECCENTSQRD 1.0067395
+#define INVECCENTSQRDM1 0.0067395
+#define EPS 0.081819221
+
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGEngine.cpp
+ Author: Jon Berndt
+ Date started: 01/21/99
+ Called by: FGAircraft
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+See header file.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/21/99 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <fstream>
+# else
+# include <fstream.h>
+# endif
+#else
+# include <fstream>
+#endif
+
+#include "FGEngine.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGAtmosphere.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+
+FGEngine::FGEngine(FGFDMExec* fdex, string enginePath, string engineName, int num)
+{
+ string fullpath;
+ string tag;
+
+ FDMExec = fdex;
+
+ State = FDMExec->GetState();
+ Atmosphere = FDMExec->GetAtmosphere();
+ FCS = FDMExec->GetFCS();
+ Aircraft = FDMExec->GetAircraft();
+ Translation = FDMExec->GetTranslation();
+ Rotation = FDMExec->GetRotation();
+ Position = FDMExec->GetPosition();
+ Auxiliary = FDMExec->GetAuxiliary();
+ Output = FDMExec->GetOutput();
+
+ Name = engineName;
+ fullpath = enginePath + "/" + engineName + ".dat";
+ ifstream enginefile(fullpath.c_str());
+
+ if (enginefile) {
+ enginefile >> tag;
+
+ if (tag == "ROCKET") Type = etRocket;
+ else if (tag == "PISTON") Type = etPiston;
+ else if (tag == "TURBOPROP") Type = etTurboProp;
+ else if (tag == "TURBOJET") Type = etTurboJet;
+ else Type = etUnknown;
+
+ enginefile >> X;
+ enginefile >> Y;
+ enginefile >> Z;
+ enginefile >> SLThrustMax;
+ enginefile >> VacThrustMax;
+ enginefile >> MaxThrottle;
+ enginefile >> MinThrottle;
+ enginefile >> SLFuelFlowMax;
+ if (Type == 1)
+ enginefile >> SLOxiFlowMax;
+ enginefile.close();
+ } else {
+ cerr << "Unable to open engine definition file " << engineName << endl;
+ }
+
+ EngineNumber = num;
+ Thrust = 0.0;
+ Starved = Flameout = false;
+}
+
+
+FGEngine::~FGEngine(void)
+{
+}
+
+
+float FGEngine::CalcRocketThrust(void)
+{
+ float lastThrust;
+
+ Throttle = FCS->GetThrottle(EngineNumber);
+ lastThrust = Thrust; // last actual thrust
+
+ if (Throttle < MinThrottle || Starved) {
+ PctPower = Thrust = 0.0; // desired thrust
+ Flameout = true;
+ } else {
+ PctPower = Throttle / MaxThrottle;
+ Thrust = PctPower*((1.0 - Atmosphere->Getrho() / 0.002378)*(VacThrustMax - SLThrustMax) +
+ SLThrustMax); // desired thrust
+ Flameout = false;
+ }
+
+ Thrust += 0.8*(Thrust - lastThrust); // actual thrust
+
+ return Thrust;
+}
+
+
+float FGEngine::CalcPistonThrust(void)
+{
+ return Thrust;
+}
+
+
+float FGEngine::CalcThrust(void)
+{
+ switch(Type) {
+ case etRocket:
+ return CalcRocketThrust();
+ // break;
+ case etPiston:
+ return CalcPistonThrust();
+ // break;
+ default:
+ return 9999.0;
+ // break;
+ }
+}
+
+float FGEngine::CalcFuelNeed() {
+ FuelNeed = SLFuelFlowMax*PctPower;
+ return FuelNeed;
+}
+
+
+float FGEngine::CalcOxidizerNeed() {
+ OxidizerNeed = SLOxiFlowMax*PctPower;
+ return OxidizerNeed;
+}
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGEngine.h
+ Author: Jon S. Berndt
+ Date started: 01/21/99
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+Based on Flightgear code, which is based on LaRCSim. This class simulates
+a generic engine.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/21/99 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGEngine_H
+#define FGEngine_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# include STL_STRING
+ FG_USING_STD(string);
+#else
+# include <string>
+#endif
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGFDMExec;
+class FGState;
+class FGAtmosphere;
+class FGFCS;
+class FGAircraft;
+class FGTranslation;
+class FGRotation;
+class FGPosition;
+class FGAuxiliary;
+class FGOutput;
+
+class FGEngine
+{
+public:
+ FGEngine(FGFDMExec*, string, string, int);
+ ~FGEngine(void);
+
+ enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet};
+
+ float GetThrottle(void) {return Throttle;}
+ float GetThrust(void) {return Thrust;}
+ bool GetStarved(void) {return Starved;}
+ bool GetFlameout(void) {return Flameout;}
+ int GetType(void) {return Type;}
+ string GetName() {return Name;}
+
+ void SetStarved(bool tt) {Starved = tt;}
+ void SetStarved(void) {Starved = true;}
+
+ float CalcThrust(void);
+ float CalcFuelNeed(void);
+ float CalcOxidizerNeed(void);
+
+private:
+ string Name;
+ EngineType Type;
+ float X, Y, Z;
+ float SLThrustMax;
+ float VacThrustMax;
+ float SLFuelFlowMax;
+ float SLOxiFlowMax;
+ float MaxThrottle;
+ float MinThrottle;
+
+ float Thrust;
+ float Throttle;
+ float FuelNeed, OxidizerNeed;
+ bool Starved;
+ bool Flameout;
+ float PctPower;
+ int EngineNumber;
+
+ FGFDMExec* FDMExec;
+ FGState* State;
+ FGAtmosphere* Atmosphere;
+ FGFCS* FCS;
+ FGAircraft* Aircraft;
+ FGTranslation* Translation;
+ FGRotation* Rotation;
+ FGPosition* Position;
+ FGAuxiliary* Auxiliary;
+ FGOutput* Output;
+
+protected:
+ float CalcRocketThrust(void);
+ float CalcPistonThrust(void);
+
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGFCS.cpp
+ Author: Jon Berndt
+ Date started: 12/12/98
+ Purpose: Model the flight controls
+ Called by: FDMExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class models the flight controls for a specific airplane
+
+HISTORY
+--------------------------------------------------------------------------------
+12/12/98 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGFCS.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGAtmosphere.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+
+FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ Name = "FGFCS";
+}
+
+
+FGFCS::~FGFCS(void)
+{
+}
+
+
+bool FGFCS::Run(void)
+{
+ if (!FGModel::Run()) {
+
+ } else {
+ }
+ return false;
+}
--- /dev/null
+/*******************************************************************************
+
+ Header: FGGFCS.h
+ Author: Jon S. Berndt
+ Date started: 12/12/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/12/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGFCS_H
+#define FGFCS_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGModel.h"
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+using namespace std;
+
+class FGFCS : public FGModel
+{
+public:
+ FGFCS(FGFDMExec*);
+ ~FGFCS(void);
+
+ bool Run(void);
+
+ inline float GetDa(void) {return Da;}
+ inline float GetDe(void) {return De;}
+ inline float GetDr(void) {return Dr;}
+ inline float GetDf(void) {return Df;}
+ inline float GetDs(void) {return Ds;}
+ inline float GetThrottle(int ii) {return Throttle[ii];}
+
+ inline void SetDa(float tt) {Da = tt;}
+ inline void SetDe(float tt) {De = tt;}
+ inline void SetDr(float tt) {Dr = tt;}
+ inline void SetDf(float tt) {Df = tt;}
+ inline void SetDs(float tt) {Ds = tt;}
+ inline void SetThrottle(int ii, float tt) {Throttle[ii] = tt;}
+
+protected:
+
+private:
+ float Da, De, Dr, Df, Ds;
+ float Throttle[MAX_ENGINES];
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGFDMExec.cpp
+ Author: Jon S. Berndt
+ Date started: 11/17/98
+ Purpose: Schedules and runs the model routines.
+ Called by: The GUI.
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+This class wraps up the simulation scheduling routines.
+
+HISTORY
+--------------------------------------------------------------------------------
+11/17/98 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <iostream>
+# include <ctime>
+# else
+# include <iostream.h>
+# include <time.h>
+# endif
+#else
+# include <iostream>
+# include <ctime>
+#endif
+
+#include "FGFDMExec.h"
+#include "FGState.h"
+#include "FGAtmosphere.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+
+// Constructor
+
+FGFDMExec::FGFDMExec(void)
+{
+ FirstModel = 0;
+ Error = 0;
+ State = 0;
+ Atmosphere = 0;
+ FCS = 0;
+ Aircraft = 0;
+ Translation = 0;
+ Rotation = 0;
+ Position = 0;
+ Auxiliary = 0;
+ Output = 0;
+
+ // Instantiate this FDM Executive's Models
+
+ Atmosphere = new FGAtmosphere(this);
+ FCS = new FGFCS(this);
+ Aircraft = new FGAircraft(this);
+ Translation = new FGTranslation(this);
+ Rotation = new FGRotation(this);
+ Position = new FGPosition(this);
+ Auxiliary = new FGAuxiliary(this);
+ Output = new FGOutput(this);
+
+ State = new FGState(this);
+
+ // Initialize models so they can communicate with each other
+
+ if (!Atmosphere->InitModel()) {cerr << "Atmosphere model init failed"; Error+=1;}
+ if (!FCS->InitModel()) {cerr << "FCS model init failed"; Error+=2;}
+ if (!Aircraft->InitModel()) {cerr << "Aircraft model init failed"; Error+=4;}
+ if (!Translation->InitModel()){cerr << "Translation model init failed"; Error+=8;}
+ if (!Rotation->InitModel()) {cerr << "Rotation model init failed"; Error+=16;}
+ if (!Position->InitModel()) {cerr << "Position model init failed"; Error+=32;}
+ if (!Auxiliary->InitModel()) {cerr << "Auxiliary model init failed"; Error+=64;}
+ if (!Output->InitModel()) {cerr << "Output model init failed"; Error+=128;}
+
+ Schedule(Atmosphere, 5);
+ Schedule(FCS, 1);
+ Schedule(Aircraft, 1);
+ Schedule(Rotation, 1);
+ Schedule(Translation, 1);
+ Schedule(Position, 1);
+ Schedule(Auxiliary, 1);
+ Schedule(Output, 5);
+
+ terminate = false;
+ frozen = false;
+}
+
+
+FGFDMExec::~FGFDMExec(void)
+{
+}
+
+
+int FGFDMExec::Schedule(FGModel* model, int rate)
+{
+ FGModel* model_iterator;
+
+ model_iterator = FirstModel;
+
+ if (model_iterator == 0L) { // this is the first model
+
+ FirstModel = model;
+ FirstModel->NextModel = 0L;
+ FirstModel->SetRate(rate);
+
+ } else { // subsequent model
+
+ while (model_iterator->NextModel != 0L) {
+ model_iterator = model_iterator->NextModel;
+ }
+ model_iterator->NextModel = model;
+ model_iterator->NextModel->SetRate(rate);
+
+ }
+ return 0;
+}
+
+
+bool FGFDMExec::Run(void)
+{
+ FGModel* model_iterator;
+
+ if (frozen) return true;
+
+ model_iterator = FirstModel;
+ if (model_iterator == 0L) return false;
+
+ while (!model_iterator->Run())
+ {
+ model_iterator = model_iterator->NextModel;
+ if (model_iterator == 0L) break;
+ }
+
+ State->IncrTime();
+
+ return true;
+}
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGFDMExec.h
+ Author: Jon Berndt
+ Date started: 11/17/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+11/17/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGFDMEXEC_HEADER_H
+#define FGFDMEXEC_HEADER_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGModel.h"
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGState;
+class FGAtmosphere;
+class FGFCS;
+class FGAircraft;
+class FGTranslation;
+class FGRotation;
+class FGPosition;
+class FGAuxiliary;
+class FGOutput;
+
+class FGFDMExec
+{
+public:
+ FGFDMExec(void);
+ ~FGFDMExec(void);
+
+ FGModel* FirstModel;
+
+ bool Initialize(void);
+ int Schedule(FGModel* model, int rate);
+ bool Run(void);
+ void Freeze(void) {frozen = true;}
+ void Resume(void) {frozen = false;}
+
+ inline FGState* GetState(void) {return State;}
+ inline FGAtmosphere* GetAtmosphere(void) {return Atmosphere;}
+ inline FGFCS* GetFCS(void) {return FCS;}
+ inline FGAircraft* GetAircraft(void) {return Aircraft;}
+ inline FGTranslation* GetTranslation(void) {return Translation;}
+ inline FGRotation* GetRotation(void) {return Rotation;}
+ inline FGPosition* GetPosition(void) {return Position;}
+ inline FGAuxiliary* GetAuxiliary(void) {return Auxiliary;}
+ inline FGOutput* GetOutput(void) {return Output;}
+
+private:
+ bool frozen;
+ bool terminate;
+ int Error;
+
+ FGState* State;
+ FGAtmosphere* Atmosphere;
+ FGFCS* FCS;
+ FGAircraft* Aircraft;
+ FGTranslation* Translation;
+ FGRotation* Rotation;
+ FGPosition* Position;
+ FGAuxiliary* Auxiliary;
+ FGOutput* Output;
+
+protected:
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+#include "FGFDMExec.h"
+#include "FGRotation.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+#include <iostream>
+#include <ctime>
+
+void main(int argc, char** argv)
+{
+ FGFDMExec* FDMExec;
+
+ struct timespec short_wait = {0,100000000};
+ struct timespec no_wait = {0,100000000};
+
+ if (argc != 3) {
+ cout << endl
+ << " You must enter the name of a registered aircraft and reset point:"
+ << endl << endl << " FDM <aircraft name> <reset file>" << endl;
+ exit(0);
+ }
+
+ FDMExec = new FGFDMExec();
+
+ FDMExec->GetAircraft()->LoadAircraftEx("aircraft", "engine", string(argv[1]));
+ FDMExec->GetState()->Reset("aircraft", string(argv[2]));
+
+ while (FDMExec->GetState()->Getsim_time() <= 25.0)
+ {
+//
+// fake an aileron, rudder and elevator kick here after 20 seconds
+//
+
+ if (FDMExec->GetState()->Getsim_time() > 5.0) {
+ FDMExec->GetFCS()->SetDa(0.05);
+ FDMExec->GetFCS()->SetDr(0.05);
+ FDMExec->GetFCS()->SetDe(0.05);
+ }
+
+ FDMExec->Run();
+ nanosleep(&short_wait,&no_wait);
+ }
+
+ delete FDMExec;
+}
--- /dev/null
+/*******************************************************************************
+
+Module: FGMatrix.cpp
+Author: Tony Peden [formatted here by JSB]
+Date started: ??
+Purpose: FGMatrix class
+Called by: Various
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+
+ARGUMENTS
+--------------------------------------------------------------------------------
+
+
+HISTORY
+--------------------------------------------------------------------------------
+??/??/?? TP Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include <stdlib.h>
+#include "FGMatrix.h"
+#include <iostream.h>
+#include <iomanip.h>
+#include <fstream.h>
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+#pragma warn -use
+
+/*******************************************************************************
+CONSTANTS
+*******************************************************************************/
+
+
+/*******************************************************************************
+TYPEDEFS
+*******************************************************************************/
+
+
+/*******************************************************************************
+GLOBALS
+*******************************************************************************/
+
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+double** alloc(int rows,int cols)
+{
+ double **A;
+
+ A = new double *[rows+1];
+ if (!A) return NULL;
+
+ for (int i=0;i<=rows;i++){
+ A[i]=new double[cols+1];
+ if (!A[i]) return NULL;
+ }
+ return A;
+}
+
+
+void dealloc(double **A, int rows, int cols)
+{
+ for(int i=0;i<=rows;i++){
+ delete[] A[i];
+ }
+
+ delete[] A;
+}
+
+
+FGMatrix::FGMatrix(unsigned rows, unsigned cols)
+{
+ this->rows=rows;
+ this->cols=cols;
+ keep=false;
+ data=alloc(rows,cols);
+}
+
+
+FGMatrix::FGMatrix(const FGMatrix& A)
+{
+ data=NULL;
+ *this=A;
+}
+
+
+FGMatrix::~FGMatrix(void)
+{
+ if (keep == false) {
+ dealloc(data,rows,cols);
+ rows=cols=0;
+ }
+}
+
+
+FGMatrix& FGMatrix::operator=(const FGMatrix& A)
+{
+ if (&A != this) {
+ if (data != NULL) dealloc(data,rows,cols);
+
+ width = A.width;
+ prec = A.prec;
+ delim = A.delim;
+ origin = A.origin;
+ rows = A.rows;
+ cols = A.cols;
+ keep = false;
+
+ if (A.keep == true) {
+ data = A.data;
+ } else {
+ data = alloc(rows,cols);
+ for (int i=0; i<=rows; i++) {
+ for (int j=0; j<=cols; j++) {
+ data[i][j] = A.data[i][j];
+ }
+ }
+ }
+ }
+ return *this;
+}
+
+
+double& FGMatrix::operator()(unsigned row, unsigned col)
+{
+ return data[row][col];
+}
+
+
+unsigned FGMatrix::Rows(void) const
+{
+ return rows;
+}
+
+
+unsigned FGMatrix::Cols(void) const
+{
+ return cols;
+}
+
+
+void FGMatrix::SetOParams(char delim,int width,int prec,int origin)
+{
+ FGMatrix::delim=delim;
+ FGMatrix::width=width;
+ FGMatrix::prec=prec;
+ FGMatrix::origin=origin;
+}
+
+
+void FGMatrix::InitMatrix(double value)
+{
+ if (data) {
+ for (int i=0;i<=rows;i++) {
+ for (int j=0;j<=cols;j++) {
+ operator()(i,j) = value;
+ }
+ }
+ }
+}
+
+
+void FGMatrix::InitMatrix(void)
+{
+ this->InitMatrix(0);
+}
+
+
+FGMatrix operator-(FGMatrix& A, FGMatrix& B)
+{
+ if ((A.Rows() != B.Rows()) || (A.Cols() != B.Cols())) {
+ cout << endl << "FGMatrix::operator-" << endl << '\t';
+ cout << "Subtraction not defined for matrices of different sizes";
+ cout << endl;
+ exit(1);
+ }
+
+ FGMatrix Diff(A.Rows(),A.Cols());
+ Diff.keep=true;
+ for (int i=1;i<=A.Rows();i++) {
+ for (int j=1;j<=A.Cols();j++) {
+ Diff(i,j)=A(i,j)-B(i,j);
+ }
+ }
+ return Diff;
+}
+
+
+void operator-=(FGMatrix &A,FGMatrix &B)
+{
+ if ((A.Rows() != B.Rows()) || (A.Cols() != B.Cols())) {
+ cout << endl << "FGMatrix::operator-" << endl << '\t';
+ cout << "Subtraction not defined for matrices of different sizes";
+ cout << endl;
+ exit(1);
+ }
+
+ for (int i=1;i<=A.Rows();i++) {
+ for (int j=1;j<=A.Cols();j++) {
+ A(i,j)-=B(i,j);
+ }
+ }
+}
+
+
+FGMatrix operator+(FGMatrix& A, FGMatrix& B)
+{
+ if ((A.Rows() != B.Rows()) || (A.Cols() != B.Cols())) {
+ cout << endl << "FGMatrix::operator+" << endl << '\t';
+ cout << "Addition not defined for matrices of different sizes";
+ cout << endl;
+ exit(1);
+ }
+
+ FGMatrix Sum(A.Rows(),A.Cols());
+ Sum.keep = true;
+ for (int i=1;i<=A.Rows();i++) {
+ for (int j=1;j<=A.Cols();j++) {
+ Sum(i,j)=A(i,j)+B(i,j);
+ }
+ }
+ return Sum;
+}
+
+
+void operator+=(FGMatrix &A,FGMatrix &B)
+{
+ if ((A.Rows() != B.Rows()) || (A.Cols() != B.Cols())) {
+ cout << endl << "FGMatrix::operator+" << endl << '\t';
+ cout << "Addition not defined for matrices of different sizes";
+ cout << endl;
+ exit(1);
+ }
+ for (int i=1;i<=A.Rows();i++) {
+ for (int j=1;j<=A.Cols();j++) {
+ A(i,j)+=B(i,j);
+ }
+ }
+}
+
+
+FGMatrix operator*(double scalar,FGMatrix &A)
+{
+ FGMatrix Product(A.Rows(),A.Cols());
+ Product.keep = true;
+ for (int i=1;i<=A.Rows();i++) {
+ for (int j=1;j<=A.Cols();j++) {
+ Product(i,j) = scalar*A(i,j);
+ }
+ }
+ return Product;
+}
+
+
+void operator*=(FGMatrix &A,double scalar)
+{
+ for (int i=1;i<=A.Rows();i++) {
+ for (int j=1;j<=A.Cols();j++) {
+ A(i,j)*=scalar;
+ }
+ }
+}
+
+
+FGMatrix operator*(FGMatrix &Left, FGMatrix &Right)
+{
+ if (Left.Cols() != Right.Rows()) {
+ cout << endl << "FGMatrix::operator*" << endl << '\t';
+ cout << "The number of rows in the right matrix must match the number";
+ cout << endl << '\t' << "of columns in the left." << endl;
+ cout << '\t' << "Multiplication not defined." << endl;
+ exit(1);
+ }
+
+ FGMatrix Product(Left.Rows(),Right.Cols());
+ Product.keep = true;
+ for (int i=1;i<=Left.Rows();i++) {
+ for (int j=1;j<=Right.Cols();j++) {
+ Product(i,j) = 0;
+ for (int k=1;k<=Left.Cols();k++) {
+ Product(i,j)+=Left(i,k)*Right(k,j);
+ }
+ }
+ }
+ return Product;
+}
+
+
+void operator*=(FGMatrix &Left,FGMatrix &Right)
+{
+ if (Left.Cols() != Right.Rows()) {
+ cout << endl << "FGMatrix::operator*" << endl << '\t';
+ cout << "The number of rows in the right matrix must match the number";
+ cout << endl << '\t' << "of columns in the left." << endl;
+ cout << '\t' << "Multiplication not defined." << endl;
+ exit(1);
+ }
+
+ double **prod;
+
+ prod=alloc(Left.Rows(),Right.Cols());
+ for (int i=1;i<=Left.Rows();i++) {
+ for (int j=1;j<=Right.Cols();j++) {
+ prod[i][j] = 0;
+ for (int k=1;k<=Left.Cols();k++) {
+ prod[i][j]+=Left(i,k)*Right(k,j);
+ }
+ }
+ }
+ dealloc(Left.data,Left.Rows(),Left.Cols());
+ Left.data=prod;
+ Left.cols=Right.cols;
+}
+
+
+FGMatrix operator/(FGMatrix& A, double scalar)
+{
+ FGMatrix Quot(A.Rows(),A.Cols());
+ A.keep = true;
+ for (int i=1;i<=A.Rows();i++) {
+ for (int j=1;j<=A.Cols();j++) {
+ Quot(i,j)=A(i,j)/scalar;
+ }
+ }
+ return Quot;
+}
+
+
+void operator/=(FGMatrix &A,double scalar)
+{
+ for (int i=1;i<=A.Rows();i++) {
+ for (int j=1;j<=A.Cols();j++) {
+ A(i,j)/=scalar;
+ }
+ }
+}
+
+
+void FGMatrix::T(void)
+{
+ if (rows==cols)
+ TransposeSquare();
+ else
+ TransposeNonSquare();
+}
+
+
+void FGMatrix::TransposeSquare(void)
+{
+ for (int i=1;i<=rows;i++) {
+ for (int j=i+1;j<=cols;j++) {
+ double tmp=data[i][j];
+ data[i][j]=data[j][i];
+ data[j][i]=tmp;
+ }
+ }
+}
+
+
+void FGMatrix::TransposeNonSquare(void)
+{
+ double **tran;
+
+ tran=alloc(rows,cols);
+ for (int i=1;i<=rows;i++) {
+ for (int j=1;j<=cols;j++) {
+ tran[j][i]=data[i][j];
+ }
+ }
+ dealloc(data,rows,cols);
+
+ data=tran;
+ unsigned m=rows;
+ rows=cols;
+ cols=m;
+}
+
+
+FGColumnVector::FGColumnVector(void):FGMatrix(3,1) { }
+FGColumnVector::FGColumnVector(int m):FGMatrix(m,1) { }
+FGColumnVector::FGColumnVector(FGColumnVector& b):FGMatrix(b) { }
+FGColumnVector::~FGColumnVector() { }
+double& FGColumnVector::operator()(int m)
+{
+ return FGMatrix::operator()(m,1);
+}
+
--- /dev/null
+/*******************************************************************************
+
+Header: FGMatrix.h
+Author: Tony Peden [formatted here by Jon Berndt]
+Date started: Unknown
+
+HISTORY
+--------------------------------------------------------------------------------
+??/??/?? TP Created
+
+/*******************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGMATRIX_H
+#define FGMATRIX_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+
+/*******************************************************************************
+CONSTANTS
+*******************************************************************************/
+
+
+/*******************************************************************************
+TYPEDEFS
+*******************************************************************************/
+
+
+/*******************************************************************************
+GLOBALS
+*******************************************************************************/
+
+class FGMatrix
+{
+private:
+ double **data;
+ unsigned rows,cols;
+ bool keep;
+ char delim;
+ int width,prec,origin;
+ void TransposeSquare(void);
+ void TransposeNonSquare(void);
+
+public:
+ FGMatrix(unsigned rows, unsigned cols);
+ FGMatrix(const FGMatrix& A);
+ ~FGMatrix(void);
+
+ FGMatrix& FGMatrix::operator=(const FGMatrix& A);
+ double& FGMatrix::operator()(unsigned row, unsigned col);
+
+ unsigned FGMatrix::Rows(void) const;
+ unsigned FGMatrix::Cols(void) const;
+
+ void FGMatrix::T(void);
+ void InitMatrix(void);
+ void InitMatrix(double value);
+
+ friend FGMatrix operator-(FGMatrix& A, FGMatrix& B);
+ friend FGMatrix operator+(FGMatrix& A, FGMatrix& B);
+ friend FGMatrix operator*(double scalar,FGMatrix& A);
+ friend FGMatrix operator*(FGMatrix& Left, FGMatrix& Right);
+ friend FGMatrix operator/(FGMatrix& A, double scalar);
+
+ friend void operator-=(FGMatrix &A,FGMatrix &B);
+ friend void operator+=(FGMatrix &A,FGMatrix &B);
+ friend void operator*=(FGMatrix &A,FGMatrix &B);
+ friend void operator*=(FGMatrix &A,double scalar);
+ friend void operator/=(FGMatrix &A,double scalar);
+
+ void SetOParams(char delim,int width,int prec, int origin=0);
+};
+
+class FGColumnVector : public FGMatrix
+{
+public:
+ FGColumnVector(void);
+ FGColumnVector(int m);
+ FGColumnVector(FGColumnVector& b);
+ ~FGColumnVector();
+
+ double& operator()(int m);
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGModel.cpp
+ Author: Jon Berndt
+ Date started: 11/11/98
+ Purpose: Base class for all models
+ Called by: FGSimExec, et. al.
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This base class for the FGAero, FGRotational, etc. classes defines methods
+common to all models.
+
+HISTORY
+--------------------------------------------------------------------------------
+11/11/98 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGModel.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGAtmosphere.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+FGModel::FGModel(FGFDMExec* fdmex)
+{
+ FDMExec = fdmex;
+ NextModel = 0L;
+
+ State = 0;
+ Atmosphere = 0;
+ FCS = 0;
+ Aircraft = 0;
+ Translation = 0;
+ Rotation = 0;
+ Position = 0;
+ Auxiliary = 0;
+ Output = 0;
+
+ exe_ctr = 1;
+}
+
+
+FGModel::~FGModel()
+{
+}
+
+
+bool FGModel::InitModel(void)
+{
+ State = FDMExec->GetState();
+ Atmosphere = FDMExec->GetAtmosphere();
+ FCS = FDMExec->GetFCS();
+ Aircraft = FDMExec->GetAircraft();
+ Translation = FDMExec->GetTranslation();
+ Rotation = FDMExec->GetRotation();
+ Position = FDMExec->GetPosition();
+ Auxiliary = FDMExec->GetAuxiliary();
+ Output = FDMExec->GetOutput();
+
+ if (!State ||
+ !Atmosphere ||
+ !FCS ||
+ !Aircraft ||
+ !Translation ||
+ !Rotation ||
+ !Position ||
+ !Auxiliary ||
+ !Output) return(false);
+ else return(true);
+}
+
+
+bool FGModel::Run()
+{
+ if (exe_ctr == 1) {
+ if (exe_ctr++ >= rate) exe_ctr = 1;
+ return false;
+ } else {
+ if (exe_ctr++ >= rate) exe_ctr = 1;
+ return true;
+ }
+}
+
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGModel.h
+ Author: Jon Berndt
+ Date started: 11/21/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+11/22/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGMODEL_H
+#define FGMODEL_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGDefs.h"
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# include STL_STRING
+# ifdef FG_HAVE_STD_INCLUDES
+# include <iostream>
+# else
+# include <iostream.h>
+# endif
+ FG_USING_STD(string);
+#else
+# include <string>
+# include <iostream>
+#endif
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGFDMExec;
+class FGState;
+class FGAtmosphere;
+class FGFCS;
+class FGAircraft;
+class FGTranslation;
+class FGRotation;
+class FGPosition;
+class FGAuxiliary;
+class FGOutput;
+
+class FGModel
+{
+public:
+ FGModel(FGFDMExec*);
+ ~FGModel(void);
+
+ FGModel* NextModel;
+ string Name;
+ virtual bool Run(void);
+ virtual bool InitModel(void);
+ void SetRate(int tt) {rate = tt;};
+
+protected:
+ int exe_ctr;
+ int rate;
+
+ FGFDMExec* FDMExec;
+ FGState* State;
+ FGAtmosphere* Atmosphere;
+ FGFCS* FCS;
+ FGAircraft* Aircraft;
+ FGTranslation* Translation;
+ FGRotation* Rotation;
+ FGPosition* Position;
+ FGAuxiliary* Auxiliary;
+ FGOutput* Output;
+
+private:
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGOutput.cpp
+ Author: Jon Berndt
+ Date started: 12/02/98
+ Purpose: Manage output of sim parameters to file or stdout
+ Called by: FGSimExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This is the place where you create output routines to dump data for perusal
+later. Some machines may not support the ncurses console output. Borland is one
+of those environments which does not, so the ncurses stuff is commented out.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/02/98 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <iostream>
+# else
+# include <iostream.h>
+# endif
+#else
+# include <iostream>
+#endif
+
+#ifdef HAVE_CURSES
+ #include <ncurses.h>
+#endif
+
+#include "FGOutput.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGAtmosphere.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ Name = "FGOutput";
+ FirstPass = true;
+#ifdef HAVE_CURSES
+ initscr();
+ cbreak();
+ noecho();
+#endif
+}
+
+
+FGOutput::~FGOutput(void)
+{
+}
+
+
+bool FGOutput::Run(void)
+{
+ if (!FGModel::Run()) {
+ DelimitedOutput();
+// ConsoleOutput();
+ } else {
+ }
+ return false;
+}
+
+
+void FGOutput::ConsoleOutput(void)
+{
+#ifdef HAVE_CURSES
+ string buffer;
+
+ clear();
+ move(1,1); insstr("Quaternions");
+ move(2,5); insstr("Q0");
+ move(2,16); insstr("Q1");
+ move(2,27); insstr("Q2");
+ move(2,38); insstr("Q3");
+
+ move(3,1); buffer = Rotation->GetQ0(); insstr(buffer.c_str());
+ move(3,12); buffer = Rotation->GetQ1(); insstr(buffer.c_str());
+ move(3,23); buffer = Rotation->GetQ2(); insstr(buffer.c_str());
+ move(3,34); buffer = Rotation->GetQ3(); insstr(buffer.c_str());
+
+ move(0,0); insstr("Time: ");
+ move(0,6); insstr(gcvt(State->Getsim_time(),6,buffer));
+
+ move(2,46); insstr("Phi");
+ move(2,55); insstr("Tht");
+ move(2,64); insstr("Psi");
+
+ move(3,45); buffer = Rotation->Getphi(); insstr(buffer.c_str());
+ move(3,54); buffer = Rotation->Gettht(); insstr(buffer.c_str());
+ move(3,63); buffer = Rotation->Getpsi(); insstr(buffer.c_str());
+
+ move(5,47); insstr("U");
+ move(5,56); insstr("V");
+ move(5,65); insstr("W");
+
+ move(6,45); buffer = Translation->GetU(); insstr(buffer.c_str());
+ move(6,54); buffer = Translation->GetV(); insstr(buffer.c_str());
+ move(6,63); buffer = Translation->GetW(); insstr(buffer.c_str());
+
+ move(8,47); insstr("Fx");
+ move(8,56); insstr("Fy");
+ move(8,65); insstr("Fz");
+
+ move(9,45); buffer = Aircraft->GetFx(); insstr(buffer.c_str());
+ move(9,54); buffer = Aircraft->GetFy(); insstr(buffer.c_str());
+ move(9,63); buffer = Aircraft->GetFz(); insstr(buffer.c_str());
+
+ move(11,47); insstr("Fn");
+ move(11,56); insstr("Fe");
+ move(11,65); insstr("Fd");
+
+ move(12,45); buffer = Position->GetFn(); insstr(buffer.c_str());
+ move(12,54); buffer = Position->GetFe(); insstr(buffer.c_str());
+ move(12,63); buffer = Position->GetFd(); insstr(buffer.c_str());
+
+ move(14,47); insstr("Latitude");
+ move(14,57); insstr("Longitude");
+ move(14,67); insstr("Altitude");
+
+ move(15,47); buffer = State->Getlatitude(); insstr(buffer.c_str());
+ move(15,57); buffer = State->Getlongitude(); insstr(buffer.c_str());
+ move(15,67); buffer = State->Geth(); insstr(buffer.c_str());
+
+ refresh();
+
+ move(LINES-1,1);
+ refresh();
+#endif
+}
+
+
+void FGOutput::DelimitedOutput(void)
+{
+ if (FirstPass) {
+ cout << "Time,";
+ cout << "Altitude,";
+ cout << "Phi,";
+ cout << "Tht,";
+ cout << "Psi,";
+ cout << "Rho,";
+ cout << "Vtotal,";
+ cout << "U,";
+ cout << "V,";
+ cout << "W,";
+ cout << "Vn,";
+ cout << "Ve,";
+ cout << "Vd,";
+ cout << "Udot,";
+ cout << "Vdot,";
+ cout << "Wdot,";
+ cout << "Fx,";
+ cout << "Fy,";
+ cout << "Fz,";
+ cout << "Latitude,";
+ cout << "Longitude,";
+ cout << "QBar,";
+ cout << "Alpha";
+ cout << "L";
+ cout << "M";
+ cout << "N";
+ cout << endl;
+ FirstPass = false;
+ } else {
+ cout << State->Getsim_time() << ",";
+ cout << State->Geth() << ",";
+ cout << Rotation->Getphi() << ",";
+ cout << Rotation->Gettht() << ",";
+ cout << Rotation->Getpsi() << ",";
+ cout << Atmosphere->Getrho() << ",";
+ cout << State->GetVt() << ",";
+ cout << Translation->GetU() << ",";
+ cout << Translation->GetV() << ",";
+ cout << Translation->GetW() << ",";
+ cout << Position->GetVn() << ",";
+ cout << Position->GetVe() << ",";
+ cout << Position->GetVd() << ",";
+ cout << Translation->GetUdot() << ",";
+ cout << Translation->GetVdot() << ",";
+ cout << Translation->GetWdot() << ",";
+ cout << Aircraft->GetFx() << ",";
+ cout << Aircraft->GetFy() << ",";
+ cout << Aircraft->GetFz() << ",";
+ cout << State->Getlatitude() << ",";
+ cout << State->Getlongitude() << ",";
+ cout << State->Getqbar() << ",";
+ cout << Translation->Getalpha() << ",";
+ cout << Aircraft->GetL() << ",";
+ cout << Aircraft->GetM() << ",";
+ cout << Aircraft->GetN() << "";
+ cout << endl;
+ }
+}
--- /dev/null
+/*******************************************************************************
+
+ Header: FGOutput.h
+ Author: Jon Berndt
+ Date started: 12/2/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/02/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGOUTPUT_H
+#define FGOUTPUT_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGModel.h"
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGOutput : public FGModel
+{
+public:
+ FGOutput(FGFDMExec*);
+ ~FGOutput(void);
+
+ bool Run(void);
+
+ void ConsoleOutput(void);
+ void DelimitedOutput(void);
+
+protected:
+
+private:
+ bool FirstPass;
+};
+
+/******************************************************************************/
+#endif
+
--- /dev/null
+/*******************************************************************************
+
+ Module: FGPosition.cpp
+ Author: Jon S. Berndt
+ Date started: 01/05/99
+ Purpose: Integrate the EOM to determine instantaneous position
+ Called by: FGFDMExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class encapsulates the integration of rates and accelerations to get the
+current position of the aircraft.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/05/99 JSB Created
+
+********************************************************************************
+COMMENTS, REFERENCES, and NOTES
+********************************************************************************
+[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
+ Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
+ School, January 1994
+[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
+ JSC 12960, July 1977
+[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
+ NASA-Ames", NASA CR-2497, January 1975
+[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
+ Wiley & Sons, 1979 ISBN 0-471-03032-5
+[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
+ 1982 ISBN 0-471-08936-2
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+# else
+# include <math.h>
+# endif
+#else
+# include <cmath>
+#endif
+
+#include "FGPosition.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+
+FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ Name = "FGPosition";
+ AccelN = AccelE = AccelD = 0.0;
+ LongitudeDot = LatitudeDot = RadiusDot = 0.0;
+}
+
+
+FGPosition::~FGPosition(void)
+{
+}
+
+
+bool FGPosition:: Run(void)
+{
+ float tanLat, cosLat;
+
+ if (!FGModel::Run()) {
+ GetState();
+ T[1][1] = Q0*Q0 + Q1*Q1 - Q2*Q2 - Q3*Q3; // Page A-11
+ T[1][2] = 2*(Q1*Q2 + Q0*Q3); // From
+ T[1][3] = 2*(Q1*Q3 - Q0*Q2); // Reference [2]
+ T[2][1] = 2*(Q1*Q2 - Q0*Q3);
+ T[2][2] = Q0*Q0 - Q1*Q1 + Q2*Q2 - Q3*Q3;
+ T[2][3] = 2*(Q2*Q3 + Q0*Q1);
+ T[3][1] = 2*(Q1*Q3 + Q0*Q2);
+ T[3][2] = 2*(Q2*Q3 - Q0*Q1);
+ T[3][3] = Q0*Q0 - Q1*Q1 - Q2*Q2 + Q3*Q3;
+
+ Fn = T[1][1]*Fx + T[2][1]*Fy + T[3][1]*Fz; // Eqn. 3.5
+ Fe = T[1][2]*Fx + T[2][2]*Fy + T[3][2]*Fz; // From
+ Fd = T[1][3]*Fx + T[2][3]*Fy + T[3][3]*Fz; // Reference [3]
+
+ tanLat = tan(Latitude); // I made this up
+ cosLat = cos(Latitude);
+
+ lastAccelN = AccelN;
+ lastAccelE = AccelE;
+ lastAccelD = AccelD;
+
+ Vn = T[1][1]*U + T[2][1]*V + T[3][1]*W;
+ Ve = T[1][2]*U + T[2][2]*V + T[3][2]*W;
+ Vd = T[1][3]*U + T[2][3]*V + T[3][3]*W;
+
+ AccelN = invMass * Fn + invRadius * (Vn*Vd - Ve*Ve*tanLat); // Eqn. 3.6
+ AccelE = invMass * Fe + invRadius * (Ve*Vd + Vn*Ve*tanLat); // From
+ AccelD = invMass * Fd - invRadius * (Vn*Vn + Ve*Ve); // Reference [3]
+
+ Vn += 0.5*dt*rate*(3.0*AccelN - lastAccelN); // Eqn. 3.7
+ Ve += 0.5*dt*rate*(3.0*AccelE - lastAccelE); // From
+ Vd += 0.5*dt*rate*(3.0*AccelD - lastAccelD); // Reference [3]
+
+ Vee = Ve - OMEGAEARTH * (Radius) * cosLat; // From Eq. 3.8
+ // Reference [3]
+ lastLatitudeDot = LatitudeDot;
+ lastLongitudeDot = LongitudeDot;
+ lastRadiusDot = RadiusDot;
+
+ if (cosLat != 0) LongitudeDot = Ve / (Radius * cosLat);
+ LatitudeDot = Vn * invRadius;
+ RadiusDot = -Vd;
+
+ Longitude += 0.5*dt*rate*(LongitudeDot + lastLongitudeDot);
+ Latitude += 0.5*dt*rate*(LatitudeDot + lastLatitudeDot);
+ Radius += 0.5*dt*rate*(RadiusDot + lastRadiusDot);
+
+ PutState();
+ return false;
+ } else {
+ return true;
+ }
+}
+
+
+void FGPosition::GetState(void)
+{
+ dt = State->Getdt();
+
+ Q0 = Rotation->GetQ0();
+ Q1 = Rotation->GetQ1();
+ Q2 = Rotation->GetQ2();
+ Q3 = Rotation->GetQ3();
+
+ Fx = Aircraft->GetFx();
+ Fy = Aircraft->GetFy();
+ Fz = Aircraft->GetFz();
+
+ U = Translation->GetU();
+ V = Translation->GetV();
+ W = Translation->GetW();
+
+ Latitude = State->Getlatitude();
+ Longitude = State->Getlongitude();
+
+ invMass = 1.0 / Aircraft->GetMass();
+ invRadius = 1.0 / (State->Geth() + EARTHRAD);
+ Radius = State->Geth() + EARTHRAD;
+}
+
+
+void FGPosition::PutState(void)
+{
+ State->Setlatitude(Latitude);
+ State->Setlongitude(Longitude);
+ State->Seth(Radius - EARTHRAD);
+}
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGPosition.h
+ Author: Jon S. Berndt
+ Date started: 1/5/99
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/05/99 JSB Created
+
+********************************************************************************
+COMMENTS, REFERENCES, and NOTES
+********************************************************************************
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGPOSITION_H
+#define FGPOSITION_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+#include "FGModel.h"
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGPosition : public FGModel
+{
+public:
+ FGPosition(FGFDMExec*);
+ ~FGPosition(void);
+
+ inline float GetFn(void) {return Fn;}
+ inline float GetFe(void) {return Fe;}
+ inline float GetFd(void) {return Fd;}
+
+ inline float GetVn(void) {return Vn;}
+ inline float GetVe(void) {return Ve;}
+ inline float GetVd(void) {return Vd;}
+
+ inline float GetT(int r, int c) {return T[r][c];}
+ inline void SetT(float t1, float t2, float t3, float t4, float t5, float t6,
+ float t7, float t8, float t9)
+ {T[1][1]=t1; T[1][2]=t2 ;T[1][3]=t3;
+ T[2][1]=t4; T[2][2]=t5 ;T[2][3]=t6;
+ T[3][1]=t7; T[3][2]=t8 ;T[3][3]=t9;}
+
+ bool Run(void);
+
+protected:
+
+private:
+ float T[4][4];
+ float Q0, Q1, Q2, Q3;
+ float Fn, Fe, Fd;
+ float Fx, Fy, Fz;
+ float U, V, W;
+ float Vn, Ve, Vd, Vee;
+ float invMass, invRadius;
+ float Radius;
+ float AccelN, AccelE, AccelD;
+ float lastAccelN, lastAccelE, lastAccelD;
+ float LatitudeDot, LongitudeDot, RadiusDot;
+ float lastLatitudeDot, lastLongitudeDot, lastRadiusDot;
+ float Longitude, Latitude;
+ float dt;
+
+ void GetState(void);
+ void PutState(void);
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGRotation.cpp
+ Author: Jon Berndt
+ Date started: 12/02/98
+ Purpose: Integrates the rotational EOM
+ Called by: FGFDMExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class integrates the rotational EOM.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/02/98 JSB Created
+
+********************************************************************************
+COMMENTS, REFERENCES, and NOTES
+********************************************************************************
+[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
+ Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
+ School, January 1994
+[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
+ JSC 12960, July 1977
+[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
+ NASA-Ames", NASA CR-2497, January 1975
+[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
+ Wiley & Sons, 1979 ISBN 0-471-03032-5
+[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
+ 1982 ISBN 0-471-08936-2
+
+ The order of rotations used in this class corresponds to a 3-2-1 sequence,
+ or Y-P-R, or Z-Y-X, if you prefer.
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGRotation.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+
+FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ Name = "FGRotation";
+ Q0dot = Q1dot = Q2dot = Q3dot = 0.0;
+ Pdot = Qdot = Rdot = 0.0;
+}
+
+
+FGRotation::~FGRotation(void)
+{
+}
+
+
+bool FGRotation::Run(void)
+{
+ float L2, N1, iQtot, sum;
+
+ if (!FGModel::Run()) {
+ GetState();
+
+ lastPdot = Pdot;
+ lastQdot = Qdot;
+ lastRdot = Rdot;
+
+ L2 = L + Ixz*P*Q - (Izz-Iyy)*R*Q;
+ N1 = N - (Iyy-Ixx)*P*Q - Ixz*R*Q;
+
+ Pdot = (L2*Izz - N1*Ixz) / (Ixx*Izz - Ixz*Ixz);
+ Qdot = (M - (Ixx-Izz)*P*R - Ixz*(P*P - R*R))/Iyy;
+ Rdot = (N1*Ixx + L2*Ixz) / (Ixx*Izz - Ixz*Ixz);
+
+ P += dt*rate*(lastPdot + Pdot)/2.0;
+ Q += dt*rate*(lastQdot + Qdot)/2.0;
+ R += dt*rate*(lastRdot + Rdot)/2.0;
+
+ lastQ0dot = Q0dot;
+ lastQ1dot = Q1dot;
+ lastQ2dot = Q2dot;
+ lastQ3dot = Q3dot;
+
+ Q0dot = -0.5*(Q1*P + Q2*Q + Q3*R);
+ Q1dot = 0.5*(Q0*P + Q2*R - Q3*Q);
+ Q2dot = 0.5*(Q0*Q + Q3*P - Q1*R);
+ Q3dot = 0.5*(Q0*R + Q1*Q - Q2*P);
+
+ Q0 += 0.5*dt*rate*(lastQ0dot + Q0dot);
+ Q1 += 0.5*dt*rate*(lastQ1dot + Q1dot);
+ Q2 += 0.5*dt*rate*(lastQ2dot + Q2dot);
+ Q3 += 0.5*dt*rate*(lastQ3dot + Q3dot);
+
+ sum = Q0*Q0 + Q1*Q1 + Q2*Q2 + Q3*Q3;
+
+ iQtot = 1.0 / sqrt(sum);
+
+ Q0 *= iQtot;
+ Q1 *= iQtot;
+ Q2 *= iQtot;
+ Q3 *= iQtot;
+
+ if (T[3][3] == 0)
+ phi = 0.0;
+ else
+ phi = atan2(T[2][3], T[3][3]);
+
+ tht = asin(-T[1][3]);
+
+ if (T[1][1] == 0.0)
+ psi = 0.0;
+ else
+ psi = atan2(T[1][2], T[1][1]);
+
+ if (psi < 0.0) psi += 2*M_PI;
+
+ PutState();
+ } else {
+ }
+ return false;
+}
+
+
+void FGRotation::GetState(void)
+{
+ dt = State->Getdt();
+
+ L = Aircraft->GetL();
+ M = Aircraft->GetM();
+ N = Aircraft->GetN();
+
+ Ixx = Aircraft->GetIxx();
+ Iyy = Aircraft->GetIyy();
+ Izz = Aircraft->GetIzz();
+ Ixz = Aircraft->GetIxz();
+
+ for (int r=1;r<=3;r++)
+ for (int c=1;c<=3;c++)
+ T[r][c] = Position->GetT(r,c);
+}
+
+
+void FGRotation::PutState(void)
+{
+}
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGRotation.h
+ Author: Jon Berndt
+ Date started: 12/02/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/02/98 JSB Created
+
+********************************************************************************
+COMMENTS, REFERENCES, and NOTES
+********************************************************************************
+[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
+ Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
+ School, January 1994
+[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
+ JSC 12960, July 1977
+[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
+ NASA-Ames", NASA CR-2497, January 1975
+[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
+ Wiley & Sons, 1979 ISBN 0-471-03032-5
+[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
+ 1982 ISBN 0-471-08936-2
+
+ The order of rotations used in this class corresponds to a 3-2-1 sequence,
+ or Y-P-R, or Z-Y-X, if you prefer.
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGROTATION_H
+#define FGROTATION_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+# else
+# include <math.h>
+# endif
+#else
+# include <cmath>
+#endif
+
+#include "FGModel.h"
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGRotation : public FGModel
+{
+public:
+ FGRotation(FGFDMExec*);
+ ~FGRotation(void);
+
+ bool Run(void);
+
+ inline float GetP(void) {return P;}
+ inline float GetQ(void) {return Q;}
+ inline float GetR(void) {return R;}
+
+ inline float GetPdot(void) {return Pdot;}
+ inline float GetQdot(void) {return Qdot;}
+ inline float GetRdot(void) {return Rdot;}
+
+ inline float Getphi(void) {return phi;}
+ inline float Gettht(void) {return tht;}
+ inline float Getpsi(void) {return psi;}
+
+ inline float GetQ0(void) {return Q0;}
+ inline float GetQ1(void) {return Q1;}
+ inline float GetQ2(void) {return Q2;}
+ inline float GetQ3(void) {return Q3;}
+
+ inline void SetP(float tt) {P = tt;}
+ inline void SetQ(float tt) {Q = tt;}
+ inline void SetR(float tt) {R = tt;}
+
+ inline void SetPQR(float t1, float t2, float t3) {P=t1;
+ Q=t2;
+ R=t3;}
+
+ inline void Setphi(float tt) {phi = tt;}
+ inline void Settht(float tt) {tht = tt;}
+ inline void Setpsi(float tt) {psi = tt;}
+
+ inline void SetEuler(float t1, float t2, float t3) {phi=t1;
+ tht=t2;
+ psi=t3;}
+
+ inline void SetQ0123(float t1, float t2, float t3, float t4) {Q0=t1;
+ Q1=t2;
+ Q2=t3;
+ Q3=t4;}
+
+protected:
+
+private:
+ float P, Q, R;
+ float L, M, N;
+ float Ixx, Iyy, Izz, Ixz;
+ float Q0, Q1, Q2, Q3;
+ float phi, tht, psi;
+ float Pdot, Qdot, Rdot;
+ float Q0dot, Q1dot, Q2dot, Q3dot;
+ float lastPdot, lastQdot, lastRdot;
+ float lastQ0dot, lastQ1dot, lastQ2dot, lastQ3dot;
+ float dt;
+ float T[4][4];
+
+ void GetState(void);
+ void PutState(void);
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGState.cpp
+ Author: Jon Berndt
+ Date started: 11/17/98
+ Called by: FGFDMExec and accessed by all models.
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+See header file.
+
+HISTORY
+--------------------------------------------------------------------------------
+11/17/98 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+# else
+# include <math.h>
+# endif
+#else
+# include <cmath>
+#endif
+
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGAtmosphere.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+
+FGState::FGState(FGFDMExec* fdex)
+{
+ FDMExec = fdex;
+
+ Vt = 0.0;
+ latitude = longitude = 0.0;
+ adot = bdot = 0.0;
+ h = 0.0;
+ a = 1000.0;
+ qbar = 0.0;
+ sim_time = dt = 0.1;
+}
+
+
+FGState::~FGState(void)
+{
+}
+
+
+bool FGState::Reset(string path, string fname)
+{
+ string resetDef;
+ float U, V, W;
+ float phi, tht, psi;
+ float alpha, beta, gamma;
+ float Q0, Q1, Q2, Q3;
+ float T[4][4];
+
+ resetDef = path + "/" + FDMExec->GetAircraft()->GetAircraftName() + "/" + fname;
+
+ ifstream resetfile(resetDef.c_str());
+
+ if (resetfile) {
+ resetfile >> U;
+ resetfile >> V;
+ resetfile >> W;
+ resetfile >> latitude;
+ resetfile >> longitude;
+ resetfile >> phi;
+ resetfile >> tht;
+ resetfile >> psi;
+ resetfile >> h;
+ resetfile.close();
+
+// Change all angular measurements from degrees (as in config file) to radians
+
+ gamma = 0.0;
+ if (W != 0.0)
+ alpha = U*U > 0.0 ? atan2(W, U) : 0.0;
+ else
+ alpha = 0.0;
+ if (V != 0.0)
+ beta = U*U+W*W > 0.0 ? atan2(V, (fabs(U)/U)*sqrt(U*U + W*W)) : 0.0;
+ else
+ beta = 0.0;
+
+ latitude *= M_PI / 180.0;
+ longitude *= M_PI / 180.0;
+ phi *= M_PI / 180.0;
+ tht *= M_PI / 180.0;
+ psi *= M_PI / 180.0;
+
+ FDMExec->GetTranslation()->SetUVW(U, V, W);
+ FDMExec->GetRotation()->SetEuler(phi, tht, psi);
+ FDMExec->GetTranslation()->SetABG(alpha, beta, gamma);
+
+ Vt = sqrt(U*U + V*V + W*W);
+ qbar = sqrt(U*U + V*V + W*W);
+
+ Q0 = sin(psi*0.5)*sin(tht*0.5)*sin(phi*0.5) + cos(psi*0.5)*cos(tht*0.5)*cos(phi*0.5);
+ Q1 = -sin(psi*0.5)*sin(tht*0.5)*cos(phi*0.5) + cos(psi*0.5)*cos(tht*0.5)*sin(phi*0.5);
+ Q2 = sin(psi*0.5)*cos(tht*0.5)*sin(phi*0.5) + cos(psi*0.5)*sin(tht*0.5)*cos(phi*0.5);
+ Q3 = sin(psi*0.5)*cos(tht*0.5)*cos(phi*0.5) - cos(psi*0.5)*sin(tht*0.5)*sin(phi*0.5);
+
+ FDMExec->GetRotation()->SetQ0123(Q0, Q1, Q2, Q3);
+
+ T[1][1] = Q0*Q0 + Q1*Q1 - Q2*Q2 - Q3*Q3;
+ T[1][2] = 2*(Q1*Q2 + Q0*Q3);
+ T[1][3] = 2*(Q1*Q3 - Q0*Q2);
+ T[2][1] = 2*(Q1*Q2 - Q0*Q3);
+ T[2][2] = Q0*Q0 - Q1*Q1 + Q2*Q2 - Q3*Q3;
+ T[2][3] = 2*(Q2*Q3 + Q0*Q1);
+ T[3][1] = 2*(Q1*Q3 + Q0*Q2);
+ T[3][2] = 2*(Q2*Q3 - Q0*Q1);
+ T[3][3] = Q0*Q0 - Q1*Q1 - Q2*Q2 + Q3*Q3;
+
+ FDMExec->GetPosition()->SetT(T[1][1], T[1][2], T[1][3],
+ T[2][1], T[2][2], T[2][3],
+ T[3][1], T[3][2], T[3][3]);
+
+ return true;
+ } else {
+ cerr << "Unable to load reset file " << fname << endl;
+ return false;
+ }
+}
+
+
+bool FGState::StoreData(string fname)
+{
+ ofstream datafile(fname.c_str());
+
+ if (datafile) {
+ datafile << FDMExec->GetTranslation()->GetU();
+ datafile << FDMExec->GetTranslation()->GetV();
+ datafile << FDMExec->GetTranslation()->GetW();
+ datafile << latitude;
+ datafile << longitude;
+ datafile << FDMExec->GetRotation()->Getphi();
+ datafile << FDMExec->GetRotation()->Gettht();
+ datafile << FDMExec->GetRotation()->Getpsi();
+ datafile << h;
+ datafile.close();
+ return true;
+ } else {
+ cerr << "Could not open dump file " << fname << endl;
+ return false;
+ }
+}
+
+
+bool FGState::DumpData(string fname)
+{
+ ofstream datafile(fname.c_str());
+
+ if (datafile) {
+ datafile << "U: " << FDMExec->GetTranslation()->GetU() << endl;
+ datafile << "V: " << FDMExec->GetTranslation()->GetV() << endl;
+ datafile << "W: " << FDMExec->GetTranslation()->GetW() << endl;
+ datafile << "P: " << FDMExec->GetRotation()->GetP() << endl;
+ datafile << "Q: " << FDMExec->GetRotation()->GetQ() << endl;
+ datafile << "R: " << FDMExec->GetRotation()->GetR() << endl;
+ datafile << "L: " << FDMExec->GetAircraft()->GetL() << endl;
+ datafile << "M: " << FDMExec->GetAircraft()->GetM() << endl;
+ datafile << "N: " << FDMExec->GetAircraft()->GetN() << endl;
+ datafile << "latitude: " << latitude << endl;
+ datafile << "longitude: " << longitude << endl;
+ datafile << "alpha: " << FDMExec->GetTranslation()->Getalpha() << endl;
+ datafile << "beta: " << FDMExec->GetTranslation()->Getbeta() << endl;
+ datafile << "gamma: " << FDMExec->GetTranslation()->Getgamma() << endl;
+ datafile << "phi: " << FDMExec->GetRotation()->Getphi() << endl;
+ datafile << "tht: " << FDMExec->GetRotation()->Gettht() << endl;
+ datafile << "psi: " << FDMExec->GetRotation()->Getpsi() << endl;
+ datafile << "Pdot: " << FDMExec->GetRotation()->GetPdot() << endl;
+ datafile << "Qdot: " << FDMExec->GetRotation()->GetQdot() << endl;
+ datafile << "Rdot: " << FDMExec->GetRotation()->GetRdot() << endl;
+ datafile << "h: " << h << endl;
+ datafile << "a: " << a << endl;
+ datafile << "rho: " << FDMExec->GetAtmosphere()->Getrho() << endl;
+ datafile << "qbar: " << qbar << endl;
+ datafile << "sim_time: " << sim_time << endl;
+ datafile << "dt: " << dt << endl;
+ datafile << "m: " << FDMExec->GetAircraft()->GetMass() << endl;
+ datafile.close();
+ return true;
+ } else {
+ return false;
+ }
+}
+
+
+bool FGState::DisplayData(void)
+{
+ cout << "U: " << FDMExec->GetTranslation()->GetU() << endl;
+ cout << "V: " << FDMExec->GetTranslation()->GetV() << endl;
+ cout << "W: " << FDMExec->GetTranslation()->GetW() << endl;
+ cout << "P: " << FDMExec->GetRotation()->GetP() << endl;
+ cout << "Q: " << FDMExec->GetRotation()->GetQ() << endl;
+ cout << "R: " << FDMExec->GetRotation()->GetR() << endl;
+ cout << "L: " << FDMExec->GetAircraft()->GetL() << endl;
+ cout << "M: " << FDMExec->GetAircraft()->GetM() << endl;
+ cout << "N: " << FDMExec->GetAircraft()->GetN() << endl;
+ cout << "Vt: " << Vt << endl;
+ cout << "latitude: " << latitude << endl;
+ cout << "longitude: " << longitude << endl;
+ cout << "alpha: " << FDMExec->GetTranslation()->Getalpha() << endl;
+ cout << "beta: " << FDMExec->GetTranslation()->Getbeta() << endl;
+ cout << "gamma: " << FDMExec->GetTranslation()->Getgamma() << endl;
+ cout << "phi: " << FDMExec->GetRotation()->Getphi() << endl;
+ cout << "tht: " << FDMExec->GetRotation()->Gettht() << endl;
+ cout << "psi: " << FDMExec->GetRotation()->Getpsi() << endl;
+ cout << "Pdot: " << FDMExec->GetRotation()->GetPdot() << endl;
+ cout << "Qdot: " << FDMExec->GetRotation()->GetQdot() << endl;
+ cout << "Rdot: " << FDMExec->GetRotation()->GetRdot() << endl;
+ cout << "h: " << h << endl;
+ cout << "a: " << a << endl;
+ cout << "rho: " << FDMExec->GetAtmosphere()->Getrho() << endl;
+ cout << "qbar: " << qbar << endl;
+ cout << "sim_time: " << sim_time << endl;
+ cout << "dt: " << dt << endl;
+ cout << "m: " << FDMExec->GetAircraft()->GetMass() << endl;
+
+ return true;
+}
--- /dev/null
+/*******************************************************************************
+
+ Header: FGState.h
+ Author: Jon S. Berndt
+ Date started: 11/17/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+Based on Flightgear code, which is based on LaRCSim. This class wraps all
+global state variables (such as velocity, position, orientation, etc.).
+
+HISTORY
+--------------------------------------------------------------------------------
+11/17/98 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGSTATE_H
+#define FGSTATE_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# include STL_STRING
+# ifdef FG_HAVE_STD_INCLUDES
+# include <fstream>
+# else
+# include <fstream.h>
+# endif
+ FG_USING_STD(string);
+#else
+# include <string>
+# include <fstream>
+#endif
+
+#include "FGDefs.h"
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGFDMExec;
+class FGState
+{
+public:
+ FGState(FGFDMExec*);
+ ~FGState(void);
+
+ bool Reset(string, string);
+ bool StoreData(string);
+ bool DumpData(string);
+ bool DisplayData(void);
+
+ inline float GetVt(void) {return Vt;}
+
+ inline float Getlatitude(void) {return latitude;}
+ inline float Getlongitude(void) {return longitude;}
+ inline float GetGeodeticLat(void) {return GeodeticLat;}
+
+ inline float Getadot(void) {return adot;}
+ inline float Getbdot(void) {return bdot;}
+
+ inline float Geth(void) {return h;}
+ inline float Geta(void) {return a;}
+ inline float GetMach(void) {return Mach;}
+
+ inline float Getsim_time(void) {return sim_time;}
+ inline float Getdt(void) {return dt;}
+
+ inline float Getqbar(void) {return qbar;}
+
+ inline void SetVt(float tt) {Vt = tt;}
+
+ inline void Setlatitude(float tt) {latitude = tt;}
+ inline void Setlongitude(float tt) {longitude = tt;}
+ inline void SetGeodeticLat(float tt) {GeodeticLat = tt;}
+
+ inline void Setadot(float tt) {adot = tt;}
+ inline void Setbdot(float tt) {bdot = tt;}
+
+ inline void Setqbar(float tt) {qbar = tt;}
+
+ inline void Seth(float tt) {h = tt;}
+ inline void Seta(float tt) {a = tt;}
+ inline void SetMach(float tt) {Mach = tt;}
+
+ inline float Setsim_time(float tt) {sim_time = tt; return sim_time;}
+ inline void Setdt(float tt) {dt = tt;}
+
+ inline float IncrTime(void) {sim_time+=dt;return sim_time;}
+
+private:
+
+ float Vt; // Total velocity
+ float latitude, longitude; // position
+ float GeodeticLat; // Geodetic Latitude
+ float adot, bdot; // alpha dot and beta dot
+ float h, a; // altitude above sea level, speed of sound
+ float qbar; // dynamic pressure
+ float sim_time, dt;
+ float Mach; // Mach number
+
+ FGFDMExec* FDMExec;
+
+protected:
+
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGTank.cpp
+ Author: Jon Berndt
+ Date started: 01/21/99
+ Called by: FGAircraft
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+See header file.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/21/99 JSB Created
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+#include "FGTank.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+
+FGTank::FGTank(ifstream& acfile)
+{
+ string type;
+
+ acfile >> type; // Type = 0: fuel, 1: oxidizer
+ if (type == "FUEL") Type = ttFUEL;
+ else if (type == "OXIDIZER") Type = ttOXIDIZER;
+ else Type = ttUNKNOWN;
+ acfile >> X; // inches
+ acfile >> Y; // "
+ acfile >> Z; // "
+ acfile >> Radius; // "
+ acfile >> Capacity; // pounds (amount it can hold)
+ acfile >> Contents; // pounds (amount it is holding)
+ Selected = true;
+ PctFull = 100.0*Contents/Capacity; // percent full; 0 to 100.0
+}
+
+
+FGTank::~FGTank(void)
+{
+}
+
+
+float FGTank::Reduce(float used)
+{
+ float shortage;
+
+ if (used < Contents) {
+ Contents -= used;
+ PctFull = 100.0*Contents/Capacity;
+ return Contents;
+ } else {
+ shortage = Contents - used;
+ Contents = 0.0;
+ PctFull = 0.0;
+ Selected = false;
+ return shortage;
+ }
+}
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGTank.h
+ Author: Jon S. Berndt
+ Date started: 01/21/99
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+Based on Flightgear code, which is based on LaRCSim. This class simulates
+a generic Tank.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/21/99 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGTank_H
+#define FGTank_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+#ifdef FGFS
+# include <Include/compiler.h>
+# include STL_STRING
+# ifdef FG_HAVE_STD_INCLUDES
+# include <fstream>
+# else
+# include <fstream.h>
+# endif
+ FG_USING_STD(string);
+#else
+# include <string>
+# include <fstream>
+#endif
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGTank
+{
+public:
+ FGTank(ifstream&);
+ ~FGTank(void);
+
+ float Reduce(float);
+ int GetType(void) {return Type;}
+ bool GetSelected(void) {return Selected;}
+ float GetPctFull(void) {return PctFull;}
+ float GetContents(void) {return Contents;}
+
+ enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
+
+private:
+ TankType Type;
+ float X, Y, Z;
+ float Capacity;
+ float Radius;
+ float PctFull;
+ float Contents;
+ bool Selected;
+
+protected:
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGTranslation.cpp
+ Author: Jon Berndt
+ Date started: 12/02/98
+ Purpose: Integrates the translational EOM
+ Called by: FDMExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class integrates the translational EOM.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/02/98 JSB Created
+
+********************************************************************************
+COMMENTS, REFERENCES, and NOTES
+********************************************************************************
+[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
+ Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
+ School, January 1994
+[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
+ JSC 12960, July 1977
+[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
+ NASA-Ames", NASA CR-2497, January 1975
+[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
+ Wiley & Sons, 1979 ISBN 0-471-03032-5
+[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
+ 1982 ISBN 0-471-08936-2
+
+ The order of rotations used in this class corresponds to a 3-2-1 sequence,
+ or Y-P-R, or Z-Y-X, if you prefer.
+
+********************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGFCS.h"
+#include "FGAircraft.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+
+FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ Name = "FGTranslation";
+ Udot = Vdot = Wdot = 0.0;
+}
+
+
+FGTranslation::~FGTranslation(void)
+{
+}
+
+
+bool FGTranslation::Run(void)
+{
+ if (!FGModel::Run()) {
+
+ GetState();
+
+ lastUdot = Udot;
+ lastVdot = Vdot;
+ lastWdot = Wdot;
+
+ Udot = V*R - W*Q + Fx/Mass;
+ Vdot = W*P - U*R + Fy/Mass;
+ Wdot = U*Q - V*P + Fz/Mass;
+
+ U += 0.5*dt*rate*(lastUdot + Udot);
+ V += 0.5*dt*rate*(lastVdot + Vdot);
+ W += 0.5*dt*rate*(lastWdot + Wdot);
+
+ Vt = U*U+V*V+W*W > 0.0 ? sqrt(U*U + V*V + W*W) : 0.0;
+
+ if (W != 0.0)
+ alpha = U*U > 0.0 ? atan2(W, U) : 0.0;
+ if (V != 0.0)
+ beta = U*U+W*W > 0.0 ? atan2(V, (fabs(U)/U)*sqrt(U*U + W*W)) : 0.0;
+
+ qbar = 0.5*rho*Vt*Vt;
+
+ PutState();
+ } else {
+ }
+ return false;
+}
+
+
+void FGTranslation::GetState(void)
+{
+ dt = State->Getdt();
+
+ P = Rotation->GetP();
+ Q = Rotation->GetQ();
+ R = Rotation->GetR();
+
+ Fx = Aircraft->GetFx();
+ Fy = Aircraft->GetFy();
+ Fz = Aircraft->GetFz();
+
+ Mass = Aircraft->GetMass();
+ rho = Atmosphere->Getrho();
+
+ phi = Rotation->Getphi();
+ tht = Rotation->Gettht();
+ psi = Rotation->Getpsi();
+}
+
+
+void FGTranslation::PutState(void)
+{
+ State->SetVt(Vt);
+ State->Setqbar(qbar);
+}
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGTranslation.h
+ Author: Jon Berndt
+ Date started: 12/02/98
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+12/02/98 JSB Created
+
+********************************************************************************
+COMMENTS, REFERENCES, and NOTES
+********************************************************************************
+[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
+ Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
+ School, January 1994
+[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
+ JSC 12960, July 1977
+[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
+ NASA-Ames", NASA CR-2497, January 1975
+[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
+ Wiley & Sons, 1979 ISBN 0-471-03032-5
+[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
+ 1982 ISBN 0-471-08936-2
+
+ The order of rotations used in this class corresponds to a 3-2-1 sequence,
+ or Y-P-R, or Z-Y-X, if you prefer.
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGTRANSLATION_H
+#define FGTRANSLATION_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+# else
+# include <math.h>
+# endif
+#else
+# include <cmath>
+#endif
+
+#include "FGModel.h"
+
+using namespace std;
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGTranslation : public FGModel
+{
+public:
+ FGTranslation(FGFDMExec*);
+ ~FGTranslation(void);
+
+ inline float GetU(void) {return U;}
+ inline float GetV(void) {return V;}
+ inline float GetW(void) {return W;}
+
+ inline float GetUdot(void) {return Udot;}
+ inline float GetVdot(void) {return Vdot;}
+ inline float GetWdot(void) {return Wdot;}
+
+ inline float Getalpha(void) {return alpha;}
+ inline float Getbeta (void) {return beta; }
+ inline float Getgamma(void) {return gamma;}
+
+ inline void SetU(float tt) {U = tt;}
+ inline void SetV(float tt) {V = tt;}
+ inline void SetW(float tt) {W = tt;}
+
+ inline void SetUVW(float t1, float t2, float t3) {U=t1; V=t2; W=t3;}
+
+ inline void Setalpha(float tt) {alpha = tt;}
+ inline void Setbeta (float tt) {beta = tt;}
+ inline void Setgamma(float tt) {gamma = tt;}
+
+ inline void SetABG(float t1, float t2, float t3) {alpha=t1; beta=t2; gamma=t3;}
+
+ bool Run(void);
+
+protected:
+
+private:
+ float U, V, W; // Body frame velocities owned by FGTranslation
+ float P, Q, R;
+ float Vt, qbar;
+ float Udot, Vdot, Wdot;
+ float lastUdot, lastVdot, lastWdot;
+ float phi, tht, psi;
+ float Fx, Fy, Fz;
+ float Mass, dt;
+ float alpha, beta, gamma;
+ float rho;
+
+ void GetState(void);
+ void PutState(void);
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+/*******************************************************************************
+
+ Module: FGUtility.cpp
+ Author: Jon Berndt
+ Date started: 01/09/99
+ Purpose: Contains utility classes for the FG FDM
+ Called by: FGPosition, et. al.
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class is a container for all utility classes used by the flight dynamics
+model.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/09/99 JSB Created
+
+********************************************************************************
+DEFINES
+*******************************************************************************/
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+#ifdef FGFS
+# include <Include/compiler.h>
+# ifdef FG_HAVE_STD_INCLUDES
+# include <cmath>
+# else
+# include <math.h>
+# endif
+#else
+# include <cmath>
+#endif
+
+#include "FGUtility.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+
+/*******************************************************************************
+************************************ CODE **************************************
+*******************************************************************************/
+
+FGUtility::FGUtility()
+{
+ // Move constant stuff to here (if any) so it won't take CPU time
+ // in the methods below.
+ SeaLevelR = EARTHRAD * ECCENT;
+}
+
+
+FGUtility::~FGUtility()
+{
+}
+
+
+float FGUtility::ToGeodetic()
+{
+ float GeodeticLat, Latitude, Radius, Altitude;
+ float tanLat, xAlpha, muAlpha, sinmuAlpha, denom, rhoAlpha, dMu;
+ float lPoint, lambdaSL, sinlambdaSL, dLambda, rAlpha;
+
+ Latitude = State->Getlatitude();
+ Radius = State->Geth() + EARTHRAD;
+
+ if (( M_PI_2 - Latitude < ONESECOND) ||
+ ( M_PI_2 + Latitude < ONESECOND)) { // Near a pole
+ GeodeticLat = Latitude;
+ Altitude = Radius - SeaLevelR;
+ } else {
+ tanLat = tan(Latitude);
+ xAlpha = ECCENT*EARTHRAD /
+ sqrt(tanLat*tanLat + ECCENTSQRD);
+ muAlpha = atan2(sqrt(EARTHRADSQRD - xAlpha*xAlpha), ECCENT*xAlpha);
+
+ if (Latitude < 0.0) muAlpha = -muAlpha;
+
+ sinmuAlpha = sin(muAlpha);
+ dLambda = muAlpha - Latitude;
+ rAlpha = xAlpha / cos(Latitude);
+ lPoint = Radius - rAlpha;
+ Altitude = lPoint*cos(dLambda);
+ denom = sqrt(1-EPS*EPS*sinmuAlpha*sinmuAlpha);
+ rhoAlpha = EARTHRAD*(1.0 - EPS) / (denom*denom*denom);
+ dMu = atan2(lPoint*sin(dLambda),rhoAlpha + Altitude);
+ State->SetGeodeticLat(muAlpha - dMu);
+ lambdaSL = atan(ECCENTSQRD*tan(GeodeticLat));
+ sinlambdaSL = sin(lambdaSL);
+ SeaLevelR = sqrt(EARTHRADSQRD / (1 + INVECCENTSQRDM1* sinlambdaSL*sinlambdaSL));
+ }
+ return 0.0;
+}
+
+
+float FGUtility:: FromGeodetic()
+{
+ float lambdaSL, sinlambdaSL, coslambdaSL, sinMu, cosMu, py, px;
+ float Altitude, SeaLevelR;
+
+ lambdaSL = atan(ECCENTSQRD*tan(State->GetGeodeticLat()));
+ sinlambdaSL = sin(lambdaSL);
+ coslambdaSL = cos(lambdaSL);
+ sinMu = sin(State->GetGeodeticLat());
+ cosMu = cos(State->GetGeodeticLat());
+ SeaLevelR = sqrt(EARTHRADSQRD /
+ (1 + INVECCENTSQRDM1*sinlambdaSL*sinlambdaSL));
+ px = SeaLevelR*coslambdaSL + Altitude*cosMu;
+ py = SeaLevelR*sinlambdaSL + Altitude*sinMu;
+ State->Setlatitude(atan2(py,px));
+ return 0.0;
+}
+
--- /dev/null
+/*******************************************************************************
+
+ Header: FGUtility.h
+ Author: Jon Berndt
+ Date started: 01/09/99
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+01/09/99 JSB Created
+
+********************************************************************************
+SENTRY
+*******************************************************************************/
+
+#ifndef FGUTILITY_H
+#define FGUTILITY_H
+
+/*******************************************************************************
+INCLUDES
+*******************************************************************************/
+
+/*******************************************************************************
+DEFINES
+*******************************************************************************/
+
+// FG_USING_STD(std);
+
+/*******************************************************************************
+CLASS DECLARATION
+*******************************************************************************/
+
+class FGFDMExec;
+class FGState;
+
+class FGUtility
+{
+public:
+ FGUtility(void);
+ ~FGUtility(void);
+
+ float ToGeodetic(void);
+ float FromGeodetic(void);
+
+protected:
+
+private:
+ float SeaLevelR;
+ FGState* State;
+ FGFDMExec* FDMExec;
+};
+
+/******************************************************************************/
+#endif
--- /dev/null
+noinst_LIBRARIES = libJSBsim.a
+
+libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \
+ FGAtmosphere.cpp FGAtmosphere.h \
+ FGAuxiliary.cpp FGAuxiliary.h \
+ FGCoefficient.cpp FGCoefficient.h \
+ FGDefs.h \
+ FGFCS.cpp FGFCS.h \
+ FGFDMExec.cpp FGFDMExec.h \
+ FGModel.cpp FGModel.h \
+ FGOutput.cpp FGOutput.h \
+ FGPosition.cpp FGPosition.h \
+ FGRotation.cpp FGRotation.h \
+ FGState.cpp FGState.h \
+ FGTranslation.cpp FGTranslation.h \
+ FGUtility.cpp FGUtility.h \
+ FGEngine.cpp FGEngine.h \
+ FGTank.cpp FGTank.h
+
+INCLUDES += -I$(top_builddir)
+
+DEFS += -DFGFS
+++ /dev/null
-// JSBsim.cxx -- interface to the JSBsim flight model
-//
-// Written by Curtis Olson, started February 1999.
-//
-// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#include <Include/compiler.h>
-
-#ifdef FG_MATH_EXCEPTION_CLASH
-# include <math.h>
-#endif
-
-#include STL_STRING
-
-#include <Aircraft/aircraft.hxx>
-#include <Controls/controls.hxx>
-#include <Debug/logstream.hxx>
-#include <Include/fg_constants.h>
-#include <Main/options.hxx>
-#include <Math/fg_geodesy.hxx>
-#include <Misc/fgpath.hxx>
-
-#include <FDM/JSBsim/FGFDMExec.h>
-#include <FDM/JSBsim/FGAircraft.h>
-#include <FDM/JSBsim/FGFCS.h>
-#include <FDM/JSBsim/FGPosition.h>
-#include <FDM/JSBsim/FGRotation.h>
-#include <FDM/JSBsim/FGState.h>
-#include <FDM/JSBsim/FGTranslation.h>
-
-#include "JSBsim.hxx"
-
-
-// The default aircraft
-FGFDMExec FDMExec;
-
-
-// Initialize the JSBsim flight model, dt is the time increment for
-// each subsequent iteration through the EOM
-int fgJSBsimInit(double dt) {
- FG_LOG( FG_FLIGHT, FG_INFO, "Starting initializing JSBsim" );
-
- FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" );
-
- FGPath aircraft_path( current_options.get_fg_root() );
- aircraft_path.append( "Aircraft" );
-
- FGPath engine_path( current_options.get_fg_root() );
- engine_path.append( "Engine" );
-
- FDMExec.GetAircraft()->LoadAircraft(aircraft_path.str(),
- engine_path.str(), "X15");
- FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" );
-
- FDMExec.GetState()->Reset(aircraft_path.str(), "Reset00");
- FG_LOG( FG_FLIGHT, FG_INFO, " loaded initial conditions" );
-
- FDMExec.GetState()->Setdt(dt);
- FG_LOG( FG_FLIGHT, FG_INFO, " set dt" );
-
- FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing JSBsim" );
-
- return 1;
-}
-
-
-// Run an iteration of the EOM (equations of motion)
-int fgJSBsimUpdate(FGInterface& f, int multiloop) {
- double save_alt = 0.0;
-
- // lets try to avoid really screwing up the JSBsim model
- if ( f.get_Altitude() < -9000 ) {
- save_alt = f.get_Altitude();
- f.set_Altitude( 0.0 );
- }
-
- // copy control positions into the JSBsim structure
- FDMExec.GetFCS()->SetDa( controls.get_aileron() );
- FDMExec.GetFCS()->SetDe( controls.get_elevator()
- + controls.get_elevator_trim() );
- FDMExec.GetFCS()->SetDr( controls.get_rudder() );
- FDMExec.GetFCS()->SetDf( 0.0 );
- FDMExec.GetFCS()->SetDs( 0.0 );
- FDMExec.GetFCS()->SetThrottle( FGControls::ALL_ENGINES,
- controls.get_throttle( 0 ) );
- // FCS->SetBrake( controls.get_brake( 0 ) );
-
- // Inform JSBsim of the local terrain altitude
- // Runway_altitude = f.get_Runway_altitude();
-
- // old -- FGInterface_2_JSBsim() not needed except for Init()
- // translate FG to JSBsim structure
- // FGInterface_2_JSBsim(f);
- // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
- // printf("Altitude = %.2f\n", Altitude * 0.3048);
- // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
-
- /* FDMExec.GetState()->Setsim_time(State->Getsim_time()
- + State->Getdt() * multiloop); */
-
- for ( int i = 0; i < multiloop; i++ ) {
- FDMExec.Run();
- }
-
- // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
- // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
-
- // translate JSBsim back to FG structure so that the
- // autopilot (and the rest of the sim can use the updated
- // values
-
- fgJSBsim_2_FGInterface(f);
-
- // but lets restore our original bogus altitude when we are done
- if ( save_alt < -9000.0 ) {
- f.set_Altitude( save_alt );
- }
-
- return 1;
-}
-
-
-// Convert from the FGInterface struct to the JSBsim generic_ struct
-int FGInterface_2_JSBsim (FGInterface& f) {
-
- return 1;
-}
-
-
-// Convert from the JSBsim generic_ struct to the FGInterface struct
-int fgJSBsim_2_FGInterface (FGInterface& f) {
-
- // Velocities
- f.set_Velocities_Local( FDMExec.GetPosition()->GetVn(),
- FDMExec.GetPosition()->GetVe(),
- FDMExec.GetPosition()->GetVd() );
- // f.set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
- // V_down_rel_ground );
- // f.set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
- // V_down_airmass );
- // f.set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
- // V_east_rel_airmass, V_down_rel_airmass );
- // f.set_Velocities_Gust( U_gust, V_gust, W_gust );
- // f.set_Velocities_Wind_Body( U_body, V_body, W_body );
-
- // f.set_V_rel_wind( V_rel_wind );
- // f.set_V_true_kts( V_true_kts );
- // f.set_V_rel_ground( V_rel_ground );
- // f.set_V_inertial( V_inertial );
- // f.set_V_ground_speed( V_ground_speed );
- // f.set_V_equiv( V_equiv );
-
- /* ***FIXME*** */ f.set_V_equiv_kts( FDMExec.GetState()->GetVt() );
- // f.set_V_calibrated( V_calibrated );
- // f.set_V_calibrated_kts( V_calibrated_kts );
-
- f.set_Omega_Body( FDMExec.GetRotation()->GetP(),
- FDMExec.GetRotation()->GetQ(),
- FDMExec.GetRotation()->GetR() );
- // f.set_Omega_Local( P_local, Q_local, R_local );
- // f.set_Omega_Total( P_total, Q_total, R_total );
-
- // f.set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
- // ***FIXME*** f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
-
- // Positions
- double lat_geoc = FDMExec.GetState()->Getlatitude();
- double lon = FDMExec.GetState()->Getlongitude();
- double alt = FDMExec.GetState()->Geth();
- double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
- fgGeocToGeod( lat_geoc, EQUATORIAL_RADIUS_M + alt * FEET_TO_METER,
- &lat_geod, &tmp_alt, &sl_radius1 );
- fgGeodToGeoc( lat_geod, alt * FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
-
- FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon << " lat_geod = " << lat_geod
- << " lat_geoc = " << lat_geoc
- << " alt = " << alt << " tmp_alt = " << tmp_alt * METER_TO_FEET
- << " sl_radius1 = " << sl_radius1 * METER_TO_FEET
- << " sl_radius2 = " << sl_radius2 * METER_TO_FEET
- << " Equator = " << EQUATORIAL_RADIUS_FT );
-
- f.set_Geocentric_Position( lat_geoc, lon,
- sl_radius2 * METER_TO_FEET + alt );
- f.set_Geodetic_Position( lat_geod, lon, alt );
- f.set_Euler_Angles( FDMExec.GetRotation()->Getphi(),
- FDMExec.GetRotation()->Gettht(),
- FDMExec.GetRotation()->Getpsi() );
-
- // Miscellaneous quantities
- // f.set_T_Local_to_Body(T_local_to_body_m);
- // f.set_Gravity( Gravity );
- // f.set_Centrifugal_relief( Centrifugal_relief );
-
- f.set_Alpha( FDMExec.GetTranslation()->Getalpha() );
- f.set_Beta( FDMExec.GetTranslation()->Getbeta() );
- // f.set_Alpha_dot( Alpha_dot );
- // f.set_Beta_dot( Beta_dot );
-
- // f.set_Cos_alpha( Cos_alpha );
- // f.set_Sin_alpha( Sin_alpha );
- // f.set_Cos_beta( Cos_beta );
- // f.set_Sin_beta( Sin_beta );
-
- // f.set_Cos_phi( Cos_phi );
- // f.set_Sin_phi( Sin_phi );
- // f.set_Cos_theta( Cos_theta );
- // f.set_Sin_theta( Sin_theta );
- // f.set_Cos_psi( Cos_psi );
- // f.set_Sin_psi( Sin_psi );
-
- // ***ATTENDTOME*** f.set_Gamma_vert_rad( Gamma_vert_rad );
- // f.set_Gamma_horiz_rad( Gamma_horiz_rad );
-
- // f.set_Sigma( Sigma );
- // f.set_Density( Density );
- // f.set_V_sound( V_sound );
- // f.set_Mach_number( Mach_number );
-
- // f.set_Static_pressure( Static_pressure );
- // f.set_Total_pressure( Total_pressure );
- // f.set_Impact_pressure( Impact_pressure );
- // f.set_Dynamic_pressure( Dynamic_pressure );
-
- // f.set_Static_temperature( Static_temperature );
- // f.set_Total_temperature( Total_temperature );
-
- /* **FIXME*** */ f.set_Sea_level_radius( sl_radius2 * METER_TO_FEET );
- /* **FIXME*** */ f.set_Earth_position_angle( 0.0 );
-
- /* ***FIXME*** */ f.set_Runway_altitude( 0.0 );
- // f.set_Runway_latitude( Runway_latitude );
- // f.set_Runway_longitude( Runway_longitude );
- // f.set_Runway_heading( Runway_heading );
- // f.set_Radius_to_rwy( Radius_to_rwy );
-
- // f.set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
- // f.set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
- // f.set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
- // D_pilot_above_rwy );
- // f.set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
-
- f.set_sin_lat_geocentric( lat_geoc );
- f.set_cos_lat_geocentric( lat_geoc );
- f.set_sin_cos_longitude( lon );
- f.set_sin_cos_latitude( lat_geod );
-
- return 0;
-}
-
-
+++ /dev/null
-// JSBsim.hxx -- interface to the "JSBsim" flight model
-//
-// Written by Curtis Olson, started February 1999.
-//
-// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _JSBSIM_HXX
-#define _JSBSIM_HXX
-
-#include <FDM/JSBsim/FGFDMExec.h>
-#undef MAX_ENGINES
-
-#include <Aircraft/aircraft.hxx>
-
-
-// reset flight params to a specific position
-int fgJSBsimInit(double dt);
-
-// update position based on inputs, positions, velocities, etc.
-int fgJSBsimUpdate(FGInterface& f, int multiloop);
-
-// Convert from the FGInterface struct to the JSBsim generic_ struct
-int FGInterface_2_JSBsim (FGInterface& f);
-
-// Convert from the JSBsim generic_ struct to the FGInterface struct
-int fgJSBsim_2_FGInterface (FGInterface& f);
-
-
-#endif // _JSBSIM_HXX
-
-
+++ /dev/null
-/*******************************************************************************
-
- Module: FGAircraft.cpp
- Author: Jon S. Berndt
- Date started: 12/12/98
- Purpose: Encapsulates an aircraft
- Called by: FGFDMExec
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-Models the aircraft reactions and forces. This class is instantiated by the
-FGFDMExec class and scheduled as an FDM entry. LoadAircraft() is supplied with a
-name of a valid, registered aircraft, and the data file is parsed.
-
-HISTORY
---------------------------------------------------------------------------------
-12/12/98 JSB Created
-04/03/99 JSB Changed Aero() method to correct body axis force calculation
- from wind vector. Fix provided by Tony Peden.
-05/03/99 JSB Changed (for the better?) the way configurations are read in.
-
-********************************************************************************
-COMMENTS, REFERENCES, and NOTES
-********************************************************************************
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
- Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
- School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
- JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
- NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
- Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
- 1982 ISBN 0-471-08936-2
-
-The aerodynamic coefficients used in this model are:
-
-Longitudinal
- CL0 - Reference lift at zero alpha
- CD0 - Reference drag at zero alpha
- CDM - Drag due to Mach
- CLa - Lift curve slope (w.r.t. alpha)
- CDa - Drag curve slope (w.r.t. alpha)
- CLq - Lift due to pitch rate
- CLM - Lift due to Mach
- CLadt - Lift due to alpha rate
-
- Cmadt - Pitching Moment due to alpha rate
- Cm0 - Reference Pitching moment at zero alpha
- Cma - Pitching moment slope (w.r.t. alpha)
- Cmq - Pitch damping (pitch moment due to pitch rate)
- CmM - Pitch Moment due to Mach
-
-Lateral
- Cyb - Side force due to sideslip
- Cyr - Side force due to yaw rate
-
- Clb - Dihedral effect (roll moment due to sideslip)
- Clp - Roll damping (roll moment due to roll rate)
- Clr - Roll moment due to yaw rate
- Cnb - Weathercocking stability (yaw moment due to sideslip)
- Cnp - Rudder adverse yaw (yaw moment due to roll rate)
- Cnr - Yaw damping (yaw moment due to yaw rate)
-
-Control
- CLDe - Lift due to elevator
- CDDe - Drag due to elevator
- CyDr - Side force due to rudder
- CyDa - Side force due to aileron
-
- CmDe - Pitch moment due to elevator
- ClDa - Roll moment due to aileron
- ClDr - Roll moment due to rudder
- CnDr - Yaw moment due to rudder
- CnDa - Yaw moment due to aileron
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#ifdef FGFS
-# ifndef __BORLANDC__
-# include <Include/compiler.h>
-# endif
-# ifdef FG_HAVE_STD_INCLUDES
-# include <cmath>
-# else
-# include <math.h>
-# endif
-#else
-# include <cmath>
-#endif
-
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGFCS.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
-{
- int i;
-
- Name = "FGAircraft";
-
- for (i=0;i<6;i++) coeff_ctr[i] = 0;
-}
-
-
-FGAircraft::~FGAircraft(void)
-{
-}
-
-bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname)
-{
- string path;
- string fullpath;
- string filename;
- string aircraftDef;
- string tag;
- string holding_string;
- char scratch[128];
- ifstream coeffInFile;
- streampos gpos;
- int axis;
- string axis_descript;
-
- axis = -1;
- aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
- ifstream aircraftfile(aircraftDef.c_str());
- cout << "Reading Aircraft Configuration File: " << aircraftDef << endl;
-
- numTanks = numEngines = 0;
- numSelectedOxiTanks = numSelectedFuelTanks = 0;
-
- while (!aircraftfile.fail()) {
- holding_string.erase();
- aircraftfile >> holding_string;
-#ifdef __BORLANDC__
- if (holding_string.compare(0, 2, "//") != 0) {
-#else
- if (holding_string.compare("//",0,2) != 0) {
-#endif
- if (holding_string == "AIRCRAFT") {
- cout << "Reading in Aircraft parameters ..." << endl;
- } else if (holding_string == "AERODYNAMICS") {
- cout << "Reading in Aerodynamic parameters ..." << endl;
- } else if (holding_string == "AC_NAME") {
- aircraftfile >> AircraftName; // String with no embedded spaces
- cout << "Aircraft Name: " << AircraftName << endl;
- } else if (holding_string == "AC_WINGAREA") {
- aircraftfile >> WingArea;
- cout << "Aircraft Wing Area: " << WingArea << endl;
- } else if (holding_string == "AC_WINGSPAN") {
- aircraftfile >> WingSpan;
- cout << "Aircraft WingSpan: " << WingSpan << endl;
- } else if (holding_string == "AC_CHORD") {
- aircraftfile >> cbar;
- cout << "Aircraft Chord: " << cbar << endl;
- } else if (holding_string == "AC_IXX") {
- aircraftfile >> Ixx;
- cout << "Aircraft Ixx: " << Ixx << endl;
- } else if (holding_string == "AC_IYY") {
- aircraftfile >> Iyy;
- cout << "Aircraft Iyy: " << Iyy << endl;
- } else if (holding_string == "AC_IZZ") {
- aircraftfile >> Izz;
- cout << "Aircraft Izz: " << Izz << endl;
- } else if (holding_string == "AC_IXZ") {
- aircraftfile >> Ixz;
- cout << "Aircraft Ixz: " << Ixz << endl;
- } else if (holding_string == "AC_EMPTYWT") {
- aircraftfile >> EmptyWeight;
- EmptyMass = EmptyWeight / GRAVITY;
- cout << "Aircraft Empty Weight: " << EmptyWeight << endl;
- } else if (holding_string == "AC_CGLOC") {
- aircraftfile >> Xcg >> Ycg >> Zcg;
- cout << "Aircraft C.G.: " << Xcg << " " << Ycg << " " << Zcg << endl;
- } else if (holding_string == "AC_EYEPTLOC") {
- aircraftfile >> Xep >> Yep >> Zep;
- cout << "Pilot Eyepoint: " << Xep << " " << Yep << " " << Zep << endl;
- } else if (holding_string == "AC_TANK") {
- Tank[numTanks] = new FGTank(aircraftfile);
- switch(Tank[numTanks]->GetType()) {
- case FGTank::ttFUEL:
- numSelectedFuelTanks++;
- cout << "Reading in Fuel Tank #" << numSelectedFuelTanks << " parameters ..." << endl;
- break;
- case FGTank::ttOXIDIZER:
- numSelectedOxiTanks++;
- cout << "Reading in Oxidizer Tank #" << numSelectedOxiTanks << " parameters ..." << endl;
- break;
- }
- numTanks++;
-
- } else if (holding_string == "AC_ENGINE") {
-
- aircraftfile >> tag;
- cout << "Reading in " << tag << " Engine parameters ..." << endl;
- Engine[numEngines] = new FGEngine(FDMExec, engine_path, tag, numEngines);
- numEngines++;
-
- } else if (holding_string == "}") {
-
- } else if (holding_string == "{") {
-
- } else if (holding_string == "LIFT") {
-
- axis_descript = " Lift Coefficients ...";
- axis = LiftCoeff;
-
- } else if (holding_string == "DRAG") {
-
- axis_descript = " Drag Coefficients ...";
- axis = DragCoeff;
-
- } else if (holding_string == "SIDE") {
-
- axis_descript = " Side Coefficients ...";
- axis = SideCoeff;
-
- } else if (holding_string == "ROLL") {
-
- axis_descript = " Roll Coefficients ...";
- axis = RollCoeff;
-
- } else if (holding_string == "PITCH") {
-
- axis_descript = " Pitch Coefficients ...";
- axis = PitchCoeff;
-
- } else if (holding_string == "YAW") {
-
- axis_descript = " Yaw Coefficients ...";
- axis = YawCoeff;
-
- }
-
- if (axis >= 0) {
- cout << axis_descript << endl;
- aircraftfile >> tag;
- gpos = aircraftfile.tellg();
- aircraftfile >> tag;
- if (tag != "}" ) {
- while (tag != "}") {
- aircraftfile.seekg(gpos);
- Coeff[axis][coeff_ctr[axis]] = new FGCoefficient(FDMExec, aircraftfile);
- coeff_ctr[axis]++;
- aircraftfile >> tag;
- gpos = aircraftfile.tellg();
- aircraftfile >> tag;
- }
- } else {
- cout << " None found ..." << endl;
- }
- }
- axis = -1;
-
- } else {
- aircraftfile.getline(scratch, 127);
- }
- }
- cout << "End of Configuration File Parsing." << endl;
-
- return true;
-}
-
-
-bool FGAircraft::Run(void)
-{
- if (!FGModel::Run()) { // if false then execute this Run()
- GetState();
-
- for (int i = 0; i < 3; i++) Forces[i] = Moments[i] = 0.0;
-
- MassChange();
-
- FProp(); FAero(); FGear(); FMass();
- MProp(); MAero(); MGear(); MMass();
-
- PutState();
- } else { // skip Run() execution this time
- }
- return false;
-}
-
-
-void FGAircraft::MassChange()
-{
- // UPDATE TANK CONTENTS
- //
- // For each engine, cycle through the tanks and draw an equal amount of
- // fuel (or oxidizer) from each active tank. The needed amount of fuel is
- // determined by the engine in the FGEngine class. If more fuel is needed
- // than is available in the tank, then that amount is considered a shortage,
- // and will be drawn from the next tank. If the engine cannot be fed what it
- // needs, it will be considered to be starved, and will shut down.
-
- float Oshortage, Fshortage;
-
- for (int e=0; e<numEngines; e++) {
- Fshortage = Oshortage = 0.0;
- for (int t=0; t<numTanks; t++) {
- switch(Engine[e]->GetType()) {
- case FGEngine::etRocket:
-
- switch(Tank[t]->GetType()) {
- case FGTank::ttFUEL:
- if (Tank[t]->GetSelected()) {
- Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
- numSelectedFuelTanks)*(dt*rate) + Fshortage);
- }
- break;
- case FGTank::ttOXIDIZER:
- if (Tank[t]->GetSelected()) {
- Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
- numSelectedOxiTanks)*(dt*rate) + Oshortage);
- }
- break;
- }
- break;
-
- case FGEngine::etPiston:
- case FGEngine::etTurboJet:
- case FGEngine::etTurboProp:
-
- if (Tank[t]->GetSelected()) {
- Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
- numSelectedFuelTanks)*(dt*rate) + Fshortage);
- }
- break;
- }
- }
- if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
- else Engine[e]->SetStarved(false);
- }
-
- Weight = EmptyWeight;
- for (int t=0; t<numTanks; t++)
- Weight += Tank[t]->GetContents();
-
- Mass = Weight / GRAVITY;
-}
-
-
-void FGAircraft::FAero(void)
-{
- float F[3];
-
- F[0] = F[1] = F[2] = 0.0;
-
- for (int axis_ctr = 0; axis_ctr < 3; axis_ctr++)
- for (int ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++)
- F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
-
- Forces[0] += - F[DragCoeff]*cos(alpha)*cos(beta)
- - F[SideCoeff]*cos(alpha)*sin(beta)
- + F[LiftCoeff]*sin(alpha);
- Forces[1] += F[DragCoeff]*sin(beta)
- + F[SideCoeff]*cos(beta);
- Forces[2] += - F[DragCoeff]*sin(alpha)*cos(beta)
- - F[SideCoeff]*sin(alpha)*sin(beta)
- - F[LiftCoeff]*cos(alpha);
-}
-
-
-void FGAircraft::FGear(void)
-{
- if (GearUp) {
- } else {
- }
-}
-
-
-void FGAircraft::FMass(void)
-{
- Forces[0] += -GRAVITY*sin(tht) * Mass;
- Forces[1] += GRAVITY*sin(phi)*cos(tht) * Mass;
- Forces[2] += GRAVITY*cos(phi)*cos(tht) * Mass;
-}
-
-
-void FGAircraft::FProp(void)
-{
- for (int i=0;i<numEngines;i++) {
- Forces[0] += Engine[i]->CalcThrust();
- }
-}
-
-
-void FGAircraft::MAero(void)
-{
- int axis_ctr, ctr;
-
- for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
- for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
- Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue();
- }
- }
-}
-
-
-void FGAircraft::MGear(void)
-{
- if (GearUp) {
- } else {
- }
-}
-
-
-void FGAircraft::MMass(void)
-{
-}
-
-
-void FGAircraft::MProp(void)
-{
-}
-
-
-void FGAircraft::GetState(void)
-{
- dt = State->Getdt();
-
- alpha = Translation->Getalpha();
- beta = Translation->Getbeta();
- phi = Rotation->Getphi();
- tht = Rotation->Gettht();
- psi = Rotation->Getpsi();
-}
-
-
-void FGAircraft::PutState(void)
-{
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGAircraft.h
- Author: Jon S. Berndt
- Date started: 12/12/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-12/12/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGAIRCRAFT_H
-#define FGAIRCRAFT_H
-
-/*******************************************************************************
-COMMENTS, REFERENCES, and NOTES
-*******************************************************************************/
-/*
-The aerodynamic coefficients used in this model typically are:
-
-Longitudinal
- CL0 - Reference lift at zero alpha
- CD0 - Reference drag at zero alpha
- CDM - Drag due to Mach
- CLa - Lift curve slope (w.r.t. alpha)
- CDa - Drag curve slope (w.r.t. alpha)
- CLq - Lift due to pitch rate
- CLM - Lift due to Mach
- CLadt - Lift due to alpha rate
-
- Cmadt - Pitching Moment due to alpha rate
- Cm0 - Reference Pitching moment at zero alpha
- Cma - Pitching moment slope (w.r.t. alpha)
- Cmq - Pitch damping (pitch moment due to pitch rate)
- CmM - Pitch Moment due to Mach
-
-Lateral
- Cyb - Side force due to sideslip
- Cyr - Side force due to yaw rate
-
- Clb - Dihedral effect (roll moment due to sideslip)
- Clp - Roll damping (roll moment due to roll rate)
- Clr - Roll moment due to yaw rate
- Cnb - Weathercocking stability (yaw moment due to sideslip)
- Cnp - Rudder adverse yaw (yaw moment due to roll rate)
- Cnr - Yaw damping (yaw moment due to yaw rate)
-
-Control
- CLDe - Lift due to elevator
- CDDe - Drag due to elevator
- CyDr - Side force due to rudder
- CyDa - Side force due to aileron
-
- CmDe - Pitch moment due to elevator
- ClDa - Roll moment due to aileron
- ClDr - Roll moment due to rudder
- CnDr - Yaw moment due to rudder
- CnDa - Yaw moment due to aileron
-
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
- Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
- School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
- JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
- NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
- Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
- 1982 ISBN 0-471-08936-2
-*/
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <fstream>
-# else
-# include <fstream.h>
-# endif
-#else
-# include <fstream>
-#endif
-
-#include "FGModel.h"
-#include "FGCoefficient.h"
-#include "FGEngine.h"
-#include "FGTank.h"
-
-/*******************************************************************************
-DEFINITIONS
-*******************************************************************************/
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGAircraft : public FGModel
-{
-public:
- FGAircraft(FGFDMExec*);
- ~FGAircraft(void);
-
- bool Run(void);
- bool LoadAircraft(string, string, string);
- inline string GetAircraftName(void) {return AircraftName;}
- inline void SetGearUp(bool tt) {GearUp = tt;}
- inline bool GetGearUp(void) {return GearUp;}
- inline float GetWingArea(void) {return WingArea;}
- inline float GetWingSpan(void) {return WingSpan;}
- inline float Getcbar(void) {return cbar;}
- inline FGEngine* GetEngine(int tt) {return Engine[tt];}
- inline FGTank* GetTank(int tt) {return Tank[tt];}
- inline float GetWeight(void) {return Weight;}
- inline float GetMass(void) {return Mass;}
- inline float GetL(void) {return Moments[0];}
- inline float GetM(void) {return Moments[1];}
- inline float GetN(void) {return Moments[2];}
- inline float GetFx(void) {return Forces[0];}
- inline float GetFy(void) {return Forces[1];}
- inline float GetFz(void) {return Forces[2];}
- inline float GetIxx(void) {return Ixx;}
- inline float GetIyy(void) {return Iyy;}
- inline float GetIzz(void) {return Izz;}
- inline float GetIxz(void) {return Ixz;}
-
-private:
- void GetState(void);
- void PutState(void);
- void FAero(void);
- void FGear(void);
- void FMass(void);
- void FProp(void);
- void MAero(void);
- void MGear(void);
- void MMass(void);
- void MProp(void);
- void MassChange(void);
- float Moments[3];
- float Forces[3];
- string AircraftName;
- float Ixx, Iyy, Izz, Ixz, EmptyMass, Mass;
- float Xcg, Ycg, Zcg;
- float Xep, Yep, Zep;
- float rho, qbar, Vt;
- float alpha, beta;
- float WingArea, WingSpan, cbar;
- float phi, tht, psi;
- float Weight, EmptyWeight;
- float dt;
-
- int numTanks;
- int numEngines;
- int numSelectedOxiTanks;
- int numSelectedFuelTanks;
- FGTank* Tank[MAX_TANKS];
- FGEngine *Engine[MAX_ENGINES];
-
- FGCoefficient *Coeff[6][10];
- int coeff_ctr[6];
-
- bool GearUp;
-
- enum Param {LiftCoeff,
- DragCoeff,
- SideCoeff,
- RollCoeff,
- PitchCoeff,
- YawCoeff,
- numCoeffs};
-
- string Axis[6];
-
-protected:
-
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGAtmosphere.cpp
- Author: Jon Berndt
- Date started: 11/24/98
- Purpose: Models the atmosphere
- Called by: FGSimExec
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-Models the atmosphere. The equation used below was determined by a third order
-curve fit using Excel. The data is from the ICAO atmosphere model.
-
-HISTORY
---------------------------------------------------------------------------------
-11/24/98 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
-{
- Name = "FGAtmosphere";
-}
-
-
-FGAtmosphere::~FGAtmosphere()
-{
-}
-
-
-bool FGAtmosphere::Run(void)
-{
- if (!FGModel::Run()) { // if false then execute this Run()
- rho = 0.002377 - 7.0E-08*State->Geth()
- + 7.0E-13*State->Geth()*State->Geth()
- - 2.0E-18*State->Geth()*State->Geth()*State->Geth();
-
- State->SetMach(State->GetVt()/State->Geta());
- } else { // skip Run() execution this time
- }
- return false;
-}
-
-float FGAtmosphere::CalcRho(float altitude)
-{
- return (0.002377 - 7.0E-08*altitude
- + 7.0E-13*altitude*altitude
- - 2.0E-18*altitude*altitude*altitude);
-
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGAtmosphere.h
- Author: Jon Berndt
- Date started: 11/24/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-11/24/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGATMOSPHERE_H
-#define FGATMOSPHERE_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGModel.h"
-
-/*******************************************************************************
-COMMENTS, REFERENCES, and NOTES
-*******************************************************************************/
-/**
-The equation used in this model was determined by a third order curve fit using
-Excel. The data is from the ICAO atmosphere model.
-@memo Models the atmosphere.
-@author Jon S. Berndt
-*/
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-using namespace std;
-
-class FGAtmosphere : public FGModel
-{
-public:
- FGAtmosphere(FGFDMExec*);
- ~FGAtmosphere(void);
- bool Run(void);
-
- inline float Getrho(void) {return rho;}
- float CalcRho(float altitude);
-
-protected:
-
-private:
- float rho;
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGAuxiliary.cpp
- Author: Jon Berndt
- Date started: 01/26/99
- Purpose: Calculates additional parameters needed by the visual system, etc.
- Called by: FGSimExec
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This class calculates various auxiliary parameters, mostly used by the visual
-system
-
-HISTORY
---------------------------------------------------------------------------------
-01/26/99 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGAuxiliary.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGPosition.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
-{
- Name = "FGAuxiliary";
-}
-
-
-FGAuxiliary::~FGAuxiliary()
-{
-}
-
-
-bool FGAuxiliary::Run()
-{
- if (!FGModel::Run()) {
- } else {
- }
- return false;
-}
-
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGAuxiliary.h
- Author: Jon Berndt
- Date started: 01/26/99
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-11/22/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGAUXILIARY_H
-#define FGAUXILIARY_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-#include "FGModel.h"
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGAuxiliary : public FGModel
-{
-public:
- FGAuxiliary(FGFDMExec*);
- ~FGAuxiliary(void);
-
- bool Run(void);
-
-protected:
-
-private:
-
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGCoefficient.cpp
- Author: Jon S. Berndt
- Date started: 12/28/98
- Purpose: Encapsulates the stability derivative class FGCoefficient;
- Called by: FGAircraft
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This class models the stability derivative coefficient lookup tables or
-equations. Note that the coefficients need not be calculated each delta-t.
-
-Note that the values in a row which index into the table must be the same value
-for each column of data, so the first column of numbers for each altitude are
-seen to be equal, and there are the same number of values for each altitude.
-
-See the header file FGCoefficient.h for the values of the identifiers.
-
-HISTORY
---------------------------------------------------------------------------------
-12/28/98 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGCoefficient.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile)
-{
- int r, c, start, end, n;
- float ftrashcan;
- string strashcan;
-
- coeffdef["FG_QBAR"] = 1;
- coeffdef["FG_WINGAREA"] = 2;
- coeffdef["FG_WINGSPAN"] = 4;
- coeffdef["FG_CBAR"] = 8;
- coeffdef["FG_ALPHA"] = 16;
- coeffdef["FG_ALPHADOT"] = 32;
- coeffdef["FG_BETA"] = 64;
- coeffdef["FG_BETADOT"] = 128;
- coeffdef["FG_PITCHRATE"] = 256;
- coeffdef["FG_ROLLRATE"] = 512;
- coeffdef["FG_YAWRATE"] = 1024;
- coeffdef["FG_ELEVATOR"] = 2048;
- coeffdef["FG_AILERON"] = 4096;
- coeffdef["FG_RUDDER"] = 8192;
- coeffdef["FG_MACH"] = 16384;
- coeffdef["FG_ALTITUDE"] = 32768L;
- coeffdef["FG_BI2VEL"] = 65536L;
- coeffdef["FG_CI2VEL"] = 131072L;
-
- FDMExec = fdex;
- State = FDMExec->GetState();
- Atmosphere = FDMExec->GetAtmosphere();
- FCS = FDMExec->GetFCS();
- Aircraft = FDMExec->GetAircraft();
- Translation = FDMExec->GetTranslation();
- Rotation = FDMExec->GetRotation();
- Position = FDMExec->GetPosition();
- Auxiliary = FDMExec->GetAuxiliary();
- Output = FDMExec->GetOutput();
-
- if (coeffDefFile) {
- if (!coeffDefFile.fail()) {
- coeffDefFile >> name;
- cout << " " << name << endl;
- coeffDefFile >> strashcan;
- coeffDefFile >> description;
- cout << " " << description << endl;
- coeffDefFile >> method;
- cout << " " << method << endl;
-
- if (method == "EQUATION") type = EQUATION;
- else if (method == "TABLE") type = TABLE;
- else if (method == "VECTOR") type = VECTOR;
- else if (method == "VALUE") type = VALUE;
- else type = UNKNOWN;
-
- if (type == VECTOR || type == TABLE) {
- coeffDefFile >> rows;
- cout << " Rows: " << rows << " ";
- if (type == TABLE) {
- coeffDefFile >> columns;
- cout << "Cols: " << columns;
- }
-
- cout << endl;
-
- coeffDefFile >> strashcan;
- if (strashcan.substr(0,1) == "F") {
- LookupR = coeffdef[strashcan.c_str()];
- cout << " Row indexing parameter: " << strashcan << endl;
- } else {
- LookupR = atoi(strashcan.c_str());
- cout << " Row indexing parameter: " << LookupR << endl;
- }
-
- }
-
- if (type == TABLE) {
- coeffDefFile >> strashcan;
- if (strashcan.substr(0,1) == "F") {
- LookupC = coeffdef[strashcan.c_str()];
- cout << " Column indexing parameter: " << strashcan << endl;
- } else {
- LookupC = atoi(strashcan.c_str());
- cout << " Column indexing parameter: " << LookupC << endl;
- }
- }
-
- coeffDefFile >> strashcan;
-
- end = strashcan.length();
- n = strashcan.find("|");
- start = 0;
- multipliers = 0;
- if (strashcan.substr(0,1) == "F") {
- while(n < end && n >= 0) {
- n -= start;
- multipliers += coeffdef[strashcan.substr(start,n).c_str()];
- start += n+1;
- n = strashcan.find("|",start);
- }
- multipliers += coeffdef[strashcan.substr(start,end).c_str()];
- } else {
- multipliers = atoi(strashcan.c_str());
- }
-
- cout << " Non-Dimensionalized by: ";
-
- mult_count = 0;
- if (multipliers & FG_QBAR) {
- mult_idx[mult_count] = FG_QBAR;
- mult_count++;
- cout << "qbar ";
- }
- if (multipliers & FG_WINGAREA) {
- mult_idx[mult_count] = FG_WINGAREA;
- mult_count++;
- cout << "S ";
- }
- if (multipliers & FG_WINGSPAN) {
- mult_idx[mult_count] = FG_WINGSPAN;
- mult_count++;
- cout << "b ";
- }
- if (multipliers & FG_CBAR) {
- mult_idx[mult_count] = FG_CBAR;
- mult_count++;
- cout << "c ";
- }
- if (multipliers & FG_ALPHA) {
- mult_idx[mult_count] = FG_ALPHA;
- mult_count++;
- cout << "alpha ";
- }
- if (multipliers & FG_ALPHADOT) {
- mult_idx[mult_count] = FG_ALPHADOT;
- mult_count++;
- cout << "alphadot ";
- }
- if (multipliers & FG_BETA) {
- mult_idx[mult_count] = FG_BETA;
- mult_count++;
- cout << "beta ";
- }
- if (multipliers & FG_BETADOT) {
- mult_idx[mult_count] = FG_BETADOT;
- mult_count++;
- cout << "betadot ";
- }
- if (multipliers & FG_PITCHRATE) {
- mult_idx[mult_count] = FG_PITCHRATE;
- mult_count++;
- cout << "q ";
- }
- if (multipliers & FG_ROLLRATE) {
- mult_idx[mult_count] = FG_ROLLRATE;
- mult_count++;
- cout << "p ";
- }
- if (multipliers & FG_YAWRATE) {
- mult_idx[mult_count] = FG_YAWRATE;
- mult_count++;
- cout << "r ";
- }
- if (multipliers & FG_ELEVATOR) {
- mult_idx[mult_count] = FG_ELEVATOR;
- mult_count++;
- cout << "De ";
- }
- if (multipliers & FG_AILERON) {
- mult_idx[mult_count] = FG_AILERON;
- mult_count++;
- cout << "Da ";
- }
- if (multipliers & FG_RUDDER) {
- mult_idx[mult_count] = FG_RUDDER;
- mult_count++;
- cout << "Dr ";
- }
- if (multipliers & FG_MACH) {
- mult_idx[mult_count] = FG_MACH;
- mult_count++;
- cout << "Mach ";
- }
- if (multipliers & FG_ALTITUDE) {
- mult_idx[mult_count] = FG_ALTITUDE;
- mult_count++;
- cout << "h ";
- }
- if (multipliers & FG_BI2VEL) {
- mult_idx[mult_count] = FG_BI2VEL;
- mult_count++;
- cout << "b /(2*Vt) ";
- }
- if (multipliers & FG_CI2VEL) {
- mult_idx[mult_count] = FG_CI2VEL;
- mult_count++;
- cout << "c /(2*Vt) ";
- }
- cout << endl;
-
- switch(type) {
- case VALUE:
- coeffDefFile >> StaticValue;
- cout << " Value = " << StaticValue << endl;
- break;
- case VECTOR:
- Allocate(rows,2);
-
- for (r=1;r<=rows;r++) {
- coeffDefFile >> Table3D[r][0];
- coeffDefFile >> Table3D[r][1];
- }
-
- for (r=0;r<=rows;r++) {
- cout << " ";
- for (c=0;c<=columns;c++) {
- cout << Table3D[r][c] << " ";
- }
- cout << endl;
- }
-
- break;
- case TABLE:
- Allocate(rows, columns);
-
- Table3D[0][0] = 0.0;
- for (c=1;c<=columns;c++) {
- coeffDefFile >> Table3D[0][c];
- for (r=1;r<=rows;r++) {
- if ( c==1 ) coeffDefFile >> Table3D[r][0];
- else coeffDefFile >> ftrashcan;
- coeffDefFile >> Table3D[r][c];
- }
- }
-
- for (r=0;r<=rows;r++) {
- cout << " ";
- for (c=0;c<=columns;c++) {
- cout << Table3D[r][c] << " ";
- }
- cout << endl;
- }
-
- break;
- }
- } else {
- cerr << "Empty file" << endl;
- }
- }
-}
-
-
-FGCoefficient::~FGCoefficient(void)
-{
-}
-
-
-bool FGCoefficient::Allocate(int r, int c)
-{
- rows = r;
- columns = c;
- Table3D = new float*[r+1];
- for (int i=0;i<=r;i++) Table3D[i] = new float[c+1];
- return true;
-}
-
-
-bool FGCoefficient::Allocate(int n)
-{
- rows = n;
- columns = 0;
- Table2D = new float[n+1];
- return true;
-}
-
-
-float FGCoefficient::Value(float rVal, float cVal)
-{
- float rFactor, cFactor, col1temp, col2temp, Value;
- int r, c, midx;
-
- if (rows < 2 || columns < 2) return 0.0;
-
- for (r=1;r<=rows;r++) if (Table3D[r][0] >= rVal) break;
- for (c=1;c<=columns;c++) if (Table3D[0][c] >= cVal) break;
-
- c = c < 2 ? 2 : (c > columns ? columns : c);
- r = r < 2 ? 2 : (r > rows ? rows : r);
-
- rFactor = (rVal - Table3D[r-1][0]) / (Table3D[r][0] - Table3D[r-1][0]);
- cFactor = (cVal - Table3D[0][c-1]) / (Table3D[0][c] - Table3D[0][c-1]);
-
- col1temp = rFactor*(Table3D[r][c-1] - Table3D[r-1][c-1]) + Table3D[r-1][c-1];
- col2temp = rFactor*(Table3D[r][c] - Table3D[r-1][c]) + Table3D[r-1][c];
-
- Value = col1temp + cFactor*(col2temp - col1temp);
-
- for (midx=0;midx<mult_count;midx++) {
- Value *= GetCoeffVal(mult_idx[midx]);
- }
-
- return Value;
-}
-
-
-float FGCoefficient::Value(float Val)
-{
- float Factor, Value;
- int r, midx;
-
- if (rows < 2) return 0.0;
-
- for (r=1;r<=rows;r++) if (Table3D[r][0] >= Val) break;
- r = r < 2 ? 2 : (r > rows ? rows : r);
-
- // make sure denominator below does not go to zero.
- if (Table3D[r][0] != Table3D[r-1][0]) {
- Factor = (Val - Table3D[r-1][0]) / (Table3D[r][0] - Table3D[r-1][0]);
- } else {
- Factor = 1.0;
- }
-
- Value = Factor*(Table3D[r][1] - Table3D[r-1][1]) + Table3D[r-1][1];
-
- for (midx=0;midx<mult_count;midx++) {
- Value *= GetCoeffVal(mult_idx[midx]);
- }
-
- return Value;
-}
-
-
-float FGCoefficient::Value(void)
-{
- float Value;
- int midx;
-
- Value = StaticValue;
-
- for (midx=0;midx<mult_count;midx++) {
- Value *= GetCoeffVal(mult_idx[midx]);
- }
-
- return Value;
-}
-
-float FGCoefficient::TotalValue()
-{
- switch(type) {
- case 0:
- return -1;
- case 1:
- return (Value());
- case 2:
- return (Value(GetCoeffVal(LookupR)));
- case 3:
- return (Value(GetCoeffVal(LookupR),GetCoeffVal(LookupC)));
- case 4:
- return 0.0;
- }
- return 0;
-}
-
-float FGCoefficient::GetCoeffVal(int val_idx)
-{
- switch(val_idx) {
- case FG_QBAR:
- return State->Getqbar();
- case FG_WINGAREA:
- return Aircraft->GetWingArea();
- case FG_WINGSPAN:
- return Aircraft->GetWingSpan();
- case FG_CBAR:
- return Aircraft->Getcbar();
- case FG_ALPHA:
- return Translation->Getalpha();
- case FG_ALPHADOT:
- return State->Getadot();
- case FG_BETA:
- return Translation->Getbeta();
- case FG_BETADOT:
- return State->Getbdot();
- case FG_PITCHRATE:
- return Rotation->GetQ();
- case FG_ROLLRATE:
- return Rotation->GetP();
- case FG_YAWRATE:
- return Rotation->GetR();
- case FG_ELEVATOR:
- return FCS->GetDe();
- case FG_AILERON:
- return FCS->GetDa();
- case FG_RUDDER:
- return FCS->GetDr();
- case FG_MACH:
- return State->GetMach();
- case FG_ALTITUDE:
- return State->Geth();
- case FG_BI2VEL:
- return Aircraft->GetWingSpan()/(2.0 * State->GetVt());
- case FG_CI2VEL:
- return Aircraft->Getcbar()/(2.0 * State->GetVt());
- }
- return 0;
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGCoefficient.h
- Author: Jon Berndt
- Date started: 12/28/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-12/28/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGCOEFFICIENT_H
-#define FGCOEFFICIENT_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-#ifdef FGFS
-# include <Include/compiler.h>
-# include STL_STRING
-# ifdef FG_HAVE_STD_INCLUDES
-# include <fstream>
-# else
-# include <fstream.h>
-# endif
- FG_USING_STD(string);
-#else
-# include <string>
-# include <fstream>
-#endif
-
-#include <map>
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-#define FG_QBAR 1
-#define FG_WINGAREA 2
-#define FG_WINGSPAN 4
-#define FG_CBAR 8
-#define FG_ALPHA 16
-#define FG_ALPHADOT 32
-#define FG_BETA 64
-#define FG_BETADOT 128
-#define FG_PITCHRATE 256
-#define FG_ROLLRATE 512
-#define FG_YAWRATE 1024
-#define FG_ELEVATOR 2048
-#define FG_AILERON 4096
-#define FG_RUDDER 8192
-#define FG_MACH 16384
-#define FG_ALTITUDE 32768L
-#define FG_BI2VEL 65536L
-#define FG_CI2VEL 131072L
-
-/*******************************************************************************
-FORWARD DECLARATIONS
-*******************************************************************************/
-class FGFDMExec;
-class FGState;
-class FGAtmosphere;
-class FGFCS;
-class FGAircraft;
-class FGTranslation;
-class FGRotation;
-class FGPosition;
-class FGAuxiliary;
-class FGOutput;
-
-/*******************************************************************************
-COMMENTS, REFERENCES, and NOTES
-********************************************************************************
-
-This class models the stability derivative coefficient lookup tables or
-equations. Note that the coefficients need not be calculated each delta-t.
-
-FG_QBAR 1
-FG_WINGAREA 2
-FG_WINGSPAN 4
-FG_CBAR 8
-FG_ALPHA 16
-FG_ALPHADOT 32
-FG_BETA 64
-FG_BETADOT 128
-FG_PITCHRATE 256
-FG_ROLLRATE 512
-FG_YAWRATE 1024
-FG_ELEVATOR 2048
-FG_AILERON 4096
-FG_RUDDER 8192
-FG_MACH 16384
-FG_ALTITUDE 32768L
-FG_BI2VEL 65536L
-FG_CI2VEL 131072L
-
-********************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGCoefficient
-{
-public:
- FGCoefficient(FGFDMExec*, ifstream&);
- ~FGCoefficient(void);
- bool Allocate(int);
- bool Allocate(int, int);
- float Value(float, float);
- float Value(float);
- float Value(void);
- float TotalValue(void);
- enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
-
-protected:
-
-private:
- typedef map<string, long> CoeffMap;
- CoeffMap coeffdef;
- string filename;
- string description;
- string name;
- string method;
- float StaticValue;
- float *Table2D;
- float **Table3D;
- float LookupR, LookupC;
- long int mult_idx[10];
- int rows, columns;
- Type type;
- int multipliers;
- int mult_count;
-
- float GetCoeffVal(int);
-
- FGFDMExec* FDMExec;
- FGState* State;
- FGAtmosphere* Atmosphere;
- FGFCS* FCS;
- FGAircraft* Aircraft;
- FGTranslation* Translation;
- FGRotation* Rotation;
- FGPosition* Position;
- FGAuxiliary* Auxiliary;
- FGOutput* Output;
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-// controls.cxx -- defines a standard interface to all flight sim controls
-//
-// Written by Curtis Olson, started May 1997.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-// (Log is kept at end of this file)
-
-
-#include "FGControls.h"
-
-
-FGControls controls;
-
-
-// Constructor
-FGControls::FGControls() :
- aileron( 0.0 ),
- elevator( 0.0 ),
- elevator_trim( 1.969572E-03 ),
- rudder( 0.0 )
-{
- for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
- throttle[engine] = 0.0;
- }
-
- for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
- brake[wheel] = 0.0;
- }
-}
-
-
-// Destructor
-FGControls::~FGControls() {
-}
-
-
-// $Log$
-// Revision 1.6 1999/06/29 15:30:33 curt
-// Updated contributed by Jon Berndt.
-//
-// Revision 1.1 1999/02/13 01:12:03 curt
-// Initial Revision.
-//
-// Revision 1.1 1999/02/09 04:51:32 jon
-// Initial revision
-//
-// Revision 1.3 1998/12/05 16:13:12 curt
-// Renamed class fgCONTROLS to class FGControls.
-//
-// Revision 1.2 1998/10/25 14:08:41 curt
-// Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
-//
-// Revision 1.1 1998/10/18 01:51:05 curt
-// c++-ifying ...
-//
-// Revision 1.8 1998/09/29 02:01:31 curt
-// Added a brake.
-//
-// Revision 1.7 1998/02/07 15:29:36 curt
-// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
-// <chotchkiss@namg.us.anritsu.com>
-//
-// Revision 1.6 1998/01/19 19:27:02 curt
-// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
-// This should simplify things tremendously.
-//
-// Revision 1.5 1998/01/19 18:40:22 curt
-// Tons of little changes to clean up the code and to remove fatal errors
-// when building with the c++ compiler.
-//
-// Revision 1.4 1997/12/10 22:37:41 curt
-// Prepended "fg" on the name of all global structures that didn't have it yet.
-// i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
-//
-// Revision 1.3 1997/08/27 03:30:01 curt
-// Changed naming scheme of basic shared structures.
-//
-// Revision 1.2 1997/06/21 17:12:48 curt
-// Capitalized subdirectory names.
-//
-// Revision 1.1 1997/05/31 19:24:04 curt
-// Initial revision.
-//
-
+++ /dev/null
-// controls.hxx -- defines a standard interface to all flight sim controls
-//
-// Written by Curtis Olson, started May 1997.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-// (Log is kept at end of this file)
-
-
-#ifndef _CONTROLS_HXX
-#define _CONTROLS_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-//using namespace std;
-
-// Define a structure containing the control parameters
-
-class FGControls {
-
-public:
-
- static const int ALL_ENGINES = -1;
- static const int MAX_ENGINES = 10;
-
- static const int ALL_WHEELS = -1;
- static const int MAX_WHEELS = 3;
-
-private:
-
- double aileron;
- double elevator;
- double elevator_trim;
- double rudder;
- double throttle[MAX_ENGINES];
- double brake[MAX_WHEELS];
-
-public:
-
- FGControls();
- ~FGControls();
-
- // Query functions
- inline double get_aileron() const { return aileron; }
- inline double get_elevator() const { return elevator; }
- inline double get_elevator_trim() const { return elevator_trim; }
- inline double get_rudder() const { return rudder; }
- inline double get_throttle(int engine) const { return throttle[engine]; }
- inline double get_brake(int wheel) const { return brake[wheel]; }
-
- // Update functions
- inline void set_aileron( double pos ) {
- aileron = pos;
- if ( aileron < -1.0 ) aileron = -1.0;
- if ( aileron > 1.0 ) aileron = 1.0;
- }
- inline void move_aileron( double amt ) {
- aileron += amt;
- if ( aileron < -1.0 ) aileron = -1.0;
- if ( aileron > 1.0 ) aileron = 1.0;
- }
- inline void set_elevator( double pos ) {
- elevator = pos;
- if ( elevator < -1.0 ) elevator = -1.0;
- if ( elevator > 1.0 ) elevator = 1.0;
- }
- inline void move_elevator( double amt ) {
- elevator += amt;
- if ( elevator < -1.0 ) elevator = -1.0;
- if ( elevator > 1.0 ) elevator = 1.0;
- }
- inline void set_elevator_trim( double pos ) {
- elevator_trim = pos;
- if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
- if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
- }
- inline void move_elevator_trim( double amt ) {
- elevator_trim += amt;
- if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
- if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
- }
- inline void set_rudder( double pos ) {
- rudder = pos;
- if ( rudder < -1.0 ) rudder = -1.0;
- if ( rudder > 1.0 ) rudder = 1.0;
- }
- inline void move_rudder( double amt ) {
- rudder += amt;
- if ( rudder < -1.0 ) rudder = -1.0;
- if ( rudder > 1.0 ) rudder = 1.0;
- }
- inline void set_throttle( int engine, double pos ) {
- if ( engine == ALL_ENGINES ) {
- for ( int i = 0; i < MAX_ENGINES; i++ ) {
- throttle[i] = pos;
- if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
- if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
- }
- } else {
- if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
- throttle[engine] = pos;
- if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
- if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
- }
- }
- }
- inline void move_throttle( int engine, double amt ) {
- if ( engine == ALL_ENGINES ) {
- for ( int i = 0; i < MAX_ENGINES; i++ ) {
- throttle[i] += amt;
- if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
- if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
- }
- } else {
- if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
- throttle[engine] += amt;
- if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
- if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
- }
- }
- }
- inline void set_brake( int wheel, double pos ) {
- if ( wheel == ALL_WHEELS ) {
- for ( int i = 0; i < MAX_WHEELS; i++ ) {
- brake[i] = pos;
- if ( brake[i] < 0.0 ) brake[i] = 0.0;
- if ( brake[i] > 1.0 ) brake[i] = 1.0;
- }
- } else {
- if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
- brake[wheel] = pos;
- if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
- if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
- }
- }
- }
- inline void move_brake( int wheel, double amt ) {
- if ( wheel == ALL_WHEELS ) {
- for ( int i = 0; i < MAX_WHEELS; i++ ) {
- brake[i] += amt;
- if ( brake[i] < 0.0 ) brake[i] = 0.0;
- if ( brake[i] > 1.0 ) brake[i] = 1.0;
- }
- } else {
- if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
- brake[wheel] += amt;
- if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
- if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
- }
- }
- }
-};
-
-
-extern FGControls controls;
-
-
-#endif // _CONTROLS_HXX
-
-
-// $Log$
-// Revision 1.6 1999/06/29 15:30:35 curt
-// Updated contributed by Jon Berndt.
-//
-// Revision 1.1 1999/02/13 01:12:03 curt
-// Initial Revision.
-//
-// Revision 1.3 1998/12/05 16:13:13 curt
-// Renamed class fgCONTROLS to class FGControls.
-//
-// Revision 1.2 1998/10/25 14:08:42 curt
-// Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
-//
-// Revision 1.1 1998/10/18 01:51:07 curt
-// c++-ifying ...
-//
-// Revision 1.17 1998/09/29 14:57:00 curt
-// c++-ified some comments.
-//
-// Revision 1.16 1998/09/29 02:01:32 curt
-// Added a brake.
-//
-// Revision 1.15 1998/04/25 22:06:27 curt
-// Edited cvs log messages in source files ... bad bad bad!
-//
-// Revision 1.14 1998/04/22 13:26:19 curt
-// C++ - ifing the code a bit.
-//
-// Revision 1.13 1998/04/21 17:02:35 curt
-// Prepairing for C++ integration.
-//
-// Revision 1.12 1998/02/09 22:56:48 curt
-// Removed "depend" files from cvs control. Other minor make tweaks.
-//
-// Revision 1.11 1998/02/07 15:29:36 curt
-// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
-// <chotchkiss@namg.us.anritsu.com>
-//
-// Revision 1.10 1998/01/27 00:47:52 curt
-// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
-// system and commandline/config file processing code.
-//
-// Revision 1.9 1998/01/22 02:59:31 curt
-// Changed #ifdef FILE_H to #ifdef _FILE_H
-//
-// Revision 1.8 1998/01/19 18:40:22 curt
-// Tons of little changes to clean up the code and to remove fatal errors
-// when building with the c++ compiler.
-//
-// Revision 1.7 1997/12/15 23:54:36 curt
-// Add xgl wrappers for debugging.
-// Generate terrain normals on the fly.
-//
-// Revision 1.6 1997/12/10 22:37:41 curt
-// Prepended "fg" on the name of all global structures that didn't have it yet.
-// i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
-//
-// Revision 1.5 1997/08/27 03:30:02 curt
-// Changed naming scheme of basic shared structures.
-//
-// Revision 1.4 1997/07/23 21:52:18 curt
-// Put comments around the text after an #endif for increased portability.
-//
-// Revision 1.3 1997/05/31 19:16:27 curt
-// Elevator trim added.
-//
-// Revision 1.2 1997/05/23 15:40:33 curt
-// Added GNU copyright headers.
-//
-// Revision 1.1 1997/05/16 15:59:48 curt
-// Initial revision.
-//
+++ /dev/null
-/*******************************************************************************
-
- Header: FGDefs.h
- Author: Jon S. Berndt
- Date started: 02/01/99
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-02/01/99 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGDEFS_H
-#define FGDEFS_H
-
-#define MAX_ENGINES 10
-#define MAX_TANKS 30
-#define GRAVITY 32.174
-#define EARTHRAD 20898908.00 // feet
-#define OMEGAEARTH 7.2685E-3 // rad/sec
-#define EARTHRADSQRD 437882827922500.0
-#define ONESECOND 4.848136811E-6
-#define ECCENT 0.996647186
-#define ECCENTSQRD 0.99330561
-#define INVECCENTSQRD 1.0067395
-#define INVECCENTSQRDM1 0.0067395
-#define EPS 0.081819221
-
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGEngine.cpp
- Author: Jon Berndt
- Date started: 01/21/99
- Called by: FGAircraft
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-See header file.
-
-HISTORY
---------------------------------------------------------------------------------
-01/21/99 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <fstream>
-# else
-# include <fstream.h>
-# endif
-#else
-# include <fstream>
-#endif
-
-#include "FGEngine.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGAtmosphere.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-
-FGEngine::FGEngine(FGFDMExec* fdex, string enginePath, string engineName, int num)
-{
- string fullpath;
- string tag;
-
- FDMExec = fdex;
-
- State = FDMExec->GetState();
- Atmosphere = FDMExec->GetAtmosphere();
- FCS = FDMExec->GetFCS();
- Aircraft = FDMExec->GetAircraft();
- Translation = FDMExec->GetTranslation();
- Rotation = FDMExec->GetRotation();
- Position = FDMExec->GetPosition();
- Auxiliary = FDMExec->GetAuxiliary();
- Output = FDMExec->GetOutput();
-
- Name = engineName;
- fullpath = enginePath + "/" + engineName + ".dat";
- ifstream enginefile(fullpath.c_str());
-
- if (enginefile) {
- enginefile >> tag;
-
- if (tag == "ROCKET") Type = etRocket;
- else if (tag == "PISTON") Type = etPiston;
- else if (tag == "TURBOPROP") Type = etTurboProp;
- else if (tag == "TURBOJET") Type = etTurboJet;
- else Type = etUnknown;
-
- enginefile >> X;
- enginefile >> Y;
- enginefile >> Z;
- enginefile >> SLThrustMax;
- enginefile >> VacThrustMax;
- enginefile >> MaxThrottle;
- enginefile >> MinThrottle;
- enginefile >> SLFuelFlowMax;
- if (Type == 1)
- enginefile >> SLOxiFlowMax;
- enginefile.close();
- } else {
- cerr << "Unable to open engine definition file " << engineName << endl;
- }
-
- EngineNumber = num;
- Thrust = 0.0;
- Starved = Flameout = false;
-}
-
-
-FGEngine::~FGEngine(void)
-{
-}
-
-
-float FGEngine::CalcRocketThrust(void)
-{
- float lastThrust;
-
- Throttle = FCS->GetThrottle(EngineNumber);
- lastThrust = Thrust; // last actual thrust
-
- if (Throttle < MinThrottle || Starved) {
- PctPower = Thrust = 0.0; // desired thrust
- Flameout = true;
- } else {
- PctPower = Throttle / MaxThrottle;
- Thrust = PctPower*((1.0 - Atmosphere->Getrho() / 0.002378)*(VacThrustMax - SLThrustMax) +
- SLThrustMax); // desired thrust
- Flameout = false;
- }
-
- Thrust += 0.8*(Thrust - lastThrust); // actual thrust
-
- return Thrust;
-}
-
-
-float FGEngine::CalcPistonThrust(void)
-{
- return Thrust;
-}
-
-
-float FGEngine::CalcThrust(void)
-{
- switch(Type) {
- case etRocket:
- return CalcRocketThrust();
- // break;
- case etPiston:
- return CalcPistonThrust();
- // break;
- default:
- return 9999.0;
- // break;
- }
-}
-
-float FGEngine::CalcFuelNeed() {
- FuelNeed = SLFuelFlowMax*PctPower;
- return FuelNeed;
-}
-
-
-float FGEngine::CalcOxidizerNeed() {
- OxidizerNeed = SLOxiFlowMax*PctPower;
- return OxidizerNeed;
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGEngine.h
- Author: Jon S. Berndt
- Date started: 01/21/99
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-
-Based on Flightgear code, which is based on LaRCSim. This class simulates
-a generic engine.
-
-HISTORY
---------------------------------------------------------------------------------
-01/21/99 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGEngine_H
-#define FGEngine_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# include STL_STRING
- FG_USING_STD(string);
-#else
-# include <string>
-#endif
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGFDMExec;
-class FGState;
-class FGAtmosphere;
-class FGFCS;
-class FGAircraft;
-class FGTranslation;
-class FGRotation;
-class FGPosition;
-class FGAuxiliary;
-class FGOutput;
-
-class FGEngine
-{
-public:
- FGEngine(FGFDMExec*, string, string, int);
- ~FGEngine(void);
-
- enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet};
-
- float GetThrottle(void) {return Throttle;}
- float GetThrust(void) {return Thrust;}
- bool GetStarved(void) {return Starved;}
- bool GetFlameout(void) {return Flameout;}
- int GetType(void) {return Type;}
- string GetName() {return Name;}
-
- void SetStarved(bool tt) {Starved = tt;}
- void SetStarved(void) {Starved = true;}
-
- float CalcThrust(void);
- float CalcFuelNeed(void);
- float CalcOxidizerNeed(void);
-
-private:
- string Name;
- EngineType Type;
- float X, Y, Z;
- float SLThrustMax;
- float VacThrustMax;
- float SLFuelFlowMax;
- float SLOxiFlowMax;
- float MaxThrottle;
- float MinThrottle;
-
- float Thrust;
- float Throttle;
- float FuelNeed, OxidizerNeed;
- bool Starved;
- bool Flameout;
- float PctPower;
- int EngineNumber;
-
- FGFDMExec* FDMExec;
- FGState* State;
- FGAtmosphere* Atmosphere;
- FGFCS* FCS;
- FGAircraft* Aircraft;
- FGTranslation* Translation;
- FGRotation* Rotation;
- FGPosition* Position;
- FGAuxiliary* Auxiliary;
- FGOutput* Output;
-
-protected:
- float CalcRocketThrust(void);
- float CalcPistonThrust(void);
-
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGFCS.cpp
- Author: Jon Berndt
- Date started: 12/12/98
- Purpose: Model the flight controls
- Called by: FDMExec
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This class models the flight controls for a specific airplane
-
-HISTORY
---------------------------------------------------------------------------------
-12/12/98 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGFCS.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGAtmosphere.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-
-FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
-{
- Name = "FGFCS";
-}
-
-
-FGFCS::~FGFCS(void)
-{
-}
-
-
-bool FGFCS::Run(void)
-{
- if (!FGModel::Run()) {
-
- } else {
- }
- return false;
-}
+++ /dev/null
-/*******************************************************************************
-
- Header: FGGFCS.h
- Author: Jon S. Berndt
- Date started: 12/12/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-12/12/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGFCS_H
-#define FGFCS_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGModel.h"
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-using namespace std;
-
-class FGFCS : public FGModel
-{
-public:
- FGFCS(FGFDMExec*);
- ~FGFCS(void);
-
- bool Run(void);
-
- inline float GetDa(void) {return Da;}
- inline float GetDe(void) {return De;}
- inline float GetDr(void) {return Dr;}
- inline float GetDf(void) {return Df;}
- inline float GetDs(void) {return Ds;}
- inline float GetThrottle(int ii) {return Throttle[ii];}
-
- inline void SetDa(float tt) {Da = tt;}
- inline void SetDe(float tt) {De = tt;}
- inline void SetDr(float tt) {Dr = tt;}
- inline void SetDf(float tt) {Df = tt;}
- inline void SetDs(float tt) {Ds = tt;}
- inline void SetThrottle(int ii, float tt) {Throttle[ii] = tt;}
-
-protected:
-
-private:
- float Da, De, Dr, Df, Ds;
- float Throttle[MAX_ENGINES];
-};
-
-/******************************************************************************/
-#endif
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
-
- Module: FGFDMExec.cpp
- Author: Jon S. Berndt
- Date started: 11/17/98
- Purpose: Schedules and runs the model routines.
- Called by: The GUI.
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-
-This class wraps up the simulation scheduling routines.
-
-HISTORY
---------------------------------------------------------------------------------
-11/17/98 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <iostream>
-# include <ctime>
-# else
-# include <iostream.h>
-# include <time.h>
-# endif
-#else
-# include <iostream>
-# include <ctime>
-#endif
-
-#include "FGFDMExec.h"
-#include "FGState.h"
-#include "FGAtmosphere.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-
-// Constructor
-
-FGFDMExec::FGFDMExec(void)
-{
- FirstModel = 0;
- Error = 0;
- State = 0;
- Atmosphere = 0;
- FCS = 0;
- Aircraft = 0;
- Translation = 0;
- Rotation = 0;
- Position = 0;
- Auxiliary = 0;
- Output = 0;
-
- // Instantiate this FDM Executive's Models
-
- Atmosphere = new FGAtmosphere(this);
- FCS = new FGFCS(this);
- Aircraft = new FGAircraft(this);
- Translation = new FGTranslation(this);
- Rotation = new FGRotation(this);
- Position = new FGPosition(this);
- Auxiliary = new FGAuxiliary(this);
- Output = new FGOutput(this);
-
- State = new FGState(this);
-
- // Initialize models so they can communicate with each other
-
- if (!Atmosphere->InitModel()) {cerr << "Atmosphere model init failed"; Error+=1;}
- if (!FCS->InitModel()) {cerr << "FCS model init failed"; Error+=2;}
- if (!Aircraft->InitModel()) {cerr << "Aircraft model init failed"; Error+=4;}
- if (!Translation->InitModel()){cerr << "Translation model init failed"; Error+=8;}
- if (!Rotation->InitModel()) {cerr << "Rotation model init failed"; Error+=16;}
- if (!Position->InitModel()) {cerr << "Position model init failed"; Error+=32;}
- if (!Auxiliary->InitModel()) {cerr << "Auxiliary model init failed"; Error+=64;}
- if (!Output->InitModel()) {cerr << "Output model init failed"; Error+=128;}
-
- Schedule(Atmosphere, 5);
- Schedule(FCS, 1);
- Schedule(Aircraft, 1);
- Schedule(Rotation, 1);
- Schedule(Translation, 1);
- Schedule(Position, 1);
- Schedule(Auxiliary, 1);
- Schedule(Output, 1);
-
- terminate = false;
- frozen = false;
-}
-
-
-FGFDMExec::~FGFDMExec(void)
-{
-}
-
-
-int FGFDMExec::Schedule(FGModel* model, int rate)
-{
- FGModel* model_iterator;
-
- model_iterator = FirstModel;
-
- if (model_iterator == 0L) { // this is the first model
-
- FirstModel = model;
- FirstModel->NextModel = 0L;
- FirstModel->SetRate(rate);
-
- } else { // subsequent model
-
- while (model_iterator->NextModel != 0L) {
- model_iterator = model_iterator->NextModel;
- }
- model_iterator->NextModel = model;
- model_iterator->NextModel->SetRate(rate);
-
- }
- return 0;
-}
-
-
-bool FGFDMExec::Run(void)
-{
- FGModel* model_iterator;
-
- if (frozen) return true;
-
- model_iterator = FirstModel;
- if (model_iterator == 0L) return false;
-
- while (!model_iterator->Run())
- {
- model_iterator = model_iterator->NextModel;
- if (model_iterator == 0L) break;
- }
-
- State->IncrTime();
-
- return true;
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGFDMExec.h
- Author: Jon Berndt
- Date started: 11/17/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-11/17/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGFDMEXEC_HEADER_H
-#define FGFDMEXEC_HEADER_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGModel.h"
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGState;
-class FGAtmosphere;
-class FGFCS;
-class FGAircraft;
-class FGTranslation;
-class FGRotation;
-class FGPosition;
-class FGAuxiliary;
-class FGOutput;
-
-class FGFDMExec
-{
-public:
- FGFDMExec::FGFDMExec(void);
- FGFDMExec::~FGFDMExec(void);
-
- FGModel* FirstModel;
-
- bool Initialize(void);
- int Schedule(FGModel* model, int rate);
- bool Run(void);
- void Freeze(void) {frozen = true;}
- void Resume(void) {frozen = false;}
-
- inline FGState* GetState(void) {return State;}
- inline FGAtmosphere* GetAtmosphere(void) {return Atmosphere;}
- inline FGFCS* GetFCS(void) {return FCS;}
- inline FGAircraft* GetAircraft(void) {return Aircraft;}
- inline FGTranslation* GetTranslation(void) {return Translation;}
- inline FGRotation* GetRotation(void) {return Rotation;}
- inline FGPosition* GetPosition(void) {return Position;}
- inline FGAuxiliary* GetAuxiliary(void) {return Auxiliary;}
- inline FGOutput* GetOutput(void) {return Output;}
-
-private:
- bool frozen;
- bool terminate;
- int Error;
-
- FGState* State;
- FGAtmosphere* Atmosphere;
- FGFCS* FCS;
- FGAircraft* Aircraft;
- FGTranslation* Translation;
- FGRotation* Rotation;
- FGPosition* Position;
- FGAuxiliary* Auxiliary;
- FGOutput* Output;
-
-protected:
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-#include "FGFDMExec.h"
-#include "FGRotation.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-#include <iostream>
-#include <ctime>
-
-void main(int argc, char** argv)
-{
- FGFDMExec* FDMExec;
-
-// struct timespec short_wait = {0,100000000};
-// struct timespec no_wait = {0,100000000};
-
- if (argc != 3) {
- cout << endl
- << " You must enter the name of a registered aircraft and reset point:"
- << endl << endl << " FDM <aircraft name> <reset file>" << endl;
- exit(0);
- }
-
- FDMExec = new FGFDMExec();
-
- FDMExec->GetAircraft()->LoadAircraft("aircraft", "engine", string(argv[1]));
- FDMExec->GetState()->Reset("aircraft", string(argv[2]));
-
- while (FDMExec->GetState()->Getsim_time() <= 25.0)
- {
-//
-// fake an aileron, rudder and elevator kick here after 20 seconds
-//
-
- if (FDMExec->GetState()->Getsim_time() > 5.0) {
- FDMExec->GetFCS()->SetDe(0.05);
-// FDMExec->GetFCS()->SetDr(0.05);
-// FDMExec->GetFCS()->SetDa(0.05);
- }
-
- FDMExec->Run();
-// nanosleep(&short_wait,&no_wait);
- }
-
- delete FDMExec;
-}
+++ /dev/null
-/*******************************************************************************
-
-Module: FGMatrix.cpp
-Author: Tony Peden [formatted here by JSB]
-Date started: ??
-Purpose: FGMatrix class
-Called by: Various
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-
-
-ARGUMENTS
---------------------------------------------------------------------------------
-
-
-HISTORY
---------------------------------------------------------------------------------
-??/??/?? TP Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include <stdlib.h>
-#include "FGMatrix.h"
-#include <iostream.h>
-#include <iomanip.h>
-#include <fstream.h>
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-#pragma warn -use
-
-/*******************************************************************************
-CONSTANTS
-*******************************************************************************/
-
-
-/*******************************************************************************
-TYPEDEFS
-*******************************************************************************/
-
-
-/*******************************************************************************
-GLOBALS
-*******************************************************************************/
-
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-double** alloc(int rows,int cols)
-{
- double **A;
-
- A = new double *[rows+1];
- if (!A) return NULL;
-
- for (int i=0;i<=rows;i++){
- A[i]=new double[cols+1];
- if (!A[i]) return NULL;
- }
- return A;
-}
-
-
-void dealloc(double **A, int rows, int cols)
-{
- for(int i=0;i<=rows;i++){
- delete[] A[i];
- }
-
- delete[] A;
-}
-
-
-FGMatrix::FGMatrix(unsigned rows, unsigned cols)
-{
- this->rows=rows;
- this->cols=cols;
- keep=false;
- data=alloc(rows,cols);
-}
-
-
-FGMatrix::FGMatrix(const FGMatrix& A)
-{
- data=NULL;
- *this=A;
-}
-
-
-FGMatrix::~FGMatrix(void)
-{
- if (keep == false) {
- dealloc(data,rows,cols);
- rows=cols=0;
- }
-}
-
-
-FGMatrix& FGMatrix::operator=(const FGMatrix& A)
-{
- if (&A != this) {
- if (data != NULL) dealloc(data,rows,cols);
-
- width = A.width;
- prec = A.prec;
- delim = A.delim;
- origin = A.origin;
- rows = A.rows;
- cols = A.cols;
- keep = false;
-
- if (A.keep == true) {
- data = A.data;
- } else {
- data = alloc(rows,cols);
- for (unsigned int i=0; i<=rows; i++) {
- for (unsigned int j=0; j<=cols; j++) {
- data[i][j] = A.data[i][j];
- }
- }
- }
- }
- return *this;
-}
-
-
-double& FGMatrix::operator()(unsigned row, unsigned col)
-{
- return data[row][col];
-}
-
-
-unsigned FGMatrix::Rows(void) const
-{
- return rows;
-}
-
-
-unsigned FGMatrix::Cols(void) const
-{
- return cols;
-}
-
-
-void FGMatrix::SetOParams(char delim,int width,int prec,int origin)
-{
- FGMatrix::delim=delim;
- FGMatrix::width=width;
- FGMatrix::prec=prec;
- FGMatrix::origin=origin;
-}
-
-
-void FGMatrix::InitMatrix(double value)
-{
- if (data) {
- for (unsigned int i=0;i<=rows;i++) {
- for (unsigned int j=0;j<=cols;j++) {
- operator()(i,j) = value;
- }
- }
- }
-}
-
-
-void FGMatrix::InitMatrix(void)
-{
- this->InitMatrix(0);
-}
-
-
-FGMatrix operator-(FGMatrix& A, FGMatrix& B)
-{
- if ((A.Rows() != B.Rows()) || (A.Cols() != B.Cols())) {
- cout << endl << "FGMatrix::operator-" << endl << '\t';
- cout << "Subtraction not defined for matrices of different sizes";
- cout << endl;
- exit(1);
- }
-
- FGMatrix Diff(A.Rows(),A.Cols());
- Diff.keep=true;
- for (unsigned int i=1;i<=A.Rows();i++) {
- for (unsigned int j=1;j<=A.Cols();j++) {
- Diff(i,j)=A(i,j)-B(i,j);
- }
- }
- return Diff;
-}
-
-
-void operator-=(FGMatrix &A,FGMatrix &B)
-{
- if ((A.Rows() != B.Rows()) || (A.Cols() != B.Cols())) {
- cout << endl << "FGMatrix::operator-" << endl << '\t';
- cout << "Subtraction not defined for matrices of different sizes";
- cout << endl;
- exit(1);
- }
-
- for (unsigned int i=1;i<=A.Rows();i++) {
- for (unsigned int j=1;j<=A.Cols();j++) {
- A(i,j)-=B(i,j);
- }
- }
-}
-
-
-FGMatrix operator+(FGMatrix& A, FGMatrix& B)
-{
- if ((A.Rows() != B.Rows()) || (A.Cols() != B.Cols())) {
- cout << endl << "FGMatrix::operator+" << endl << '\t';
- cout << "Addition not defined for matrices of different sizes";
- cout << endl;
- exit(1);
- }
-
- FGMatrix Sum(A.Rows(),A.Cols());
- Sum.keep = true;
- for (unsigned int i=1;i<=A.Rows();i++) {
- for (unsigned int j=1;j<=A.Cols();j++) {
- Sum(i,j)=A(i,j)+B(i,j);
- }
- }
- return Sum;
-}
-
-
-void operator+=(FGMatrix &A,FGMatrix &B)
-{
- if ((A.Rows() != B.Rows()) || (A.Cols() != B.Cols())) {
- cout << endl << "FGMatrix::operator+" << endl << '\t';
- cout << "Addition not defined for matrices of different sizes";
- cout << endl;
- exit(1);
- }
- for (unsigned int i=1;i<=A.Rows();i++) {
- for (unsigned int j=1;j<=A.Cols();j++) {
- A(i,j)+=B(i,j);
- }
- }
-}
-
-
-FGMatrix operator*(double scalar,FGMatrix &A)
-{
- FGMatrix Product(A.Rows(),A.Cols());
- Product.keep = true;
- for (unsigned int i=1;i<=A.Rows();i++) {
- for (unsigned int j=1;j<=A.Cols();j++) {
- Product(i,j) = scalar*A(i,j);
- }
- }
- return Product;
-}
-
-
-void operator*=(FGMatrix &A,double scalar)
-{
- for (unsigned int i=1;i<=A.Rows();i++) {
- for (unsigned int j=1;j<=A.Cols();j++) {
- A(i,j)*=scalar;
- }
- }
-}
-
-
-FGMatrix operator*(FGMatrix &Left, FGMatrix &Right)
-{
- if (Left.Cols() != Right.Rows()) {
- cout << endl << "FGMatrix::operator*" << endl << '\t';
- cout << "The number of rows in the right matrix must match the number";
- cout << endl << '\t' << "of columns in the left." << endl;
- cout << '\t' << "Multiplication not defined." << endl;
- exit(1);
- }
-
- FGMatrix Product(Left.Rows(),Right.Cols());
- Product.keep = true;
- for (unsigned int i=1;i<=Left.Rows();i++) {
- for (unsigned int j=1;j<=Right.Cols();j++) {
- Product(i,j) = 0;
- for (unsigned int k=1;k<=Left.Cols();k++) {
- Product(i,j)+=Left(i,k)*Right(k,j);
- }
- }
- }
- return Product;
-}
-
-
-void operator*=(FGMatrix &Left,FGMatrix &Right)
-{
- if (Left.Cols() != Right.Rows()) {
- cout << endl << "FGMatrix::operator*" << endl << '\t';
- cout << "The number of rows in the right matrix must match the number";
- cout << endl << '\t' << "of columns in the left." << endl;
- cout << '\t' << "Multiplication not defined." << endl;
- exit(1);
- }
-
- double **prod;
-
- prod=alloc(Left.Rows(),Right.Cols());
- for (unsigned int i=1;i<=Left.Rows();i++) {
- for (unsigned int j=1;j<=Right.Cols();j++) {
- prod[i][j] = 0;
- for (unsigned int k=1;k<=Left.Cols();k++) {
- prod[i][j]+=Left(i,k)*Right(k,j);
- }
- }
- }
- dealloc(Left.data,Left.Rows(),Left.Cols());
- Left.data=prod;
- Left.cols=Right.cols;
-}
-
-
-FGMatrix operator/(FGMatrix& A, double scalar)
-{
- FGMatrix Quot(A.Rows(),A.Cols());
- A.keep = true;
- for (unsigned int i=1;i<=A.Rows();i++) {
- for (unsigned int j=1;j<=A.Cols();j++) {
- Quot(i,j)=A(i,j)/scalar;
- }
- }
- return Quot;
-}
-
-
-void operator/=(FGMatrix &A,double scalar)
-{
- for (unsigned int i=1;i<=A.Rows();i++) {
- for (unsigned int j=1;j<=A.Cols();j++) {
- A(i,j)/=scalar;
- }
- }
-}
-
-
-void FGMatrix::T(void)
-{
- if (rows==cols)
- TransposeSquare();
- else
- TransposeNonSquare();
-}
-
-
-void FGMatrix::TransposeSquare(void)
-{
- for (unsigned int i=1;i<=rows;i++) {
- for (unsigned int j=i+1;j<=cols;j++) {
- double tmp=data[i][j];
- data[i][j]=data[j][i];
- data[j][i]=tmp;
- }
- }
-}
-
-
-void FGMatrix::TransposeNonSquare(void)
-{
- double **tran;
-
- tran=alloc(rows,cols);
- for (unsigned int i=1;i<=rows;i++) {
- for (unsigned int j=1;j<=cols;j++) {
- tran[j][i]=data[i][j];
- }
- }
- dealloc(data,rows,cols);
-
- data=tran;
- unsigned m=rows;
- rows=cols;
- cols=m;
-}
-
-
-FGColumnVector::FGColumnVector(void):FGMatrix(3,1) { }
-FGColumnVector::FGColumnVector(int m):FGMatrix(m,1) { }
-FGColumnVector::FGColumnVector(FGColumnVector& b):FGMatrix(b) { }
-FGColumnVector::~FGColumnVector() { }
-double& FGColumnVector::operator()(int m)
-{
- return FGMatrix::operator()(m,1);
-}
-
+++ /dev/null
-/*******************************************************************************
-
-Header: FGMatrix.h
-Author: Tony Peden [formatted here by Jon Berndt]
-Date started: Unknown
-
-HISTORY
---------------------------------------------------------------------------------
-??/??/?? TP Created
-
-/*******************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGMATRIX_H
-#define FGMATRIX_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include <stdlib.h>
-#include <iostream.h>
-#include <fstream.h>
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-
-/*******************************************************************************
-CONSTANTS
-*******************************************************************************/
-
-
-/*******************************************************************************
-TYPEDEFS
-*******************************************************************************/
-
-
-/*******************************************************************************
-GLOBALS
-*******************************************************************************/
-
-class FGMatrix
-{
-private:
- double **data;
- unsigned rows,cols;
- bool keep;
- char delim;
- int width,prec,origin;
- void TransposeSquare(void);
- void TransposeNonSquare(void);
-
-public:
- FGMatrix(unsigned rows, unsigned cols);
- FGMatrix(const FGMatrix& A);
- ~FGMatrix(void);
-
- FGMatrix& FGMatrix::operator=(const FGMatrix& A);
- double& FGMatrix::operator()(unsigned row, unsigned col);
-
- unsigned FGMatrix::Rows(void) const;
- unsigned FGMatrix::Cols(void) const;
-
- void FGMatrix::T(void);
- void InitMatrix(void);
- void InitMatrix(double value);
-
- friend FGMatrix operator-(FGMatrix& A, FGMatrix& B);
- friend FGMatrix operator+(FGMatrix& A, FGMatrix& B);
- friend FGMatrix operator*(double scalar,FGMatrix& A);
- friend FGMatrix operator*(FGMatrix& Left, FGMatrix& Right);
- friend FGMatrix operator/(FGMatrix& A, double scalar);
-
- friend void operator-=(FGMatrix &A,FGMatrix &B);
- friend void operator+=(FGMatrix &A,FGMatrix &B);
- friend void operator*=(FGMatrix &A,FGMatrix &B);
- friend void operator*=(FGMatrix &A,double scalar);
- friend void operator/=(FGMatrix &A,double scalar);
-
- void SetOParams(char delim,int width,int prec, int origin=0);
-};
-
-class FGColumnVector : public FGMatrix
-{
-public:
- FGColumnVector(void);
- FGColumnVector(int m);
- FGColumnVector(FGColumnVector& b);
- ~FGColumnVector();
-
- double& operator()(int m);
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGModel.cpp
- Author: Jon Berndt
- Date started: 11/11/98
- Purpose: Base class for all models
- Called by: FGSimExec, et. al.
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This base class for the FGAero, FGRotational, etc. classes defines methods
-common to all models.
-
-HISTORY
---------------------------------------------------------------------------------
-11/11/98 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGModel.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGAtmosphere.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-FGModel::FGModel(FGFDMExec* fdmex)
-{
- FDMExec = fdmex;
- NextModel = 0L;
-
- State = 0;
- Atmosphere = 0;
- FCS = 0;
- Aircraft = 0;
- Translation = 0;
- Rotation = 0;
- Position = 0;
- Auxiliary = 0;
- Output = 0;
-
- exe_ctr = 1;
-}
-
-
-FGModel::~FGModel()
-{
-}
-
-
-bool FGModel::InitModel(void)
-{
- State = FDMExec->GetState();
- Atmosphere = FDMExec->GetAtmosphere();
- FCS = FDMExec->GetFCS();
- Aircraft = FDMExec->GetAircraft();
- Translation = FDMExec->GetTranslation();
- Rotation = FDMExec->GetRotation();
- Position = FDMExec->GetPosition();
- Auxiliary = FDMExec->GetAuxiliary();
- Output = FDMExec->GetOutput();
-
- if (!State ||
- !Atmosphere ||
- !FCS ||
- !Aircraft ||
- !Translation ||
- !Rotation ||
- !Position ||
- !Auxiliary ||
- !Output) return(false);
- else return(true);
-}
-
-
-bool FGModel::Run()
-{
- if (exe_ctr == 1) {
- if (exe_ctr++ >= rate) exe_ctr = 1;
- return false;
- } else {
- if (exe_ctr++ >= rate) exe_ctr = 1;
- return true;
- }
-}
-
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGModel.h
- Author: Jon Berndt
- Date started: 11/21/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-11/22/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGMODEL_H
-#define FGMODEL_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGDefs.h"
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# include STL_STRING
-# ifdef FG_HAVE_STD_INCLUDES
-# include <iostream>
-# else
-# include <iostream.h>
-# endif
- FG_USING_STD(string);
-#else
-# include <string>
-# include <iostream>
-#endif
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGFDMExec;
-class FGState;
-class FGAtmosphere;
-class FGFCS;
-class FGAircraft;
-class FGTranslation;
-class FGRotation;
-class FGPosition;
-class FGAuxiliary;
-class FGOutput;
-
-class FGModel
-{
-public:
- FGModel(FGFDMExec*);
- ~FGModel(void);
-
- FGModel* NextModel;
- string Name;
- virtual bool Run(void);
- virtual bool InitModel(void);
- void SetRate(int tt) {rate = tt;};
-
-protected:
- int exe_ctr;
- int rate;
-
- FGFDMExec* FDMExec;
- FGState* State;
- FGAtmosphere* Atmosphere;
- FGFCS* FCS;
- FGAircraft* Aircraft;
- FGTranslation* Translation;
- FGRotation* Rotation;
- FGPosition* Position;
- FGAuxiliary* Auxiliary;
- FGOutput* Output;
-
-private:
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGOutput.cpp
- Author: Jon Berndt
- Date started: 12/02/98
- Purpose: Manage output of sim parameters to file or stdout
- Called by: FGSimExec
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This is the place where you create output routines to dump data for perusal
-later. Some machines may not support the ncurses console output. Borland is one
-of those environments which does not, so the ncurses stuff is commented out.
-
-HISTORY
---------------------------------------------------------------------------------
-12/02/98 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <iostream>
-# else
-# include <iostream.h>
-# endif
-#else
-# include <iostream>
-#endif
-
-#ifdef HAVE_CURSES
- #include <ncurses.h>
-#endif
-
-#include "FGOutput.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGAtmosphere.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
-{
- Name = "FGOutput";
- FirstPass = true;
-#ifdef HAVE_CURSES
- initscr();
- cbreak();
- noecho();
-#endif
-}
-
-
-FGOutput::~FGOutput(void)
-{
-}
-
-
-bool FGOutput::Run(void)
-{
- if (!FGModel::Run()) {
- DelimitedOutput();
-// ConsoleOutput();
- } else {
- }
- return false;
-}
-
-
-void FGOutput::ConsoleOutput(void)
-{
-#ifdef HAVE_CURSES
- string buffer;
-
- clear();
- move(1,1); insstr("Quaternions");
- move(2,5); insstr("Q0");
- move(2,16); insstr("Q1");
- move(2,27); insstr("Q2");
- move(2,38); insstr("Q3");
-
- move(3,1); buffer = Rotation->GetQ0(); insstr(buffer.c_str());
- move(3,12); buffer = Rotation->GetQ1(); insstr(buffer.c_str());
- move(3,23); buffer = Rotation->GetQ2(); insstr(buffer.c_str());
- move(3,34); buffer = Rotation->GetQ3(); insstr(buffer.c_str());
-
- move(0,0); insstr("Time: ");
- move(0,6); insstr(gcvt(State->Getsim_time(),6,buffer));
-
- move(2,46); insstr("Phi");
- move(2,55); insstr("Tht");
- move(2,64); insstr("Psi");
-
- move(3,45); buffer = Rotation->Getphi(); insstr(buffer.c_str());
- move(3,54); buffer = Rotation->Gettht(); insstr(buffer.c_str());
- move(3,63); buffer = Rotation->Getpsi(); insstr(buffer.c_str());
-
- move(5,47); insstr("U");
- move(5,56); insstr("V");
- move(5,65); insstr("W");
-
- move(6,45); buffer = Translation->GetU(); insstr(buffer.c_str());
- move(6,54); buffer = Translation->GetV(); insstr(buffer.c_str());
- move(6,63); buffer = Translation->GetW(); insstr(buffer.c_str());
-
- move(8,47); insstr("Fx");
- move(8,56); insstr("Fy");
- move(8,65); insstr("Fz");
-
- move(9,45); buffer = Aircraft->GetFx(); insstr(buffer.c_str());
- move(9,54); buffer = Aircraft->GetFy(); insstr(buffer.c_str());
- move(9,63); buffer = Aircraft->GetFz(); insstr(buffer.c_str());
-
- move(11,47); insstr("Fn");
- move(11,56); insstr("Fe");
- move(11,65); insstr("Fd");
-
- move(12,45); buffer = Position->GetFn(); insstr(buffer.c_str());
- move(12,54); buffer = Position->GetFe(); insstr(buffer.c_str());
- move(12,63); buffer = Position->GetFd(); insstr(buffer.c_str());
-
- move(14,47); insstr("Latitude");
- move(14,57); insstr("Longitude");
- move(14,67); insstr("Altitude");
-
- move(15,47); buffer = State->Getlatitude(); insstr(buffer.c_str());
- move(15,57); buffer = State->Getlongitude(); insstr(buffer.c_str());
- move(15,67); buffer = State->Geth(); insstr(buffer.c_str());
-
- refresh();
-
- move(LINES-1,1);
- refresh();
-#endif
-}
-
-
-void FGOutput::DelimitedOutput(void)
-{
- if (FirstPass) {
- cout << "Time,";
- cout << "Altitude,";
- cout << "Phi,";
- cout << "Tht,";
- cout << "Psi,";
- cout << "Rho,";
- cout << "Vtotal,";
- cout << "U,";
- cout << "V,";
- cout << "W,";
- cout << "Vn,";
- cout << "Ve,";
- cout << "Vd,";
- cout << "Udot,";
- cout << "Vdot,";
- cout << "Wdot,";
- cout << "Fx,";
- cout << "Fy,";
- cout << "Fz,";
- cout << "Latitude,";
- cout << "Longitude,";
- cout << "QBar,";
- cout << "Alpha,";
- cout << "L,";
- cout << "M,";
- cout << "N";
- cout << endl;
- FirstPass = false;
- } else {
- cout << State->Getsim_time() << ",";
- cout << State->Geth() << ",";
- cout << Rotation->Getphi() << ",";
- cout << Rotation->Gettht() << ",";
- cout << Rotation->Getpsi() << ",";
- cout << Atmosphere->Getrho() << ",";
- cout << State->GetVt() << ",";
- cout << Translation->GetU() << ",";
- cout << Translation->GetV() << ",";
- cout << Translation->GetW() << ",";
- cout << Position->GetVn() << ",";
- cout << Position->GetVe() << ",";
- cout << Position->GetVd() << ",";
- cout << Translation->GetUdot() << ",";
- cout << Translation->GetVdot() << ",";
- cout << Translation->GetWdot() << ",";
- cout << Aircraft->GetFx() << ",";
- cout << Aircraft->GetFy() << ",";
- cout << Aircraft->GetFz() << ",";
- cout << State->Getlatitude() << ",";
- cout << State->Getlongitude() << ",";
- cout << State->Getqbar() << ",";
- cout << Translation->Getalpha() << ",";
- cout << Aircraft->GetL() << ",";
- cout << Aircraft->GetM() << ",";
- cout << Aircraft->GetN() << "";
- cout << endl;
- }
-}
+++ /dev/null
-/*******************************************************************************
-
- Header: FGOutput.h
- Author: Jon Berndt
- Date started: 12/2/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-12/02/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGOUTPUT_H
-#define FGOUTPUT_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGModel.h"
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGOutput : public FGModel
-{
-public:
- FGOutput(FGFDMExec*);
- ~FGOutput(void);
-
- bool Run(void);
-
- void ConsoleOutput(void);
- void DelimitedOutput(void);
-
-protected:
-
-private:
- bool FirstPass;
-};
-
-/******************************************************************************/
-#endif
-
+++ /dev/null
-/*******************************************************************************
-
- Module: FGPosition.cpp
- Author: Jon S. Berndt
- Date started: 01/05/99
- Purpose: Integrate the EOM to determine instantaneous position
- Called by: FGFDMExec
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This class encapsulates the integration of rates and accelerations to get the
-current position of the aircraft.
-
-HISTORY
---------------------------------------------------------------------------------
-01/05/99 JSB Created
-
-********************************************************************************
-COMMENTS, REFERENCES, and NOTES
-********************************************************************************
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
- Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
- School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
- JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
- NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
- Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
- 1982 ISBN 0-471-08936-2
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <cmath>
-# else
-# include <math.h>
-# endif
-#else
-# include <cmath>
-#endif
-
-#include "FGPosition.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-
-FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex)
-{
- Name = "FGPosition";
- AccelN = AccelE = AccelD = 0.0;
- LongitudeDot = LatitudeDot = RadiusDot = 0.0;
-}
-
-
-FGPosition::~FGPosition(void)
-{
-}
-
-
-bool FGPosition:: Run(void)
-{
- float tanLat, cosLat;
-
- if (!FGModel::Run()) {
- GetState();
- T[1][1] = Q0*Q0 + Q1*Q1 - Q2*Q2 - Q3*Q3; // Page A-11
- T[1][2] = 2*(Q1*Q2 + Q0*Q3); // From
- T[1][3] = 2*(Q1*Q3 - Q0*Q2); // Reference [2]
- T[2][1] = 2*(Q1*Q2 - Q0*Q3);
- T[2][2] = Q0*Q0 - Q1*Q1 + Q2*Q2 - Q3*Q3;
- T[2][3] = 2*(Q2*Q3 + Q0*Q1);
- T[3][1] = 2*(Q1*Q3 + Q0*Q2);
- T[3][2] = 2*(Q2*Q3 - Q0*Q1);
- T[3][3] = Q0*Q0 - Q1*Q1 - Q2*Q2 + Q3*Q3;
-
- Fn = T[1][1]*Fx + T[2][1]*Fy + T[3][1]*Fz; // Eqn. 3.5
- Fe = T[1][2]*Fx + T[2][2]*Fy + T[3][2]*Fz; // From
- Fd = T[1][3]*Fx + T[2][3]*Fy + T[3][3]*Fz; // Reference [3]
-
- tanLat = tan(Latitude); // I made this up
- cosLat = cos(Latitude);
-
- lastAccelN = AccelN;
- lastAccelE = AccelE;
- lastAccelD = AccelD;
-
- Vn = T[1][1]*U + T[2][1]*V + T[3][1]*W;
- Ve = T[1][2]*U + T[2][2]*V + T[3][2]*W;
- Vd = T[1][3]*U + T[2][3]*V + T[3][3]*W;
-
- AccelN = invMass * Fn + invRadius * (Vn*Vd - Ve*Ve*tanLat); // Eqn. 3.6
- AccelE = invMass * Fe + invRadius * (Ve*Vd + Vn*Ve*tanLat); // From
- AccelD = invMass * Fd - invRadius * (Vn*Vn + Ve*Ve); // Reference [3]
-
- Vn += 0.5*dt*rate*(3.0*AccelN - lastAccelN); // Eqn. 3.7
- Ve += 0.5*dt*rate*(3.0*AccelE - lastAccelE); // From
- Vd += 0.5*dt*rate*(3.0*AccelD - lastAccelD); // Reference [3]
-
- Vee = Ve - OMEGAEARTH * (Radius) * cosLat; // From Eq. 3.8
- // Reference [3]
- lastLatitudeDot = LatitudeDot;
- lastLongitudeDot = LongitudeDot;
- lastRadiusDot = RadiusDot;
-
- if (cosLat != 0) LongitudeDot = Ve / (Radius * cosLat);
- LatitudeDot = Vn * invRadius;
- RadiusDot = -Vd;
-
- Longitude += 0.5*dt*rate*(LongitudeDot + lastLongitudeDot);
- Latitude += 0.5*dt*rate*(LatitudeDot + lastLatitudeDot);
- Radius += 0.5*dt*rate*(RadiusDot + lastRadiusDot);
-
- PutState();
- return false;
- } else {
- return true;
- }
-}
-
-
-void FGPosition::GetState(void)
-{
- dt = State->Getdt();
-
- Q0 = Rotation->GetQ0();
- Q1 = Rotation->GetQ1();
- Q2 = Rotation->GetQ2();
- Q3 = Rotation->GetQ3();
-
- Fx = Aircraft->GetFx();
- Fy = Aircraft->GetFy();
- Fz = Aircraft->GetFz();
-
- U = Translation->GetU();
- V = Translation->GetV();
- W = Translation->GetW();
-
- Latitude = State->Getlatitude();
- Longitude = State->Getlongitude();
-
- invMass = 1.0 / Aircraft->GetMass();
- invRadius = 1.0 / (State->Geth() + EARTHRAD);
- Radius = State->Geth() + EARTHRAD;
-}
-
-
-void FGPosition::PutState(void)
-{
- State->Setlatitude(Latitude);
- State->Setlongitude(Longitude);
- State->Seth(Radius - EARTHRAD);
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGPosition.h
- Author: Jon S. Berndt
- Date started: 1/5/99
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-01/05/99 JSB Created
-
-********************************************************************************
-COMMENTS, REFERENCES, and NOTES
-********************************************************************************
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGPOSITION_H
-#define FGPOSITION_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-#include "FGModel.h"
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGPosition : public FGModel
-{
-public:
- FGPosition(FGFDMExec*);
- ~FGPosition(void);
-
- inline float GetFn(void) {return Fn;}
- inline float GetFe(void) {return Fe;}
- inline float GetFd(void) {return Fd;}
-
- inline float GetVn(void) {return Vn;}
- inline float GetVe(void) {return Ve;}
- inline float GetVd(void) {return Vd;}
-
- inline float GetT(int r, int c) {return T[r][c];}
- inline void SetT(float t1, float t2, float t3, float t4, float t5, float t6,
- float t7, float t8, float t9)
- {T[1][1]=t1; T[1][2]=t2 ;T[1][3]=t3;
- T[2][1]=t4; T[2][2]=t5 ;T[2][3]=t6;
- T[3][1]=t7; T[3][2]=t8 ;T[3][3]=t9;}
-
- bool Run(void);
-
-protected:
-
-private:
- float T[4][4];
- float Q0, Q1, Q2, Q3;
- float Fn, Fe, Fd;
- float Fx, Fy, Fz;
- float U, V, W;
- float Vn, Ve, Vd, Vee;
- float invMass, invRadius;
- float Radius;
- float AccelN, AccelE, AccelD;
- float lastAccelN, lastAccelE, lastAccelD;
- float LatitudeDot, LongitudeDot, RadiusDot;
- float lastLatitudeDot, lastLongitudeDot, lastRadiusDot;
- float Longitude, Latitude;
- float dt;
-
- void GetState(void);
- void PutState(void);
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGRotation.cpp
- Author: Jon Berndt
- Date started: 12/02/98
- Purpose: Integrates the rotational EOM
- Called by: FGFDMExec
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This class integrates the rotational EOM.
-
-HISTORY
---------------------------------------------------------------------------------
-12/02/98 JSB Created
-
-********************************************************************************
-COMMENTS, REFERENCES, and NOTES
-********************************************************************************
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
- Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
- School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
- JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
- NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
- Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
- 1982 ISBN 0-471-08936-2
-
- The order of rotations used in this class corresponds to a 3-2-1 sequence,
- or Y-P-R, or Z-Y-X, if you prefer.
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGRotation.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-
-FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex)
-{
- Name = "FGRotation";
- Q0dot = Q1dot = Q2dot = Q3dot = 0.0;
- Pdot = Qdot = Rdot = 0.0;
-}
-
-
-FGRotation::~FGRotation(void)
-{
-}
-
-
-bool FGRotation::Run(void)
-{
- float L2, N1, iQtot, sum;
-
- if (!FGModel::Run()) {
- GetState();
-
- lastPdot = Pdot;
- lastQdot = Qdot;
- lastRdot = Rdot;
-
- L2 = L + Ixz*P*Q - (Izz-Iyy)*R*Q;
- N1 = N - (Iyy-Ixx)*P*Q - Ixz*R*Q;
-
- Pdot = (L2*Izz - N1*Ixz) / (Ixx*Izz - Ixz*Ixz);
- Qdot = (M - (Ixx-Izz)*P*R - Ixz*(P*P - R*R))/Iyy;
- Rdot = (N1*Ixx + L2*Ixz) / (Ixx*Izz - Ixz*Ixz);
-
- P += dt*rate*(lastPdot + Pdot)/2.0;
- Q += dt*rate*(lastQdot + Qdot)/2.0;
- R += dt*rate*(lastRdot + Rdot)/2.0;
-
- lastQ0dot = Q0dot;
- lastQ1dot = Q1dot;
- lastQ2dot = Q2dot;
- lastQ3dot = Q3dot;
-
- Q0dot = -0.5*(Q1*P + Q2*Q + Q3*R);
- Q1dot = 0.5*(Q0*P + Q2*R - Q3*Q);
- Q2dot = 0.5*(Q0*Q + Q3*P - Q1*R);
- Q3dot = 0.5*(Q0*R + Q1*Q - Q2*P);
-
- Q0 += 0.5*dt*rate*(lastQ0dot + Q0dot);
- Q1 += 0.5*dt*rate*(lastQ1dot + Q1dot);
- Q2 += 0.5*dt*rate*(lastQ2dot + Q2dot);
- Q3 += 0.5*dt*rate*(lastQ3dot + Q3dot);
-
- sum = Q0*Q0 + Q1*Q1 + Q2*Q2 + Q3*Q3;
-
- iQtot = 1.0 / sqrt(sum);
-
- Q0 *= iQtot;
- Q1 *= iQtot;
- Q2 *= iQtot;
- Q3 *= iQtot;
-
- if (T[3][3] == 0)
- phi = 0.0;
- else
- phi = atan2(T[2][3], T[3][3]);
-
- tht = asin(-T[1][3]);
-
- if (T[1][1] == 0.0)
- psi = 0.0;
- else
- psi = atan2(T[1][2], T[1][1]);
-
- if (psi < 0.0) psi += 2*M_PI;
-
- PutState();
- } else {
- }
- return false;
-}
-
-
-void FGRotation::GetState(void)
-{
- dt = State->Getdt();
-
- L = Aircraft->GetL();
- M = Aircraft->GetM();
- N = Aircraft->GetN();
-
- Ixx = Aircraft->GetIxx();
- Iyy = Aircraft->GetIyy();
- Izz = Aircraft->GetIzz();
- Ixz = Aircraft->GetIxz();
-
- for (int r=1;r<=3;r++)
- for (int c=1;c<=3;c++)
- T[r][c] = Position->GetT(r,c);
-}
-
-
-void FGRotation::PutState(void)
-{
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGRotation.h
- Author: Jon Berndt
- Date started: 12/02/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-12/02/98 JSB Created
-
-********************************************************************************
-COMMENTS, REFERENCES, and NOTES
-********************************************************************************
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
- Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
- School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
- JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
- NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
- Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
- 1982 ISBN 0-471-08936-2
-
- The order of rotations used in this class corresponds to a 3-2-1 sequence,
- or Y-P-R, or Z-Y-X, if you prefer.
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGROTATION_H
-#define FGROTATION_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <cmath>
-# else
-# include <math.h>
-# endif
-#else
-# include <cmath>
-#endif
-
-#include "FGModel.h"
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGRotation : public FGModel
-{
-public:
- FGRotation(FGFDMExec*);
- ~FGRotation(void);
-
- bool Run(void);
-
- inline float GetP(void) {return P;}
- inline float GetQ(void) {return Q;}
- inline float GetR(void) {return R;}
-
- inline float GetPdot(void) {return Pdot;}
- inline float GetQdot(void) {return Qdot;}
- inline float GetRdot(void) {return Rdot;}
-
- inline float Getphi(void) {return phi;}
- inline float Gettht(void) {return tht;}
- inline float Getpsi(void) {return psi;}
-
- inline float GetQ0(void) {return Q0;}
- inline float GetQ1(void) {return Q1;}
- inline float GetQ2(void) {return Q2;}
- inline float GetQ3(void) {return Q3;}
-
- inline void SetP(float tt) {P = tt;}
- inline void SetQ(float tt) {Q = tt;}
- inline void SetR(float tt) {R = tt;}
-
- inline void SetPQR(float t1, float t2, float t3) {P=t1;
- Q=t2;
- R=t3;}
-
- inline void Setphi(float tt) {phi = tt;}
- inline void Settht(float tt) {tht = tt;}
- inline void Setpsi(float tt) {psi = tt;}
-
- inline void SetEuler(float t1, float t2, float t3) {phi=t1;
- tht=t2;
- psi=t3;}
-
- inline void SetQ0123(float t1, float t2, float t3, float t4) {Q0=t1;
- Q1=t2;
- Q2=t3;
- Q3=t4;}
-
-protected:
-
-private:
- float P, Q, R;
- float L, M, N;
- float Ixx, Iyy, Izz, Ixz;
- float Q0, Q1, Q2, Q3;
- float phi, tht, psi;
- float Pdot, Qdot, Rdot;
- float Q0dot, Q1dot, Q2dot, Q3dot;
- float lastPdot, lastQdot, lastRdot;
- float lastQ0dot, lastQ1dot, lastQ2dot, lastQ3dot;
- float dt;
- float T[4][4];
-
- void GetState(void);
- void PutState(void);
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGState.cpp
- Author: Jon Berndt
- Date started: 11/17/98
- Called by: FGFDMExec and accessed by all models.
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-See header file.
-
-HISTORY
---------------------------------------------------------------------------------
-11/17/98 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <cmath>
-# else
-# include <math.h>
-# endif
-#else
-# include <cmath>
-#endif
-
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGAtmosphere.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-
-FGState::FGState(FGFDMExec* fdex)
-{
- FDMExec = fdex;
-
- Vt = 0.0;
- latitude = longitude = 0.0;
- adot = bdot = 0.0;
- h = 0.0;
- a = 1000.0;
- qbar = 0.0;
- sim_time = dt = 0.1;
-}
-
-
-FGState::~FGState(void)
-{
-}
-
-
-bool FGState::Reset(string path, string fname)
-{
- string resetDef;
- float U, V, W;
- float phi, tht, psi;
- float alpha, beta, gamma;
- float Q0, Q1, Q2, Q3;
- float T[4][4];
-
- resetDef = path + "/" + FDMExec->GetAircraft()->GetAircraftName() + "/" + fname;
-
- ifstream resetfile(resetDef.c_str());
-
- if (resetfile) {
- resetfile >> U;
- resetfile >> V;
- resetfile >> W;
- resetfile >> latitude;
- resetfile >> longitude;
- resetfile >> phi;
- resetfile >> tht;
- resetfile >> psi;
- resetfile >> h;
- resetfile.close();
-
-// Change all angular measurements from degrees (as in config file) to radians
-
- gamma = 0.0;
- if (W != 0.0)
- alpha = U*U > 0.0 ? atan2(W, U) : 0.0;
- else
- alpha = 0.0;
- if (V != 0.0)
- beta = U*U+W*W > 0.0 ? atan2(V, (fabs(U)/U)*sqrt(U*U + W*W)) : 0.0;
- else
- beta = 0.0;
-
- latitude *= M_PI / 180.0;
- longitude *= M_PI / 180.0;
- phi *= M_PI / 180.0;
- tht *= M_PI / 180.0;
- psi *= M_PI / 180.0;
-
- FDMExec->GetTranslation()->SetUVW(U, V, W);
- FDMExec->GetRotation()->SetEuler(phi, tht, psi);
- FDMExec->GetTranslation()->SetABG(alpha, beta, gamma);
-
- Vt = sqrt(U*U + V*V + W*W);
- qbar = 0.5*(U*U + V*V + W*W)*FDMExec->GetAtmosphere()->CalcRho(h);
-
- Q0 = sin(psi*0.5)*sin(tht*0.5)*sin(phi*0.5) + cos(psi*0.5)*cos(tht*0.5)*cos(phi*0.5);
- Q1 = -sin(psi*0.5)*sin(tht*0.5)*cos(phi*0.5) + cos(psi*0.5)*cos(tht*0.5)*sin(phi*0.5);
- Q2 = sin(psi*0.5)*cos(tht*0.5)*sin(phi*0.5) + cos(psi*0.5)*sin(tht*0.5)*cos(phi*0.5);
- Q3 = sin(psi*0.5)*cos(tht*0.5)*cos(phi*0.5) - cos(psi*0.5)*sin(tht*0.5)*sin(phi*0.5);
-
- FDMExec->GetRotation()->SetQ0123(Q0, Q1, Q2, Q3);
-
- T[1][1] = Q0*Q0 + Q1*Q1 - Q2*Q2 - Q3*Q3;
- T[1][2] = 2*(Q1*Q2 + Q0*Q3);
- T[1][3] = 2*(Q1*Q3 - Q0*Q2);
- T[2][1] = 2*(Q1*Q2 - Q0*Q3);
- T[2][2] = Q0*Q0 - Q1*Q1 + Q2*Q2 - Q3*Q3;
- T[2][3] = 2*(Q2*Q3 + Q0*Q1);
- T[3][1] = 2*(Q1*Q3 + Q0*Q2);
- T[3][2] = 2*(Q2*Q3 - Q0*Q1);
- T[3][3] = Q0*Q0 - Q1*Q1 - Q2*Q2 + Q3*Q3;
-
- FDMExec->GetPosition()->SetT(T[1][1], T[1][2], T[1][3],
- T[2][1], T[2][2], T[2][3],
- T[3][1], T[3][2], T[3][3]);
-
- return true;
- } else {
- cerr << "Unable to load reset file " << fname << endl;
- return false;
- }
-}
-
-
-bool FGState::StoreData(string fname)
-{
- ofstream datafile(fname.c_str());
-
- if (datafile) {
- datafile << FDMExec->GetTranslation()->GetU();
- datafile << FDMExec->GetTranslation()->GetV();
- datafile << FDMExec->GetTranslation()->GetW();
- datafile << latitude;
- datafile << longitude;
- datafile << FDMExec->GetRotation()->Getphi();
- datafile << FDMExec->GetRotation()->Gettht();
- datafile << FDMExec->GetRotation()->Getpsi();
- datafile << h;
- datafile.close();
- return true;
- } else {
- cerr << "Could not open dump file " << fname << endl;
- return false;
- }
-}
-
-
-bool FGState::DumpData(string fname)
-{
- ofstream datafile(fname.c_str());
-
- if (datafile) {
- datafile << "U: " << FDMExec->GetTranslation()->GetU() << endl;
- datafile << "V: " << FDMExec->GetTranslation()->GetV() << endl;
- datafile << "W: " << FDMExec->GetTranslation()->GetW() << endl;
- datafile << "P: " << FDMExec->GetRotation()->GetP() << endl;
- datafile << "Q: " << FDMExec->GetRotation()->GetQ() << endl;
- datafile << "R: " << FDMExec->GetRotation()->GetR() << endl;
- datafile << "L: " << FDMExec->GetAircraft()->GetL() << endl;
- datafile << "M: " << FDMExec->GetAircraft()->GetM() << endl;
- datafile << "N: " << FDMExec->GetAircraft()->GetN() << endl;
- datafile << "latitude: " << latitude << endl;
- datafile << "longitude: " << longitude << endl;
- datafile << "alpha: " << FDMExec->GetTranslation()->Getalpha() << endl;
- datafile << "beta: " << FDMExec->GetTranslation()->Getbeta() << endl;
- datafile << "gamma: " << FDMExec->GetTranslation()->Getgamma() << endl;
- datafile << "phi: " << FDMExec->GetRotation()->Getphi() << endl;
- datafile << "tht: " << FDMExec->GetRotation()->Gettht() << endl;
- datafile << "psi: " << FDMExec->GetRotation()->Getpsi() << endl;
- datafile << "Pdot: " << FDMExec->GetRotation()->GetPdot() << endl;
- datafile << "Qdot: " << FDMExec->GetRotation()->GetQdot() << endl;
- datafile << "Rdot: " << FDMExec->GetRotation()->GetRdot() << endl;
- datafile << "h: " << h << endl;
- datafile << "a: " << a << endl;
- datafile << "rho: " << FDMExec->GetAtmosphere()->Getrho() << endl;
- datafile << "qbar: " << qbar << endl;
- datafile << "sim_time: " << sim_time << endl;
- datafile << "dt: " << dt << endl;
- datafile << "m: " << FDMExec->GetAircraft()->GetMass() << endl;
- datafile.close();
- return true;
- } else {
- return false;
- }
-}
-
-
-bool FGState::DisplayData(void)
-{
- cout << "U: " << FDMExec->GetTranslation()->GetU() << endl;
- cout << "V: " << FDMExec->GetTranslation()->GetV() << endl;
- cout << "W: " << FDMExec->GetTranslation()->GetW() << endl;
- cout << "P: " << FDMExec->GetRotation()->GetP() << endl;
- cout << "Q: " << FDMExec->GetRotation()->GetQ() << endl;
- cout << "R: " << FDMExec->GetRotation()->GetR() << endl;
- cout << "L: " << FDMExec->GetAircraft()->GetL() << endl;
- cout << "M: " << FDMExec->GetAircraft()->GetM() << endl;
- cout << "N: " << FDMExec->GetAircraft()->GetN() << endl;
- cout << "Vt: " << Vt << endl;
- cout << "latitude: " << latitude << endl;
- cout << "longitude: " << longitude << endl;
- cout << "alpha: " << FDMExec->GetTranslation()->Getalpha() << endl;
- cout << "beta: " << FDMExec->GetTranslation()->Getbeta() << endl;
- cout << "gamma: " << FDMExec->GetTranslation()->Getgamma() << endl;
- cout << "phi: " << FDMExec->GetRotation()->Getphi() << endl;
- cout << "tht: " << FDMExec->GetRotation()->Gettht() << endl;
- cout << "psi: " << FDMExec->GetRotation()->Getpsi() << endl;
- cout << "Pdot: " << FDMExec->GetRotation()->GetPdot() << endl;
- cout << "Qdot: " << FDMExec->GetRotation()->GetQdot() << endl;
- cout << "Rdot: " << FDMExec->GetRotation()->GetRdot() << endl;
- cout << "h: " << h << endl;
- cout << "a: " << a << endl;
- cout << "rho: " << FDMExec->GetAtmosphere()->Getrho() << endl;
- cout << "qbar: " << qbar << endl;
- cout << "sim_time: " << sim_time << endl;
- cout << "dt: " << dt << endl;
- cout << "m: " << FDMExec->GetAircraft()->GetMass() << endl;
-
- return true;
-}
+++ /dev/null
-/*******************************************************************************
-
- Header: FGState.h
- Author: Jon S. Berndt
- Date started: 11/17/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-
-Based on Flightgear code, which is based on LaRCSim. This class wraps all
-global state variables (such as velocity, position, orientation, etc.).
-
-HISTORY
---------------------------------------------------------------------------------
-11/17/98 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGSTATE_H
-#define FGSTATE_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# include STL_STRING
-# ifdef FG_HAVE_STD_INCLUDES
-# include <fstream>
-# else
-# include <fstream.h>
-# endif
- FG_USING_STD(string);
-#else
-# include <string>
-# include <fstream>
-#endif
-
-#include "FGDefs.h"
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGFDMExec;
-class FGState
-{
-public:
- FGState(FGFDMExec*);
- ~FGState(void);
-
- bool Reset(string, string);
- bool StoreData(string);
- bool DumpData(string);
- bool DisplayData(void);
-
- inline float GetVt(void) {return Vt;}
-
- inline float Getlatitude(void) {return latitude;}
- inline float Getlongitude(void) {return longitude;}
- inline float GetGeodeticLat(void) {return GeodeticLat;}
-
- inline float Getadot(void) {return adot;}
- inline float Getbdot(void) {return bdot;}
-
- inline float Geth(void) {return h;}
- inline float Geta(void) {return a;}
- inline float GetMach(void) {return Mach;}
-
- inline float Getsim_time(void) {return sim_time;}
- inline float Getdt(void) {return dt;}
-
- inline float Getqbar(void) {return qbar;}
-
- inline void SetVt(float tt) {Vt = tt;}
-
- inline void Setlatitude(float tt) {latitude = tt;}
- inline void Setlongitude(float tt) {longitude = tt;}
- inline void SetGeodeticLat(float tt) {GeodeticLat = tt;}
-
- inline void Setadot(float tt) {adot = tt;}
- inline void Setbdot(float tt) {bdot = tt;}
-
- inline void Setqbar(float tt) {qbar = tt;}
-
- inline void Seth(float tt) {h = tt;}
- inline void Seta(float tt) {a = tt;}
- inline void SetMach(float tt) {Mach = tt;}
-
- inline float Setsim_time(float tt) {sim_time = tt; return sim_time;}
- inline void Setdt(float tt) {dt = tt;}
-
- inline float IncrTime(void) {sim_time+=dt;return sim_time;}
-
-private:
-
- float Vt; // Total velocity
- float latitude, longitude; // position
- float GeodeticLat; // Geodetic Latitude
- float adot, bdot; // alpha dot and beta dot
- float h, a; // altitude above sea level, speed of sound
- float qbar; // dynamic pressure
- float sim_time, dt;
- float Mach; // Mach number
-
- FGFDMExec* FDMExec;
-
-protected:
-
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGTank.cpp
- Author: Jon Berndt
- Date started: 01/21/99
- Called by: FGAircraft
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-See header file.
-
-HISTORY
---------------------------------------------------------------------------------
-01/21/99 JSB Created
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-#include "FGTank.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-
-FGTank::FGTank(ifstream& acfile)
-{
- string type;
-
- acfile >> type; // Type = 0: fuel, 1: oxidizer
- if (type == "FUEL") Type = ttFUEL;
- else if (type == "OXIDIZER") Type = ttOXIDIZER;
- else Type = ttUNKNOWN;
- acfile >> X; // inches
- acfile >> Y; // "
- acfile >> Z; // "
- acfile >> Radius; // "
- acfile >> Capacity; // pounds (amount it can hold)
- acfile >> Contents; // pounds (amount it is holding)
- Selected = true;
- PctFull = 100.0*Contents/Capacity; // percent full; 0 to 100.0
-}
-
-
-FGTank::~FGTank(void)
-{
-}
-
-
-float FGTank::Reduce(float used)
-{
- float shortage;
-
- if (used < Contents) {
- Contents -= used;
- PctFull = 100.0*Contents/Capacity;
- return Contents;
- } else {
- shortage = Contents - used;
- Contents = 0.0;
- PctFull = 0.0;
- Selected = false;
- return shortage;
- }
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGTank.h
- Author: Jon S. Berndt
- Date started: 01/21/99
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-
-Based on Flightgear code, which is based on LaRCSim. This class simulates
-a generic Tank.
-
-HISTORY
---------------------------------------------------------------------------------
-01/21/99 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGTank_H
-#define FGTank_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-#ifdef FGFS
-# include <Include/compiler.h>
-# include STL_STRING
-# ifdef FG_HAVE_STD_INCLUDES
-# include <fstream>
-# else
-# include <fstream.h>
-# endif
- FG_USING_STD(string);
-#else
-# include <string>
-# include <fstream>
-#endif
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGTank
-{
-public:
- FGTank(ifstream&);
- ~FGTank(void);
-
- float Reduce(float);
- int GetType(void) {return Type;}
- bool GetSelected(void) {return Selected;}
- float GetPctFull(void) {return PctFull;}
- float GetContents(void) {return Contents;}
-
- enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
-
-private:
- TankType Type;
- float X, Y, Z;
- float Capacity;
- float Radius;
- float PctFull;
- float Contents;
- bool Selected;
-
-protected:
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGTranslation.cpp
- Author: Jon Berndt
- Date started: 12/02/98
- Purpose: Integrates the translational EOM
- Called by: FDMExec
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This class integrates the translational EOM.
-
-HISTORY
---------------------------------------------------------------------------------
-12/02/98 JSB Created
-
-********************************************************************************
-COMMENTS, REFERENCES, and NOTES
-********************************************************************************
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
- Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
- School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
- JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
- NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
- Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
- 1982 ISBN 0-471-08936-2
-
- The order of rotations used in this class corresponds to a 3-2-1 sequence,
- or Y-P-R, or Z-Y-X, if you prefer.
-
-********************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#include "FGTranslation.h"
-#include "FGRotation.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-
-FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex)
-{
- Name = "FGTranslation";
- Udot = Vdot = Wdot = 0.0;
-}
-
-
-FGTranslation::~FGTranslation(void)
-{
-}
-
-
-bool FGTranslation::Run(void)
-{
- if (!FGModel::Run()) {
-
- GetState();
-
- lastUdot = Udot;
- lastVdot = Vdot;
- lastWdot = Wdot;
-
- Udot = V*R - W*Q + Fx/Mass;
- Vdot = W*P - U*R + Fy/Mass;
- Wdot = U*Q - V*P + Fz/Mass;
-
- U += 0.5*dt*rate*(lastUdot + Udot);
- V += 0.5*dt*rate*(lastVdot + Vdot);
- W += 0.5*dt*rate*(lastWdot + Wdot);
-
- Vt = U*U+V*V+W*W > 0.0 ? sqrt(U*U + V*V + W*W) : 0.0;
-
- if (W != 0.0)
- alpha = U*U > 0.0 ? atan2(W, U) : 0.0;
- if (V != 0.0)
- beta = U*U+W*W > 0.0 ? atan2(V, (fabs(U)/U)*sqrt(U*U + W*W)) : 0.0;
-
- qbar = 0.5*rho*Vt*Vt;
-
- PutState();
- } else {
- }
- return false;
-}
-
-
-void FGTranslation::GetState(void)
-{
- dt = State->Getdt();
-
- P = Rotation->GetP();
- Q = Rotation->GetQ();
- R = Rotation->GetR();
-
- Fx = Aircraft->GetFx();
- Fy = Aircraft->GetFy();
- Fz = Aircraft->GetFz();
-
- Mass = Aircraft->GetMass();
- rho = Atmosphere->Getrho();
-
- phi = Rotation->Getphi();
- tht = Rotation->Gettht();
- psi = Rotation->Getpsi();
-}
-
-
-void FGTranslation::PutState(void)
-{
- State->SetVt(Vt);
- State->Setqbar(qbar);
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGTranslation.h
- Author: Jon Berndt
- Date started: 12/02/98
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-12/02/98 JSB Created
-
-********************************************************************************
-COMMENTS, REFERENCES, and NOTES
-********************************************************************************
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
- Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
- School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
- JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
- NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
- Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
- 1982 ISBN 0-471-08936-2
-
- The order of rotations used in this class corresponds to a 3-2-1 sequence,
- or Y-P-R, or Z-Y-X, if you prefer.
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGTRANSLATION_H
-#define FGTRANSLATION_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <cmath>
-# else
-# include <math.h>
-# endif
-#else
-# include <cmath>
-#endif
-
-#include "FGModel.h"
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGTranslation : public FGModel
-{
-public:
- FGTranslation(FGFDMExec*);
- ~FGTranslation(void);
-
- inline float GetU(void) {return U;}
- inline float GetV(void) {return V;}
- inline float GetW(void) {return W;}
-
- inline float GetUdot(void) {return Udot;}
- inline float GetVdot(void) {return Vdot;}
- inline float GetWdot(void) {return Wdot;}
-
- inline float Getalpha(void) {return alpha;}
- inline float Getbeta (void) {return beta; }
- inline float Getgamma(void) {return gamma;}
-
- inline void SetU(float tt) {U = tt;}
- inline void SetV(float tt) {V = tt;}
- inline void SetW(float tt) {W = tt;}
-
- inline void SetUVW(float t1, float t2, float t3) {U=t1; V=t2; W=t3;}
-
- inline void Setalpha(float tt) {alpha = tt;}
- inline void Setbeta (float tt) {beta = tt;}
- inline void Setgamma(float tt) {gamma = tt;}
-
- inline void SetABG(float t1, float t2, float t3) {alpha=t1; beta=t2; gamma=t3;}
-
- bool Run(void);
-
-protected:
-
-private:
- float U, V, W; // Body frame velocities owned by FGTranslation
- float P, Q, R;
- float Vt, qbar;
- float Udot, Vdot, Wdot;
- float lastUdot, lastVdot, lastWdot;
- float phi, tht, psi;
- float Fx, Fy, Fz;
- float Mass, dt;
- float alpha, beta, gamma;
- float rho;
-
- void GetState(void);
- void PutState(void);
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-/*******************************************************************************
-
- Module: FGUtility.cpp
- Author: Jon Berndt
- Date started: 01/09/99
- Purpose: Contains utility classes for the FG FDM
- Called by: FGPosition, et. al.
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-FUNCTIONAL DESCRIPTION
---------------------------------------------------------------------------------
-This class is a container for all utility classes used by the flight dynamics
-model.
-
-HISTORY
---------------------------------------------------------------------------------
-01/09/99 JSB Created
-
-********************************************************************************
-DEFINES
-*******************************************************************************/
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-#ifdef FGFS
-# include <Include/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
-# include <cmath>
-# else
-# include <math.h>
-# endif
-#else
-# include <cmath>
-#endif
-
-#include "FGUtility.h"
-#include "FGState.h"
-#include "FGFDMExec.h"
-
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
-
-FGUtility::FGUtility()
-{
- // Move constant stuff to here (if any) so it won't take CPU time
- // in the methods below.
- SeaLevelR = EARTHRAD * ECCENT;
-}
-
-
-FGUtility::~FGUtility()
-{
-}
-
-
-float FGUtility::ToGeodetic()
-{
- float Latitude, Radius, Altitude;
- float tanLat, xAlpha, muAlpha, sinmuAlpha, denom, rhoAlpha, dMu;
- float lPoint, lambdaSL, sinlambdaSL, dLambda, rAlpha;
-
- Latitude = State->Getlatitude();
- Radius = State->Geth() + EARTHRAD;
-
- if (( M_PI_2 - Latitude < ONESECOND) ||
- ( M_PI_2 + Latitude < ONESECOND)) { // Near a pole
- } else {
- tanLat = tan(Latitude);
- xAlpha = ECCENT*EARTHRAD /
- sqrt(tanLat*tanLat + ECCENTSQRD);
- muAlpha = atan2(sqrt(EARTHRADSQRD - xAlpha*xAlpha), ECCENT*xAlpha);
-
- if (Latitude < 0.0) muAlpha = -muAlpha;
-
- sinmuAlpha = sin(muAlpha);
- dLambda = muAlpha - Latitude;
- rAlpha = xAlpha / cos(Latitude);
- lPoint = Radius - rAlpha;
- Altitude = lPoint*cos(dLambda);
- denom = sqrt(1-EPS*EPS*sinmuAlpha*sinmuAlpha);
- rhoAlpha = EARTHRAD*(1.0 - EPS) / (denom*denom*denom);
- dMu = atan2(lPoint*sin(dLambda),rhoAlpha + Altitude);
- State->SetGeodeticLat(muAlpha - dMu);
- lambdaSL = atan(ECCENTSQRD*tan(muAlpha - dMu));
- sinlambdaSL = sin(lambdaSL);
- SeaLevelR = sqrt(EARTHRADSQRD / (1 + INVECCENTSQRDM1* sinlambdaSL*sinlambdaSL));
- }
- return 0.0;
-}
-
-
-float FGUtility:: FromGeodetic()
-{
- float lambdaSL, sinlambdaSL, coslambdaSL, sinMu, cosMu, py, px;
- float Altitude, SeaLevelR, Radius;
-
- Radius = State->Geth() + EARTHRAD;
- lambdaSL = atan(ECCENTSQRD*tan(State->GetGeodeticLat()));
- sinlambdaSL = sin(lambdaSL);
- coslambdaSL = cos(lambdaSL);
- sinMu = sin(State->GetGeodeticLat());
- cosMu = cos(State->GetGeodeticLat());
- SeaLevelR = sqrt(EARTHRADSQRD /
- (1 + INVECCENTSQRDM1*sinlambdaSL*sinlambdaSL));
- Altitude = Radius - SeaLevelR;
- px = SeaLevelR*coslambdaSL + Altitude*cosMu;
- py = SeaLevelR*sinlambdaSL + Altitude*sinMu;
- State->Setlatitude(atan2(py,px));
- return 0.0;
-}
-
+++ /dev/null
-/*******************************************************************************
-
- Header: FGUtility.h
- Author: Jon Berndt
- Date started: 01/09/99
-
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any later
- version.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- Place - Suite 330, Boston, MA 02111-1307, USA.
-
- Further information about the GNU General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-01/09/99 JSB Created
-
-********************************************************************************
-SENTRY
-*******************************************************************************/
-
-#ifndef FGUTILITY_H
-#define FGUTILITY_H
-
-/*******************************************************************************
-INCLUDES
-*******************************************************************************/
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-/*******************************************************************************
-CLASS DECLARATION
-*******************************************************************************/
-
-class FGFDMExec;
-class FGState;
-
-class FGUtility
-{
-public:
- FGUtility(void);
- ~FGUtility(void);
-
- float ToGeodetic(void);
- float FromGeodetic(void);
-
-protected:
-
-private:
- float SeaLevelR;
- FGState* State;
- FGFDMExec* FDMExec;
-};
-
-/******************************************************************************/
-#endif
+++ /dev/null
-noinst_LIBRARIES = libJSBsim.a
-
-libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \
- FGAtmosphere.cpp FGAtmosphere.h \
- FGAuxiliary.cpp FGAuxiliary.h \
- FGCoefficient.cpp FGCoefficient.h \
- FGDefs.h \
- FGFCS.cpp FGFCS.h \
- FGFDMExec.cpp FGFDMExec.h \
- FGModel.cpp FGModel.h \
- FGOutput.cpp FGOutput.h \
- FGPosition.cpp FGPosition.h \
- FGRotation.cpp FGRotation.h \
- FGState.cpp FGState.h \
- FGTranslation.cpp FGTranslation.h \
- FGUtility.cpp FGUtility.h \
- FGEngine.cpp FGEngine.h \
- FGTank.cpp FGTank.h
-
-INCLUDES += -I$(top_builddir)
-
-DEFS += -DFGFS
#include "ls_cockpit.h"
#include "ls_constants.h"
#include "ls_types.h"
-#include "c172_aero.h"
-
#include <math.h>
#include <stdio.h>
extern COCKPIT cockpit_;
-
+FILE *out;
SCALAR interp(SCALAR *y_table, SCALAR *x_table, int Ntable, SCALAR x)
{
}
else if(x >= x_table[Ntable-1])
{
- slope=(y_table[Ntable-1]-y_table[Ntable-2])/(x_table[Ntable-1]-x_table[Ntable-2]);
- y=slope*(x-x_table[Ntable-1]) +y_table[Ntable-1];
-
-/* printf("x larger than x_table[N]: %g %g %d\n",x,x_table[NCL-1],Ntable-1);
- */ }
+ y=y_table[Ntable-1];
+ /* printf("x larger than x_table[N]: %g %g %d\n",x,x_table[NCL-1],Ntable-1); */
+ }
else /*x is within the table, interpolate linearly to find y value*/
{
return y;
}
+void record()
+{
+ fprintf(out,"%g,%g,%g,%g,%g,%g,%g,%g,%g,",Long_control,Lat_control,Rudder_pedal,Aft_trim,Fwd_trim,V_rel_wind,Dynamic_pressure,P_body,R_body);
+ fprintf(out,"%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,",Alpha,Cos_alpha,Sin_alpha,Alpha_dot,Q_body,Theta_dot,Sin_theta,Cos_theta,Beta,Cos_beta,Sin_beta);
+ fprintf(out,"%g,%g,%g,%g,%g,%g,%g,%g\n",Sin_phi,Cos_phi,F_X_aero,F_Y_aero,F_Z_aero,M_l_aero,M_m_aero,M_n_aero);
+ fflush(out);
+}
void aero( SCALAR dt, int Initialize ) {
-
-
static int init = 0;
static SCALAR trim_inc = 0.0002;
+ SCALAR long_trim;
+
+ SCALAR elevator, aileron, rudder;
+
static SCALAR alpha_ind[NCL]={-0.087,0,0.175,0.209,0.24,0.262,0.278,0.303,0.314,0.332,0.367};
static SCALAR CLtable[NCL]={-0.14,0.31,1.21,1.376,1.51249,1.591,1.63,1.60878,1.53712,1.376,1.142};
+
+
+
+
+ /*Note that CLo,Cdo,Cmo will likely change with flap setting so
+ they may not be declared static in the future */
+
+
+ static SCALAR CLadot=1.7;
+ static SCALAR CLq=3.9;
+ static SCALAR CLde=0.43;
+ static SCALAR CLo=0;
+
+
+ static SCALAR Cdo=0.031;
+ static SCALAR Cda=0.13; /*Not used*/
+ static SCALAR Cdde=0.06;
+
+ static SCALAR Cma=-0.89;
+ static SCALAR Cmadot=-5.2;
+ static SCALAR Cmq=-12.4;
+ static SCALAR Cmo=-0.062;
+ static SCALAR Cmde=-1.28;
+
+ static SCALAR Clbeta=-0.089;
+ static SCALAR Clp=-0.47;
+ static SCALAR Clr=0.096;
+ static SCALAR Clda=0.178;
+ static SCALAR Cldr=0.0147;
+
+ static SCALAR Cnbeta=0.065;
+ static SCALAR Cnp=-0.03;
+ static SCALAR Cnr=-0.099;
+ static SCALAR Cnda=-0.053;
+ static SCALAR Cndr=-0.0657;
+
+ static SCALAR Cybeta=-0.31;
+ static SCALAR Cyp=-0.037;
+ static SCALAR Cyr=0.21;
+ static SCALAR Cyda=0.0;
+ static SCALAR Cydr=0.187;
+
+ /*nondimensionalization quantities*/
+ /*units here are ft and lbs */
+ static SCALAR cbar=4.9; /*mean aero chord ft*/
+ static SCALAR b=35.8; /*wing span ft */
+ static SCALAR Sw=174; /*wing planform surface area ft^2*/
+ static SCALAR rPiARe=0.054; /*reciprocal of Pi*AR*e*/
+
+ SCALAR W=Mass/INVG;
+
+ SCALAR CLwbh,CL,cm,cd,cn,cy,croll,cbar_2V,b_2V,qS,qScbar,qSb,ps,rs;
+
+ SCALAR F_X_wind,F_Y_wind,F_Z_wind,W_X,W_Y,W_Z;
+
+
+
+
+
+ if (Initialize != 0)
+ {
+
+
+ out=fopen("flight.csv","w");
+ /* Initialize aero coefficients */
-
- /* printf("Initialize= %d\n",Initialize); */
-/* printf("Initializing aero model...Initialize= %d\n", Initialize);
- */ CLadot=1.7;
- CLq=3.9;
- CLde=0.43;
- CLo=0;
-
-
- Cdo=0.031;
- Cda=0.13; /*Not used*/
- Cdde=0.06;
-
- Cma=-0.89;
- Cmadot=-5.2;
- Cmq=-12.4;
- Cmo=-0.015;
- Cmde=-1.28;
-
- Clbeta=-0.089;
- Clp=-0.47;
- Clr=0.096;
- Clda=-0.178;
- Cldr=0.0147;
-
- Cnbeta=0.065;
- Cnp=-0.03;
- Cnr=-0.099;
- Cnda=-0.053;
- Cndr=-0.0657;
-
- Cybeta=-0.31;
- Cyp=-0.037;
- Cyr=0.21;
- Cyda=0.0;
- Cydr=0.187;
-
- /*nondimensionalization quantities*/
- /*units here are ft and lbs */
- cbar=4.9; /*mean aero chord ft*/
- b=35.8; /*wing span ft */
- Sw=174; /*wing planform surface area ft^2*/
- rPiARe=0.054; /*reciprocal of Pi*AR*e*/
-
- MaxTakeoffWeight=2550;
- EmptyWeight=1500;
-
- Zcg=0.51;
+
+ }
+
+ record();
/*
LaRCsim uses:
rudder > 0 => ANL
*/
- /*do weight & balance here since there is no better place*/
- Weight=Mass / INVG;
-
- if(Weight > 2550)
- { Weight=2550; }
- else if(Weight < 1500)
- { Weight=1500; }
-
-
- if(Dx_cg > 0.5586)
- { Dx_cg = 0.5586; }
- else if(Dx_cg < -0.4655)
- { Dx_cg = -0.4655; }
+ if(Aft_trim) long_trim = long_trim - trim_inc;
+ if(Fwd_trim) long_trim = long_trim + trim_inc;
- Cg=Dx_cg/cbar +0.25;
+ /*scale pct control to degrees deflection*/
+ if ((Long_control+long_trim) <= 0)
+ elevator=(Long_control+long_trim)*-28*DEG_TO_RAD;
+ else
+ elevator=(Long_control+long_trim)*23*DEG_TO_RAD;
- Dz_cg=Zcg*cbar;
+ aileron = Lat_control*17.5*DEG_TO_RAD;
+ rudder = Rudder_pedal*16*DEG_TO_RAD;
-
- long_trim=0;
- if(Aft_trim) long_trim = long_trim - trim_inc;
- if(Fwd_trim) long_trim = long_trim + trim_inc;
-/* printf("Long_control: %7.4f, long_trim: %7.4f,DEG_TO_RAD: %7.4f, RAD_TO_DEG: %7.4f\n",Long_control,long_trim,DEG_TO_RAD,RAD_TO_DEG);
- */ /*scale pct control to degrees deflection*/
- if ((Long_control+long_trim) <= 0)
- elevator=(Long_control+long_trim)*28*DEG_TO_RAD;
- else
- elevator=(Long_control+long_trim)*23*DEG_TO_RAD;
+ /*check control surface travel limits*/
+ /* if((elevator+long_trim) > 23)
+ elevator=23;
+ else if((elevator+long_trim) < -28)
+ elevator=-23; */
+
- aileron = -1*Lat_control*17.5*DEG_TO_RAD;
- rudder = -1*Rudder_pedal*16*DEG_TO_RAD;
/*
The aileron travel limits are 20 deg. TEU and 15 deg TED
but since we don't distinguish between left and right we'll
use the average here (17.5 deg)
*/
-
+ /* if(fabs(aileron) > 17.5)
+ aileron = 17.5;
+ if(fabs(rudder) > 16)
+ rudder = 16; */
/*calculate rate derivative nondimensionalization (is that a word?) factors */
/*hack to avoid divide by zero*/
b_2V=0;
}
-
/*calcuate the qS nondimensionalization factors*/
qS=Dynamic_pressure*Sw;
qScbar=qS*cbar;
qSb=qS*b;
+ /*transform the aircraft rotation rates*/
+ ps=-P_body*Cos_alpha + R_body*Sin_alpha;
+ rs=-P_body*Sin_alpha + R_body*Cos_alpha;
-/* printf("aero: Wb: %7.4f, Ub: %7.4f, Alpha: %7.4f, elev: %7.4f, ail: %7.4f, rud: %7.4f, long_trim: %7.4f\n",W_body,U_body,Alpha*RAD_TO_DEG,elevator*RAD_TO_DEG,aileron*RAD_TO_DEG,rudder*RAD_TO_DEG,long_trim*RAD_TO_DEG);
- */ //printf("Theta: %7.4f, Gamma: %7.4f, Beta: %7.4f, Phi: %7.4f, Psi: %7.4f\n",Theta*RAD_TO_DEG,Gamma_vert_rad*RAD_TO_DEG,Beta*RAD_TO_DEG,Phi*RAD_TO_DEG,Psi*RAD_TO_DEG);
-
/* sum coefficients */
CLwbh = interp(CLtable,alpha_ind,NCL,Alpha);
CL = CLo + CLwbh + (CLadot*Alpha_dot + CLq*Theta_dot)*cbar_2V + CLde*elevator;
cd = Cdo + rPiARe*CL*CL + Cdde*elevator;
- cy = Cybeta*Beta + (Cyp*P_body + Cyr*R_body)*b_2V + Cyda*aileron + Cydr*rudder;
+ cy = Cybeta*Beta + (Cyp*ps + Cyr*rs)*b_2V + Cyda*aileron + Cydr*rudder;
- cm = Cmo + Cma*Alpha + (Cmq*Q_body + Cmadot*Alpha_dot)*cbar_2V + Cmde*(elevator+long_trim);
- cn = Cnbeta*Beta + (Cnp*P_body + Cnr*R_body)*b_2V + Cnda*aileron + Cndr*rudder;
- croll=Clbeta*Beta + (Clp*P_body + Clr*R_body)*b_2V + Clda*aileron + Cldr*rudder;
+ cm = Cmo + Cma*Alpha + (Cmq*Theta_dot + Cmadot*Alpha_dot)*cbar_2V + Cmde*(elevator+long_trim);
+ cn = Cnbeta*Beta + (Cnp*ps + Cnr*rs)*b_2V + Cnda*aileron + Cndr*rudder;
+ croll=Clbeta*Beta + (Clp*ps + Clr*rs)*b_2V + Clda*aileron + Cldr*rudder;
-/* printf("aero: CL: %7.4f, Cd: %7.4f, Cm: %7.4f, Cy: %7.4f, Cn: %7.4f, Cl: %7.4f\n",CL,cd,cm,cy,cn,croll);
- */ /*calculate wind axes forces*/
+ /*calculate wind axes forces*/
F_X_wind=-1*cd*qS;
F_Y_wind=cy*qS;
F_Z_wind=-1*CL*qS;
-/* printf("V_rel_wind: %7.4f, Fxwind: %7.4f Fywind: %7.4f Fzwind: %7.4f\n",V_rel_wind,F_X_wind,F_Y_wind,F_Z_wind);
- */
/*calculate moments and body axis forces */
-
+ /*find body-axis components of weight*/
+ /*with earth axis to body axis transform */
+ W_X=-1*W*Sin_theta;
+ W_Y=W*Sin_phi*Cos_theta;
+ W_Z=W*Cos_phi*Cos_theta;
/* requires ugly wind-axes to body-axes transform */
- F_X_aero = F_X_wind*Cos_alpha*Cos_beta - F_Y_wind*Cos_alpha*Sin_beta - F_Z_wind*Sin_alpha;
- F_Y_aero = F_X_wind*Sin_beta + F_Y_wind*Cos_beta;
- F_Z_aero = F_X_wind*Sin_alpha*Cos_beta - F_Y_wind*Sin_alpha*Sin_beta + F_Z_wind*Cos_alpha;
+ F_X_aero = W_X + F_X_wind*Cos_alpha*Cos_beta - F_Y_wind*Cos_alpha*Sin_beta - F_Z_wind*Sin_alpha;
+ F_Y_aero = W_Y + F_X_wind*Sin_beta + F_Z_wind*Cos_beta;
+ F_Z_aero = W_Z*NZ + F_X_wind*Sin_alpha*Cos_beta - F_Y_wind*Sin_alpha*Sin_beta + F_Z_wind*Cos_alpha;
/*no axes transform here */
- M_l_aero = croll*qSb;
- M_m_aero = cm*qScbar;
- M_n_aero = cn*qSb;
-
-/* printf("I_yy: %7.4f, qScbar: %7.4f, qbar: %7.4f, Sw: %7.4f, cbar: %7.4f, 0.5*rho*V^2: %7.4f\n",I_yy,qScbar,Dynamic_pressure,Sw,cbar,0.5*0.0023081*V_rel_wind*V_rel_wind);
- */
-/* printf("Fxaero: %7.4f Fyaero: %7.4f Fzaero: %7.4f Weight: %7.4f\n",F_X_aero,F_Y_aero,F_Z_aero,W);
- *//* printf("Maero: %7.4f Naero: %7.4f Raero: %7.4f\n",M_m_aero,M_n_aero,M_l_aero);
- */
+ M_l_aero = I_xx*croll*qSb;
+ M_m_aero = I_yy*cm*qScbar;
+ M_n_aero = I_zz*cn*qSb;
+
}
#include "ls_generic.h"
#include "ls_sim_control.h"
#include "ls_cockpit.h"
-#include "c172_aero.h"
extern SIM_CONTROL sim_control_;
/* F_X_engine = Throttle[3]*813.4/0.2; */ /* original code */
/* F_Z_engine = Throttle[3]*11.36/0.2; */ /* original code */
- F_X_engine = Throttle[3]*350/0.83;
- F_Z_engine = Throttle[3]*4.9/0.83;
- M_m_engine = F_X_engine*0.734*cbar;
- /* 0.734 - estimated (WAGged) location of thrust line in the z-axis*/
+ F_X_engine = Throttle[3]*813.4/0.83;
+ F_Z_engine = Throttle[3]*11.36/0.83;
Throttle_pct = Throttle[3];
}
----------------------------------------------------------------------------
- GENEALOGY: Created 931012 by E. B. Jackson
+ GENEALOGY: Renamed navion_gear.c originally created 931012 by E. B. Jackson
+
----------------------------------------------------------------------------
$Header$
$Log$
-Revision 1.2 1999/08/19 21:24:03 curt
-Updated Tony's c172 model code.
+Revision 1.1 1999/06/17 18:07:34 curt
+Initial revision
+
+Revision 1.1 1999/06/15 20:05:27 curt
+Added c172 model from Tony Peden.
+
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
+Revision 1.6 1998/10/17 01:34:16 curt
+C++ ifying ...
+
+Revision 1.5 1998/09/29 02:03:00 curt
+Added a brake + autopilot mods.
+
+Revision 1.4 1998/08/06 12:46:40 curt
+Header change.
+
+Revision 1.3 1998/02/03 23:20:18 curt
+Lots of little tweaks to fix various consistency problems discovered by
+Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+passed arguments along to the real printf(). Also incorporated HUD changes
+by Michele America.
+
+Revision 1.2 1998/01/19 18:40:29 curt
+Tons of little changes to clean up the code and to remove fatal errors
+when building with the c++ compiler.
+
+Revision 1.1 1997/05/29 00:10:02 curt
+Initial Flight Gear revision.
----------------------------------------------------------------------------
#include "ls_cockpit.h"
-sub3( DATA v1[], DATA v2[], DATA result[] )
+void sub3( DATA v1[], DATA v2[], DATA result[] )
{
result[0] = v1[0] - v2[0];
result[1] = v1[1] - v2[1];
result[2] = v1[2] - v2[2];
}
-add3( DATA v1[], DATA v2[], DATA result[] )
+void add3( DATA v1[], DATA v2[], DATA result[] )
{
result[0] = v1[0] + v2[0];
result[1] = v1[1] + v2[1];
result[2] = v1[2] + v2[2];
}
-cross3( DATA v1[], DATA v2[], DATA result[] )
+void cross3( DATA v1[], DATA v2[], DATA result[] )
{
result[0] = v1[1]*v2[2] - v1[2]*v2[1];
result[1] = v1[2]*v2[0] - v1[0]*v2[2];
result[2] = v1[0]*v2[1] - v1[1]*v2[0];
}
-multtrans3x3by3( DATA m[][3], DATA v[], DATA result[] )
+void multtrans3x3by3( DATA m[][3], DATA v[], DATA result[] )
{
result[0] = m[0][0]*v[0] + m[1][0]*v[1] + m[2][0]*v[2];
result[1] = m[0][1]*v[0] + m[1][1]*v[1] + m[2][1]*v[2];
result[2] = m[0][2]*v[0] + m[1][2]*v[1] + m[2][2]*v[2];
}
-mult3x3by3( DATA m[][3], DATA v[], DATA result[] )
+void mult3x3by3( DATA m[][3], DATA v[], DATA result[] )
{
result[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2];
result[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2];
result[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2];
}
-clear3( DATA v[] )
+void clear3( DATA v[] )
{
v[0] = 0.; v[1] = 0.; v[2] = 0.;
}
-gear()
-{
+void gear( SCALAR dt, int Initialize ) {
char rcsid[] = "$Id$";
/*
* Put aircraft specific executable code here
*/
- percent_brake[1] = 0.; /* replace with cockpit brake handle connection code */
+ /* replace with cockpit brake handle connection code */
+ percent_brake[1] = Brake_pct;
percent_brake[2] = percent_brake[1];
caster_angle_rad[0] = 0.03*Rudder_pedal;
void model_init( void ) {
- Throttle[3] = 0.2;
+ Throttle[3] = 0.2; Rudder_pedal = 0; Lat_control = 0; Long_control = 0;
Dx_pilot = 0; Dy_pilot = 0; Dz_pilot = 0;
Mass=2300*INVG;
#include <FDM/LaRCsim/ls_generic.h>
#include <FDM/LaRCsim/ls_interface.h>
#include <FDM/LaRCsim/ls_constants.h>
-#include <FDM/LaRCsim/atmos_62.h>
-/* #include <FDM/LaRCsim/ls_trim_fs.h> */
-#include <FDM/LaRCsim/c172_aero.h>
-
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-
-//simple "one-at-a-time" longitudinal trimming routine
-typedef struct
-{
- double latitude,longitude,altitude;
- double vc,alpha,beta,gamma;
- double theta,phi,psi;
- double weight,cg;
- int use_gamma_tmg;
-}InitialConditions;
-
-// Units for setIC
-// vc knots (calibrated airspeed, close to indicated)
-// altitude ft
-// all angles in degrees
-// weight lbs
-// cg %MAC
-// if use_gamma_tmg =1 then theta will be computed
-// from theta=alpha+gamma and the value given will
-// be ignored. Otherwise gamma is computed from
-// gamma=theta-alpha
-void setIC(InitialConditions IC)
-{
- SCALAR vtfps,u,v,w,vt_east;
- SCALAR vnu,vnv,vnw,vteu,vtev,vtew,vdu,vdv,vdw;
- SCALAR alphar,betar,thetar,phir,psir,gammar;
- SCALAR sigma,ps,Ts,a;
-
- Mass=IC.weight*INVG;
- Dx_cg=(IC.cg-0.25)*4.9;
-
- Latitude=IC.latitude*DEG_TO_RAD;
- Longitude=IC.longitude*DEG_TO_RAD;
- Altitude=IC.altitude;
- ls_geod_to_geoc( Latitude, Altitude, &Sea_level_radius, &Lat_geocentric);
-
- ls_atmos(IC.altitude,&sigma,&a,&Ts,&ps);
- vtfps=sqrt(1/sigma*IC.vc*IC.vc)*1.68781;
- alphar=IC.alpha*DEG_TO_RAD;
- betar=IC.beta*DEG_TO_RAD;
- gammar=IC.gamma*DEG_TO_RAD;
-
-
- phir=IC.phi*DEG_TO_RAD;
- psir=IC.psi*DEG_TO_RAD;
-
- if(IC.use_gamma_tmg == 1)
- {
- thetar=alphar+gammar;
- }
- else
- {
- thetar=IC.theta*DEG_TO_RAD;
- gammar=thetar-alphar;
- }
-
- u=vtfps*cos(alphar)*cos(betar);
- v=vtfps*sin(betar);
- w=vtfps*sin(alphar)*cos(betar);
-
- vnu=u*cos(thetar)*cos(psir);
- vnv=v*(-sin(psir)*cos(phir)+sin(phir)*sin(thetar)*cos(psir));
- vnw=w*(sin(phir)*sin(psir)+cos(phir)*sin(thetar)*cos(psir));
-
- V_north=vnu+vnv+vnw;
-
- vteu=u*cos(thetar)*sin(psir);
- vtev=v*(cos(phir)*cos(psir)+sin(phir)*sin(thetar)*sin(psir));
- vtew=w*(-sin(phir)*cos(psir)+cos(phir)*sin(thetar)*sin(psir));
-
- vt_east=vteu+vtev+vtew;
- V_east=vt_east+ OMEGA_EARTH*Sea_level_radius*cos(Lat_geocentric);
-
- vdu=u*-sin(thetar);
- vdv=v*cos(thetar)*sin(phir);
- vdw=w*cos(thetar)*cos(phir);
-
- V_down=vdu+vdv+vdw;
-
- Theta=thetar;
- Phi=phir;
- Psi=psir;
-
-}
-
-
-int trim_long(int kmax, InitialConditions IC)
-{
- double elevator,alpha;
- double tol=1E-3;
- double a_tol=tol/10;
- double alpha_step=0.001;
- int k=0,i,j=0,jmax=10,sum=0;
- ls_loop(0.0,-1);
- do{
- //printf("k: %d\n",k);
- while((fabs(W_dot_body) > tol) && (j < jmax))
- {
-
- IC.alpha+=W_dot_body*0.05;
- if((IC.alpha < -5) || (IC.alpha > 21))
- j=jmax;
- setIC(IC);
- ls_loop(0.0,-1);
-/* printf("IC.alpha: %g, Alpha: %g, wdot: %g\n",IC.alpha,Alpha*RAD_TO_DEG,W_dot_body);
- */ j++;
- }
- sum+=j;
-/* printf("\tTheta: %7.4f, Alpha: %7.4f, wdot: %10.6f, j: %d\n",Theta*RAD_TO_DEG,Alpha*RAD_TO_DEG,W_dot_body,j);
- */ j=0;
- while((fabs(U_dot_body) > tol) && (j < jmax))
- {
-
- Throttle_pct-=U_dot_body*0.005;
- if((Throttle_pct < 0) || (Throttle_pct > 1))
- Throttle_pct=0.2;
- setIC(IC);
- ls_loop(0.0,-1);
- j++;
- }
- sum+=j;
-/* printf("\tThrottle_pct: %7.4f, udot: %10.6f, j: %d\n",Throttle_pct,U_dot_body,j);
- */ j=0;
- while((fabs(Q_dot_body) > a_tol) && (j < jmax))
- {
-
- Long_control+=Q_dot_body*0.001;
- if((Long_control < -1) || (Long_control > 1))
- j=jmax;
- setIC(IC);
- ls_loop(0.0,-1);
- j++;
- }
- sum+=j;
- if(Long_control >= 0)
- elevator=Long_control*23;
- else
- elevator=Long_control*28;
-/* printf("\televator: %7.4f, qdot: %10.6f, j: %d\n",elevator,Q_dot_body,j);
- */ k++;j=0;
- }while(((fabs(W_dot_body) > tol) || (fabs(U_dot_body) > tol) || (fabs(Q_dot_body) > tol)) && (k < kmax));
- /* printf("Total Iterations: %d\n",sum); */
- return k;
-}
-
-int trim_ground(int kmax, InitialConditions IC)
-{
- double elevator,alpha,qdot_prev,alt_prev,step;
- double tol=1E-3;
- double a_tol=tol/10;
- double alpha_step=0.001;
- int k=0,i,j=0,jmax=40,sum=0,m=0;
- Throttle_pct=0;
- Brake_pct=1;
- Theta=5*DEG_TO_RAD;
- IC.altitude=Runway_altitude;
- printf("udot: %g\n",U_dot_body);
- setIC(IC);
- printf("Altitude: %g, Runway_altitude: %g\n",Altitude,Runway_altitude);
- qdot_prev=1.0E6;
-
- ls_loop(0.0,-1);
-
- do{
- //printf("k: %d\n",k);
- step=1;
- printf("IC.altitude: %g, Altitude: %g, Runway_altitude: %g,wdot: %g,F_Z_gear: %g, M_m_gear: %g,F_Z: %g\n",IC.altitude,Altitude,Runway_altitude,W_dot_body,F_Z_gear,M_m_gear,F_Z);
-
- m=0;
- while((fabs(W_dot_body) > tol) && (m < 10))
- {
-
- j=0;
-
- do{
- alt_prev=IC.altitude;
- IC.altitude+=step;
- setIC(IC);
- ls_loop(0.0,-1);
- printf("IC.altitude: %g, Altitude: %g, Runway_altitude: %g,wdot: %g,F_Z: %g\n",IC.altitude,Altitude,Runway_altitude,W_dot_body,F_Z);
- j++;
- }while((W_dot_body < 0) && (j < jmax));
- IC.altitude-=step;
- step/=10;
- printf("step: %g\n",step);
- m++;
-
- }
- sum+=j;
- printf("IC.altitude: %g, Altitude: %g, Runway_altitude: %g,wdot: %g,F_Z_gear: %g, M_m_gear: %g,F_Z: %g\n",IC.altitude,Altitude,Runway_altitude,W_dot_body,F_Z_gear,M_m_gear,F_Z);
-
- j=0;
-
- while((Q_dot_body <= qdot_prev) && (j < jmax))
- {
-
-
- qdot_prev=Q_dot_body;
- IC.theta+=Q_dot_body;
- setIC(IC);
- ls_loop(0.0,-1);
- j++;
-
- printf("\tTheta: %7.4f, qdot: %10.6f, qdot_prev: %10.6f, j: %d\n",Theta*RAD_TO_DEG,Q_dot_body,qdot_prev,j);
- }
- IC.theta-=qdot_prev;
- sum+=j;
-
- printf("\tTheta: %7.4f, qdot: %10.6f, W_dot_body: %g\n",Theta,Q_dot_body,W_dot_body);
- j=0;
- if(W_dot_body > tol)
- {
- step=1;
- while((W_dot_body > 0) && (j <jmax))
- {
- IC.altitude-=step;
- setIC(IC);
- ls_loop(0.0,-1);
- j++;
- }
- }
- k++;j=0;
- }while(((fabs(W_dot_body) > tol) || (fabs(Q_dot_body) > tol)) && (k < kmax));
- printf("Total Iterations: %d\n",sum);
- return k;
-}
-void do_trims(int kmax,FILE *out,InitialConditions IC)
-{
- int k=0,i;
- double speed,elevator,cmcl;
- out=fopen("trims.out","w");
- speed=55;
-
- for(i=1;i<=5;i++)
- {
- switch(i)
- {
- case 1: IC.weight=1500;IC.cg=0.155;break;
- case 2: IC.weight=1500;IC.cg=0.364;break;
- case 3: IC.weight=1950;IC.cg=0.155;break;
- case 4: IC.weight=2550;IC.cg=0.257;break;
- case 5: IC.weight=2550;IC.cg=0.364;break;
- }
-
- speed=50;
- while(speed <= 150)
- {
- IC.vc=speed;
- Long_control=0;Theta=0;Throttle_pct=0.0;
-
- k=trim_long(kmax,IC);
- if(Long_control <= 0)
- elevator=Long_control*28;
- else
- elevator=Long_control*23;
- if(fabs(CL) > 1E-3)
- {
- cmcl=cm / CL;
- }
- if(k < kmax)
- {
- fprintf(out,"%g,%g,%g,%g,%g,%d",V_calibrated_kts,Alpha*RAD_TO_DEG,Long_control,Throttle_pct,Gamma_vert_rad,k);
- fprintf(out,",%g,%g,%g,%g,%g\n",CL,cm,cmcl,Weight,Cg);
-/* printf("%g,%g,%g,%g,%g,%g,%g,%g,%g,%g\n",V_calibrated_kts,Alpha*RAD_TO_DEG,elevator,CL,cm,Cmo,Cma,Cmde,Mass*32.174,Dx_cg);
- */ }
- else
- {
- printf("kmax exceeded at: %g knots, %g lbs, %g %%MAC\n",V_calibrated_kts,Weight,Cg);
- printf("wdot: %g, udot: %g, qdot: %g\n\n",W_dot_body,U_dot_body,Q_dot_body);
-
- }
- speed+=10;
- }
- }
- fclose(out);
-}
-
-void do_stick_pull(int kmax, SCALAR tmax,FILE *out,InitialConditions IC)
-{
-
- SCALAR htarget,hgain,hdiffgain,herr,herr_diff,herrprev;
- SCALAR theta_trim,elev_trim,time;
- int k;
- k=trim_long(kmax,IC);
- printf("Trim:\n\tAlpha: %10.6f, elev: %10.6f, Throttle: %10.6f\n\twdot: %10.6f, qdot: %10.6f, udot: %10.6f\n",Alpha*RAD_TO_DEG,Long_control,Throttle_pct,W_dot_body,U_dot_body,Q_dot_body);
-
- htarget=0;
-
- hgain=1;
- hdiffgain=1;
- elev_trim=Long_control;
- out=fopen("stick_pull.out","w");
- herr=Q_body-htarget;
-
- //fly steady-level for 2 seconds, well, zero pitch rate anyway
- while(time < 2.0)
- {
- herrprev=herr;
- ls_update(1);
- herr=Q_body-htarget;
- herr_diff=herr-herrprev;
- Long_control=elev_trim+(hgain*herr + hdiffgain*herr_diff);
- time+=0.01;
-/* printf("Time: %7.4f, Alt: %7.4f, Alpha: %7.4f, pelev: %7.4f, qdot: %7.4f, udot: %7.4f, Phi: %7.4f, Psi: %7.4f\n",time,Altitude,Alpha*RAD_TO_DEG,Long_control*100,Q_body*RAD_TO_DEG,U_dot_body,Phi,Psi);
- printf("Mcg: %7.4f, Mrp: %7.4f, Maero: %7.4f, Meng: %7.4f, Mgear: %7.4f, Dx_cg: %7.4f, Dz_cg: %7.4f\n\n",M_m_cg,M_m_rp,M_m_aero,M_m_engine,M_m_gear,Dx_cg,Dz_cg);
- */ fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,",time,V_true_kts,Theta*RAD_TO_DEG,Alpha*RAD_TO_DEG,Q_body*RAD_TO_DEG,Alpha_dot*RAD_TO_DEG,Q_dot_body*RAD_TO_DEG,Throttle_pct,elevator*RAD_TO_DEG);
- fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f\n",CL,CLwbh,cm,cd,Altitude);
- }
-
- //begin untrimmed climb at theta_trim + 2 degrees
- hgain=4;
- hdiffgain=2;
- theta_trim=Theta;
- htarget=theta_trim;
- herr=Theta-htarget;
- while(time < tmax)
- {
- //ramp in the target theta
- if(htarget < (theta_trim + 2*DEG_TO_RAD))
- {
- htarget+= 0.01*DEG_TO_RAD;
- }
- herrprev=herr;
- ls_update(1);
- herr=Theta-htarget;
- herr_diff=herr-herrprev;
- Long_control=elev_trim+(hgain*herr + hdiffgain*herr_diff);
- time+=0.01;
-/* printf("Time: %7.4f, Alt: %7.4f, Alpha: %7.4f, pelev: %7.4f, qdot: %7.4f, udot: %7.4f, Phi: %7.4f, Psi: %7.4f\n",time,Altitude,Alpha*RAD_TO_DEG,Long_control*100,Q_body*RAD_TO_DEG,U_dot_body,Phi,Psi);
- printf("Mcg: %7.4f, Mrp: %7.4f, Maero: %7.4f, Meng: %7.4f, Mgear: %7.4f, Dx_cg: %7.4f, Dz_cg: %7.4f\n\n",M_m_cg,M_m_rp,M_m_aero,M_m_engine,M_m_gear,Dx_cg,Dz_cg);
- */ fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,",time,V_true_kts,Theta*RAD_TO_DEG,Alpha*RAD_TO_DEG,Q_body*RAD_TO_DEG,Alpha_dot*RAD_TO_DEG,Q_dot_body*RAD_TO_DEG,Throttle_pct,elevator*RAD_TO_DEG);
- fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f\n",CL,CLwbh,cm,cd,Altitude);
- }
- printf("%g,%g\n",theta_trim*RAD_TO_DEG,htarget*RAD_TO_DEG);
- fclose(out);
-}
-
-void do_takeoff(FILE *out)
-{
- SCALAR htarget,hgain,hdiffgain,elev_trim,elev_trim_save,herr;
- SCALAR time,herrprev,herr_diff;
-
- htarget=0;
-
- hgain=1;
- hdiffgain=1;
- elev_trim=Long_control;
- elev_trim_save=elev_trim;
-
-
- out=fopen("takeoff.out","w");
- herr=Q_body-htarget;
-
- //attempt to maintain zero pitch rate during the roll
- while((V_calibrated_kts < 61) && (time < 30.0))
- {
- /* herrprev=herr;*/
- ls_update(1);
- /*herr=Q_body-htarget;
- herr_diff=herr-herrprev;
- Long_control=elev_trim+(hgain*herr + hdiffgain*herr_diff); */
- time+=0.01;
- printf("Time: %7.4f, Vc: %7.4f, Alpha: %7.4f, pelev: %7.4f, qdot: %7.4f, udot: %7.4f, U: %7.4f, W: %7.4f\n",time,V_calibrated_kts,Alpha*RAD_TO_DEG,Long_control*100,Q_body*RAD_TO_DEG,U_dot_body,U_body,W_body);
-// printf("Mcg: %7.4f, Mrp: %7.4f, Maero: %7.4f, Meng: %7.4f, Mgear: %7.4f, Dx_cg: %7.4f, Dz_cg: %7.4f\n\n",M_m_cg,M_m_rp,M_m_aero,M_m_engine,M_m_gear,Dx_cg,Dz_cg);
-// fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,",time,V_calibrated_kts,Theta*RAD_TO_DEG,Alpha*RAD_TO_DEG,Q_body*RAD_TO_DEG,Alpha_dot*RAD_TO_DEG,Q_dot_body*RAD_TO_DEG,Throttle_pct,elevator*RAD_TO_DEG);
- fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f\n",CL,CLwbh,cm,cd,Altitude);
-
- }
- //At Vr, ramp in 10% nose up elevator in 0.5 seconds
- elev_trim_save=0;
- printf("At Vr, rotate...\n");
- while((Q_body < 3.0*RAD_TO_DEG) && (time < 30.0))
- {
- Long_control-=0.01;
- ls_update(1);
- printf("Time: %7.4f, Vc: %7.4f, Alpha: %7.4f, pelev: %7.4f, q: %7.4f, cm: %7.4f, U: %7.4f, W: %7.4f\n",time,V_calibrated_kts,Alpha*RAD_TO_DEG,Long_control*100,Q_body*RAD_TO_DEG,cm,U_body,W_body);
-
- fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,",time,V_calibrated_kts,Theta*RAD_TO_DEG,Alpha*RAD_TO_DEG,Q_body*RAD_TO_DEG,Alpha_dot*RAD_TO_DEG,Q_dot_body*RAD_TO_DEG,Throttle_pct,elevator*RAD_TO_DEG);
- fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f\n",CL,CLwbh,cm,cd,Altitude);
- time +=0.01;
-
- }
- //Maintain 15 degrees theta for the climbout
- htarget=15*DEG_TO_RAD;
- herr=Theta-htarget;
- hgain=10;
- hdiffgain=1;
- elev_trim=Long_control;
- while(time < 30.0)
- {
- herrprev=herr;
- ls_update(1);
- herr=Theta-htarget;
- herr_diff=herr-herrprev;
- Long_control=elev_trim+(hgain*herr + hdiffgain*herr_diff);
- time+=0.01;
- printf("Time: %7.4f, Alt: %7.4f, Speed: %7.4f, Theta: %7.4f\n",time,Altitude,V_calibrated_kts,Theta*RAD_TO_DEG);
- fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,%20.8f,",time,V_calibrated_kts,Theta*RAD_TO_DEG,Alpha*RAD_TO_DEG,Q_body*RAD_TO_DEG,Alpha_dot*RAD_TO_DEG,Q_dot_body*RAD_TO_DEG,Throttle_pct,elevator*RAD_TO_DEG);
- fprintf(out,"%20.8f,%20.8f,%20.8f,%20.8f,%20.8f\n",CL,CLwbh,cm,cd,Altitude);
- }
- fclose(out);
- printf("Speed: %7.4f, Alt: %7.4f, Alpha: %7.4f, pelev: %7.4f, q: %7.4f, udot: %7.4f\n",V_true_kts,Altitude,Alpha*RAD_TO_DEG,Long_control,Q_body*RAD_TO_DEG,U_dot_body);
- printf("F_down_total: %7.4f, F_Z_aero: %7.4f, F_X: %7.4f, M_m_cg: %7.4f\n\n",F_down+Mass*Gravity,F_Z_aero,F_X,M_m_cg);
-
-
-
-
-}
// Initialize the LaRCsim flight model, dt is the time increment for
// each subsequent iteration through the EOM
}
-
// Run an iteration of the EOM (equations of motion)
-int main(int argc, char *argv[]) {
+int main() {
double save_alt = 0.0;
- int multiloop=1,k=0,i;
- double time=0,elev_trim,elev_trim_save,elevator,speed,cmcl;
- FILE *out;
- double hgain,hdiffgain,herr,herrprev,herr_diff,htarget;
- InitialConditions IC;
+ int multiloop=1;
+ double time=0;
- if(argc < 6)
- {
- printf("Need args: $c172 speed alt alpha elev throttle\n");
- exit(1);
- }
+ Altitude=1000; /*BFI as given by airnav*/
+ Latitude=47.5299892;
+ Longitude=122.3019561;
+ Lat_geocentric=Latitude;
+ Lon_geocentric=Longitude;
+ Radius_to_vehicle=Altitude+EQUATORIAL_RADIUS;
+ Lat_control = 0;
+ Long_control = 0;
+ Long_trim = 0;
+ Rudder_pedal = 0;
+ Throttle_pct = 0.0;
+ Brake_pct = 1.0;
+ V_north=200;
+ V_east=0;
+ V_down=0;
- IC.latitude=47.5299892; //BFI
- IC.longitude=122.3019561;
- Runway_altitude = 18.0;
- IC.altitude=strtod(argv[2],NULL);
- IC.vc=strtod(argv[1],NULL);
- IC.alpha=10;
- IC.beta=0;
- IC.theta=strtod(argv[3],NULL);
- IC.use_gamma_tmg=0;
- IC.phi=0;
- IC.psi=0;
- IC.weight=1500;
- IC.cg=0.155;
- Long_control=strtod(argv[4],NULL);
- setIC(IC);
- printf("Out setIC\n");
- ls_ForceAltitude(IC.altitude);
- fgLaRCsimInit(0.01);
+ printf("Calling init...\n");
+ fgLaRCsimInit(0.05);
- while(IC.alpha < 30.0)
- {
- setIC(IC);
- ls_loop(0.0,-1);
- printf("CL: %g ,Alpha: %g\n",CL,IC.alpha);
- IC.alpha+=1.0;
- }
-
- /*trim_ground(10,IC);*/
- /* printf("%g,%g\n",Theta,Gamma_vert_rad);
- printf("trim_long():\n");
- k=trim_long(200,IC);
- Throttle_pct=Throttle_pct-0.2;
- printf("%g,%g\n",Theta,Gamma_vert_rad);
- out=fopen("dive.out","w");
- time=0;
- while(time < 30.0)
- {
- ls_update(1);
-
- cmcl=cm/CL;
- fprintf(out,"%g,%g,%g,%g,%g,%d",V_calibrated_kts,Alpha*RAD_TO_DEG,Long_control,Throttle_pct,Gamma_vert_rad,k);
- fprintf(out,",%g,%g,%g\n",CL,cm,cmcl);
- time+=0.01;
- }
- fclose(out);
- printf("V_rel_wind: %8.2f, Alpha: %8.2f, Beta: %8.2f\n",V_rel_wind,Alpha*RAD_TO_DEG,Beta*RAD_TO_DEG);
- printf("Theta: %8.2f, Gamma: %8.2f, Alpha_tmg: %8.2f\n",Theta*RAD_TO_DEG,Gamma_vert_rad*RAD_TO_DEG,Theta*RAD_TO_DEG-Gamma_vert_rad*RAD_TO_DEG);
- printf("V_north: %8.2f, V_east_rel_ground: %8.2f, V_east: %8.2f, V_down: %8.2f\n",V_north,V_east_rel_ground,V_east,V_down);
- printf("Long_control: %8.2f, Throttle_pct: %8.2f\n",Long_control,Throttle_pct);
- printf("k: %d, udot: %8.4f, wdot: %8.4f, qdot: %8.5f\n",k,U_dot_body,W_dot_body,Q_dot_body);
+ /* copy control positions into the LaRCsim structure */
- printf("\nls_update():\n");
- ls_update(1);
- printf("V_rel_wind: %8.2f, Alpha: %8.2f, Beta: %8.2f\n",V_rel_wind,Alpha*RAD_TO_DEG,Beta*RAD_TO_DEG);
- printf("Theta: %8.2f, Gamma: %8.2f, Alpha_tmg: %8.2f\n",Theta*RAD_TO_DEG,Gamma_vert_rad*RAD_TO_DEG,Theta*RAD_TO_DEG-Gamma_vert_rad*RAD_TO_DEG);
- */
-
+
/* Inform LaRCsim of the local terrain altitude */
+ Runway_altitude = 18.0;
+ printf("Entering Loop\n");
+ printf("Speed: %7.4f, Lat: %7.4f, Long: %7.4f, Alt: %7.4f\n\n",V_true_kts,Latitude,Longitude,Altitude);
+ while (time < 0.2)
+ {
+ time=time+0.05;
+ ls_update(multiloop);
+ printf("Speed: %7.4f, Fxeng: %7.4f, Fxaero: %7.4f, Fxgear: %7.4f Alt: %7.4f\n\n",V_true_kts,F_X_engine,F_X_aero,F_X_gear,Altitude);
+
+
+
+ }
+ /* // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
+ // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
-
+ // translate LaRCsim back to FG structure so that the
+ // autopilot (and the rest of the sim can use the updated
+ // values
+ //fgLaRCsim_2_FGInterface(f); */
+
+
+
return 1;
}
return( 0 );
}
-*/
+// Convert from the LaRCsim generic_ struct to the FGInterface struct
+int fgLaRCsim_2_FGInterface (FGInterface& f) {
+
+ // Mass properties and geometry values
+ f.set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
+ // f.set_Pilot_Location( Dx_pilot, Dy_pilot, Dz_pilot );
+ f.set_CG_Position( Dx_cg, Dy_cg, Dz_cg );
+
+ // Forces
+ // f.set_Forces_Body_Total( F_X, F_Y, F_Z );
+ // f.set_Forces_Local_Total( F_north, F_east, F_down );
+ // f.set_Forces_Aero( F_X_aero, F_Y_aero, F_Z_aero );
+ // f.set_Forces_Engine( F_X_engine, F_Y_engine, F_Z_engine );
+ // f.set_Forces_Gear( F_X_gear, F_Y_gear, F_Z_gear );
+
+ // Moments
+ // f.set_Moments_Total_RP( M_l_rp, M_m_rp, M_n_rp );
+ // f.set_Moments_Total_CG( M_l_cg, M_m_cg, M_n_cg );
+ // f.set_Moments_Aero( M_l_aero, M_m_aero, M_n_aero );
+ // f.set_Moments_Engine( M_l_engine, M_m_engine, M_n_engine );
+ // f.set_Moments_Gear( M_l_gear, M_m_gear, M_n_gear );
+
+ // Accelerations
+ // f.set_Accels_Local( V_dot_north, V_dot_east, V_dot_down );
+ // f.set_Accels_Body( U_dot_body, V_dot_body, W_dot_body );
+ // f.set_Accels_CG_Body( A_X_cg, A_Y_cg, A_Z_cg );
+ // f.set_Accels_Pilot_Body( A_X_pilot, A_Y_pilot, A_Z_pilot );
+ // f.set_Accels_CG_Body_N( N_X_cg, N_Y_cg, N_Z_cg );
+ // f.set_Accels_Pilot_Body_N( N_X_pilot, N_Y_pilot, N_Z_pilot );
+ // f.set_Accels_Omega( P_dot_body, Q_dot_body, R_dot_body );
+
+ // Velocities
+ f.set_Velocities_Local( V_north, V_east, V_down );
+ // f.set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
+ // V_down_rel_ground );
+ // f.set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
+ // V_down_airmass );
+ // f.set_Velocities_Local_Rel_Airmass( V_north_rel_airmass,
+ // V_east_rel_airmass, V_down_rel_airmass );
+ // f.set_Velocities_Gust( U_gust, V_gust, W_gust );
+ // f.set_Velocities_Wind_Body( U_body, V_body, W_body );
+
+ // f.set_V_rel_wind( V_rel_wind );
+ // f.set_V_true_kts( V_true_kts );
+ // f.set_V_rel_ground( V_rel_ground );
+ // f.set_V_inertial( V_inertial );
+ // f.set_V_ground_speed( V_ground_speed );
+ // f.set_V_equiv( V_equiv );
+ f.set_V_equiv_kts( V_equiv_kts );
+ // f.set_V_calibrated( V_calibrated );
+ // f.set_V_calibrated_kts( V_calibrated_kts );
+
+ f.set_Omega_Body( P_body, Q_body, R_body );
+ // f.set_Omega_Local( P_local, Q_local, R_local );
+ // f.set_Omega_Total( P_total, Q_total, R_total );
+
+ // f.set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot );
+ f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
+
+ FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << Longitude
+ << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude
+ << " alt = " << Altitude << " sl_radius = " << Sea_level_radius
+ << " radius_to_vehicle = " << Radius_to_vehicle );
+
+ // Positions
+ f.set_Geocentric_Position( Lat_geocentric, Lon_geocentric,
+ Radius_to_vehicle );
+ f.set_Geodetic_Position( Latitude, Longitude, Altitude );
+ f.set_Euler_Angles( Phi, Theta, Psi );
+
+ // Miscellaneous quantities
+ f.set_T_Local_to_Body(T_local_to_body_m);
+ // f.set_Gravity( Gravity );
+ // f.set_Centrifugal_relief( Centrifugal_relief );
+
+ f.set_Alpha( Alpha );
+ f.set_Beta( Beta );
+ // f.set_Alpha_dot( Alpha_dot );
+ // f.set_Beta_dot( Beta_dot );
+
+ // f.set_Cos_alpha( Cos_alpha );
+ // f.set_Sin_alpha( Sin_alpha );
+ // f.set_Cos_beta( Cos_beta );
+ // f.set_Sin_beta( Sin_beta );
+
+ // f.set_Cos_phi( Cos_phi );
+ // f.set_Sin_phi( Sin_phi );
+ // f.set_Cos_theta( Cos_theta );
+ // f.set_Sin_theta( Sin_theta );
+ // f.set_Cos_psi( Cos_psi );
+ // f.set_Sin_psi( Sin_psi );
+
+ f.set_Gamma_vert_rad( Gamma_vert_rad );
+ // f.set_Gamma_horiz_rad( Gamma_horiz_rad );
+
+ // f.set_Sigma( Sigma );
+ // f.set_Density( Density );
+ // f.set_V_sound( V_sound );
+ // f.set_Mach_number( Mach_number );
+
+ // f.set_Static_pressure( Static_pressure );
+ // f.set_Total_pressure( Total_pressure );
+ // f.set_Impact_pressure( Impact_pressure );
+ // f.set_Dynamic_pressure( Dynamic_pressure );
+
+ // f.set_Static_temperature( Static_temperature );
+ // f.set_Total_temperature( Total_temperature );
+
+ f.set_Sea_level_radius( Sea_level_radius );
+ f.set_Earth_position_angle( Earth_position_angle );
+
+ f.set_Runway_altitude( Runway_altitude );
+ // f.set_Runway_latitude( Runway_latitude );
+ // f.set_Runway_longitude( Runway_longitude );
+ // f.set_Runway_heading( Runway_heading );
+ // f.set_Radius_to_rwy( Radius_to_rwy );
+
+ // f.set_CG_Rwy_Local( D_cg_north_of_rwy, D_cg_east_of_rwy, D_cg_above_rwy);
+ // f.set_CG_Rwy_Rwy( X_cg_rwy, Y_cg_rwy, H_cg_rwy );
+ // f.set_Pilot_Rwy_Local( D_pilot_north_of_rwy, D_pilot_east_of_rwy,
+ // D_pilot_above_rwy );
+ // f.set_Pilot_Rwy_Rwy( X_pilot_rwy, Y_pilot_rwy, H_pilot_rwy );
+
+ f.set_sin_lat_geocentric(Lat_geocentric);
+ f.set_cos_lat_geocentric(Lat_geocentric);
+ f.set_sin_cos_longitude(Longitude);
+ f.set_sin_cos_latitude(Latitude);
+
+ // printf("sin_lat_geo %f cos_lat_geo %f\n", sin_Lat_geoc, cos_Lat_geoc);
+ // printf("sin_lat %f cos_lat %f\n",
+ // f.get_sin_latitude(), f.get_cos_latitude());
+ // printf("sin_lon %f cos_lon %f\n",
+ // f.get_sin_longitude(), f.get_cos_longitude());
+
+ return 0;
+} */
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:34 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
----------------------------------------------------------------------------
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:33 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.3 1998/08/06 12:46:37 curt
Header change.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:33 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.4 1998/08/24 20:09:26 curt
Code optimization tweaks from Norman Vine.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:33 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.4 1998/08/24 20:09:26 curt
Code optimization tweaks from Norman Vine.
$Header$
$Log$
+Revision 1.1 1999/06/17 18:07:34 curt
+Initial revision
+
Revision 1.2 1999/04/22 18:47:25 curt
Wrap with extern "C" { } if building with __cplusplus compiler.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:34 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.3 1998/07/08 14:41:37 curt
.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:34 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.3 1998/08/06 12:46:39 curt
Header change.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:34 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.5 1998/07/12 03:11:03 curt
Removed some printf()'s.
Fixed the autopilot integration so it should be able to update it's control
/* Flight Gear Modification Log
*
* $Log$
+ * Revision 1.1 1999/06/17 18:07:33 curt
+ * Initial revision
+ *
* Revision 1.2 1999/04/27 19:28:04 curt
* Changes for the MacOS port contributed by Darrell Walisser.
*
// $Log$
-// Revision 1.1 1999/04/05 21:32:45 curt
+// Revision 1.1 1999/06/17 18:07:33 curt
// Initial revision
//
+// Revision 1.1.1.1 1999/04/05 21:32:45 curt
+// Start of 0.6.x branch.
+//
// Revision 1.11 1998/10/17 01:34:15 curt
// C++ ifying ...
//
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:34 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.1 1998/06/27 22:34:57 curt
Initial revision.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:34 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.1 1998/06/27 22:34:58 curt
Initial revision.
CURRENT RCS HEADER INFO:
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:33 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.3 1998/08/06 12:46:39 curt
Header change.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:33 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.4 1998/08/06 12:46:39 curt
Header change.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:33 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.4 1998/08/24 20:09:27 curt
Code optimization tweaks from Norman Vine.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:33 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.3 1998/08/06 12:46:40 curt
Header change.
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:33 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
* Revision 1.9 1995/03/29 16:09:56 bjax
* Fixed bug in having more than three trim controls; removed unnecessary
* call to ls_trim_init in ls_trim_get_set. EBJ
$Header$
$Log$
-Revision 1.1 1999/04/05 21:32:45 curt
+Revision 1.1 1999/06/17 18:07:34 curt
Initial revision
+Revision 1.1.1.1 1999/04/05 21:32:45 curt
+Start of 0.6.x branch.
+
Revision 1.6 1998/10/17 01:34:16 curt
C++ ifying ...
+++ /dev/null
-noinst_LIBRARIES = libSlew.a
-
-libSlew_a_SOURCES = slew.cxx slew.hxx
-
-INCLUDES += -I$(top_builddir) -I$(top_builddir)/Simulator
+++ /dev/null
-// slew.cxx -- the "slew" flight model
-//
-// Written by Curtis Olson, started May 1997.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#include <math.h>
-
-#include "slew.hxx"
-
-#include <FDM/flight.hxx>
-#include <Aircraft/aircraft.hxx>
-#include <Controls/controls.hxx>
-#include <Include/fg_constants.h>
-
-
-// reset flight params to a specific position
-void fgSlewInit(double pos_x, double pos_y, double pos_z, double heading) {
- FGInterface *f;
-
- f = current_aircraft.fdm_state;
-
- /*
- f->pos_x = pos_x;
- f->pos_y = pos_y;
- f->pos_z = pos_z;
-
- f->vel_x = 0.0;
- f->vel_y = 0.0;
- f->vel_z = 0.0;
-
- f->Phi = 0.0;
- f->Theta = 0.0;
- f->Psi = 0.0;
-
- f->vel_Phi = 0.0;
- f->vel_Theta = 0.0;
- f->vel_Psi = 0.0;
-
- f->Psi = heading;
- */
-}
-
-
-// update position based on inputs, positions, velocities, etc.
-void fgSlewUpdate( void ) {
- FGInterface *f;
- FGControls *c;
-
- f = current_aircraft.fdm_state;
- c = current_aircraft.controls;
-
- /* f->Psi += ( c->aileron / 8 );
- if ( f->Psi > FG_2PI ) {
- f->Psi -= FG_2PI;
- } else if ( f->Psi < 0 ) {
- f->Psi += FG_2PI;
- }
-
- f->vel_x = -c->elev;
-
- f->pos_x = f->pos_x + (cos(f->Psi) * f->vel_x);
- f->pos_y = f->pos_y + (sin(f->Psi) * f->vel_x); */
-}
-
-
+++ /dev/null
-// slew.hxx -- the "slew" flight model
-//
-// Written by Curtis Olson, started May 1997.
-//
-// Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _SLEW_HXX
-#define _SLEW_HXX
-
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-
-// reset flight params to a specific position
-void fgSlewInit(double pos_x, double pos_y, double pos_z, double heading);
-
-// update position based on inputs, positions, velocities, etc.
-void fgSlewUpdate( void );
-
-
-#endif // _SLEW_HXX
-
-
FG_USING_STD(string);
-#ifndef FG_HAVE_NATIVE_SGI_COMPILERS
-FG_USING_STD(cout);
-#endif
-
puFont guiFnt = 0;
fntTexFont *guiFntHandle = 0;
// Install our fast fonts
fntpath.append( "typewriter.txf" );
guiFntHandle = new fntTexFont ;
- guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
+ guiFntHandle -> load ( fntpath.c_str() ) ;
puFont GuiFont ( guiFntHandle, 15 ) ;
puSetDefaultFonts( GuiFont, GuiFont ) ;
guiFnt = puGetDefaultLabelFont();
/*
CodeWarrior compiler from Metrowerks, Inc.
*/
-# define FG_HAVE_TRAITS
-# define FG_HAVE_STD_INCLUDES
-# define FG_HAVE_STD
-# define FG_NAMESPACES
+# if (__MWERKS__ < 0x0900) //|| macintosh
+# define FG_HAVE_TRAITS
+# define FG_HAVE_STD_INCLUDES
+# define FG_HAVE_STD
+# define FG_NAMESPACES
-# define STL_ALGORITHM <algorithm>
-# define STL_FUNCTIONAL <functional>
-# define STL_IOMANIP <iomanip>
-# define STL_IOSTREAM <iostream>
-# define STL_STDEXCEPT <stdexcept>
-# define STL_STRING <string>
+# define STL_ALGORITHM <algorithm>
+# define STL_FUNCTIONAL <functional>
+# define STL_IOMANIP <iomanip>
+# define STL_IOSTREAM <iostream>
+# define STL_STDEXCEPT <stdexcept>
+# define STL_STRING <string>
// Temp:
-# define bcopy(from, to, n) memcpy(to, from, n)
+# define bcopy(from, to, n) memcpy(to, from, n)
// -rp- please use FG_MEM_COPY everywhere !
-# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
+# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
// -dw- currently used glut has no game mode stuff
-# define GLUT_WRONG_VERSION
+# define GLUT_WRONG_VERSION
+
+# elif (__MWERKS__ >= 0x0900) && __INTEL__
+# error still to be supported...
+# else
+# error unknown Metrowerks compiler
+# endif
#endif
//
+++ /dev/null
-/* Include/config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define to empty if the keyword does not work. */
-#undef const
-
-/* Define if you don't have vprintf but do have _doprnt. */
-#undef HAVE_DOPRNT
-
-/* Define if you have the vprintf function. */
-#undef HAVE_VPRINTF
-
-/* Define as the return type of signal handlers (int or void). */
-#undef RETSIGTYPE
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-#undef size_t
-
-/* Define if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
-/* Define if your <sys/time.h> declares struct tm. */
-#undef TM_IN_SYS_TIME
-
-/* Define if the X Window System is missing or not being used. */
-#undef X_DISPLAY_MISSING
-
-/* Define to empty if the keyword does not work. */
-#undef const
-
-/* Define to eliminate all trace of debugging messages such as for a
- release build */
-#undef FG_NDEBUG
-
-/* Define if you don't have vprintf but do have _doprnt. */
-#undef HAVE_DOPRNT
-
-/* Define if you have the vprintf function. */
-#undef HAVE_VPRINTF
-
-/* Define to package name */
-#undef PACKAGE
-
-/* Define as the return type of signal handlers (int or void). */
-#undef RETSIGTYPE
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-#undef size_t
-
-/* Define if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#undef TIME_WITH_SYS_TIME
-
-/* Define if your <sys/time.h> declares struct tm. */
-#undef TM_IN_SYS_TIME
-
-/* Define to version number */
-#undef VERSION
-
-/* Define if compiling on a Winbloze (95, NT, etc.) platform */
-#undef WIN32
-
-/* Define if the X Window System is missing or not being used. */
-#undef X_DISPLAY_MISSING
-
-/* Define if you have the GetLocalTime function. */
-#undef HAVE_GETLOCALTIME
-
-/* Define if you have the bcopy function. */
-#undef HAVE_BCOPY
-
-/* Define if you have the ftime function. */
-#undef HAVE_FTIME
-
-/* Define if you have the getitimer function. */
-#undef HAVE_GETITIMER
-
-/* Define if you have the getrusage function. */
-#undef HAVE_GETRUSAGE
-
-/* Define if you have the gettimeofday function. */
-#undef HAVE_GETTIMEOFDAY
-
-/* Define if you have the memcpy function. */
-#undef HAVE_MEMCPY
-
-/* Define if you have the mktime function. */
-#undef HAVE_MKTIME
-
-/* Define if you have the rand function. */
-#undef HAVE_RAND
-
-/* Define if you have the random function. */
-#undef HAVE_RANDOM
-
-/* Define if you have the rint function. */
-#undef HAVE_RINT
-
-/* Define if you have the setitimer function. */
-#undef HAVE_SETITIMER
-
-/* Define if you have the signal function. */
-#undef HAVE_SIGNAL
-
-/* Define if you have the strstr function. */
-#undef HAVE_STRSTR
-
-/* Define if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
-/* Define if you have the <getopt.h> header file. */
-#undef HAVE_GETOPT_H
-
-/* Define if you have the <gfc/gdbf.h> header file. */
-#undef HAVE_GFC_GDBF_H
-
-/* Define if you have the <gpc.h> header file. */
-#undef HAVE_GPC_H
-
-/* Define if you have the <malloc.h> header file. */
-#undef HAVE_MALLOC_H
-
-/* Define if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
-/* Define if you have the <sys/timeb.h> header file. */
-#undef HAVE_SYS_TIMEB_H
-
-/* Define if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define if you have the <values.h> header file. */
-#undef HAVE_VALUES_H
-
-/* Define if you have the <winbase.h> header file. */
-#undef HAVE_WINBASE_H
-
-/* Define if you have the <windows.h> header file. */
-#undef HAVE_WINDOWS_H
-
-/* Define if you have the GL library (-lGL). */
-#undef HAVE_LIBGL
-
-/* Define if you have the GLU library (-lGLU). */
-#undef HAVE_LIBGLU
-
-/* Define if you have the GLcore library (-lGLcore). */
-#undef HAVE_LIBGLCORE
-
-/* Define if you have the ICE library (-lICE). */
-#undef HAVE_LIBICE
-
-/* Define if you have the MesaGL library (-lMesaGL). */
-#undef HAVE_LIBMESAGL
-
-/* Define if you have the MesaGLU library (-lMesaGLU). */
-#undef HAVE_LIBMESAGLU
-
-/* Define if you have the SM library (-lSM). */
-#undef HAVE_LIBSM
-
-/* Define if you have the X11 library (-lX11). */
-#undef HAVE_LIBX11
-
-/* Define if you have the Xext library (-lXext). */
-#undef HAVE_LIBXEXT
-
-/* Define if you have the Xi library (-lXi). */
-#undef HAVE_LIBXI
-
-/* Define if you have the Xmu library (-lXmu). */
-#undef HAVE_LIBXMU
-
-/* Define if you have the Xt library (-lXt). */
-#undef HAVE_LIBXT
-
-/* Define if you have the glut library (-lglut). */
-#undef HAVE_LIBGLUT
-
-/* Define if you have the m library (-lm). */
-#undef HAVE_LIBM
-
-/* Define if you have the socket library (-lsocket). */
-#undef HAVE_LIBSOCKET
// Alterations: Copyright C. Hotchkiss 1996
//
// $Log$
+// Revision 1.1 1999/06/17 18:07:30 curt
+// Initial revision
+//
// Revision 1.2 1999/04/22 18:45:42 curt
// Borland tweaks.
//
// Parse config file options
int fgOPTIONS::parse_config_file( const string& path ) {
fg_gzifstream in( path );
- if ( !in.is_open() )
+ if ( !in )
return(FG_OPTIONS_ERROR);
FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path );
in >> skipcomment;
-#ifndef __MWERKS__
- while ( ! in.eof() ) {
-#else
- char c = '\0';
- while ( in.get(c) && c != '\0' ) {
- in.putback(c);
-#endif
+ while ( !in.eof() ) {
string line;
#ifdef GETLINE_NEEDS_TERMINATOR
int xsize = 480;
int ysize = 380;
- if ( !current_view.get_winWidth() || !current_view.get_winHeight() ) {
- return;
- }
-
xmin = (current_view.get_winWidth() - xsize) / 2;
xmax = xmin + xsize;
+++ /dev/null
-SUBDIRS = \
- Aircraft \
- Airports \
- Astro \
- Autopilot \
- Cockpit \
- Controls \
- FDM \
- GUI \
- Joystick \
- Objects \
- Scenery \
- Time \
- Weather \
- Main
mpath.append( "materials" );
fg_gzifstream in( mpath.str() );
- if ( ! in.is_open() ) {
+ if ( ! in ) {
FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << mpath.str() );
exit(-1);
}
-#ifndef __MWERKS__
while ( ! in.eof() ) {
-#else
- char c = '\0';
- while ( in.get(c) && c != '\0' ) {
- in.putback(c);
-#endif
// printf("%s", line);
// strip leading white space and comments
// ignore initial comments and blank lines. (priming the pump)
// in >> skipcomment;
- // string line;
+ string line;
- string token;
- char c;
-
-#ifdef __MWERKS__
- while ( in.get(c) && c != '\0' ) {
- in.putback(c);
-#else
while ( ! in.eof() ) {
-#endif
+ string token;
+ char c;
-#ifdef __MWERKS__
+#if defined( MACOS )
in >> ::skipws;
#else
in >> skipws;