1
0
Fork 0

Initial revision

This commit is contained in:
curt 1999-06-17 20:07:19 +00:00
parent c90db01dc8
commit 14a8533f63
123 changed files with 1400 additions and 6082 deletions

339
COPYING
View file

@ -1,339 +0,0 @@
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.
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.)
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.
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.
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
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.

183
INSTALL
View file

@ -1,183 +0,0 @@
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.

View file

@ -1,103 +0,0 @@
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

32
NEWS
View file

@ -1,35 +1,3 @@
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,

View file

@ -8,9 +8,9 @@ FlightGear up and running under Linux.
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!
@ -49,45 +49,6 @@ need"
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:
@ -133,9 +94,15 @@ This will install the binaries in /usr/local/bin. Notice that the name
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
@ -228,6 +195,4 @@ adjusted for your specific architecture:
export CFLAGS="-mieee -mcpu=ev56 -Wa,-m21164a -pipe -g"
export CXXFLAGS="-mieee -mcpu=ev56 -Wa,-m21164a -pipe -g"
./configure
./configure

2
Thanks
View file

@ -136,7 +136,7 @@ Bob Kuehne <rpk@sgi.com>
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.

0
config.guess vendored Executable file → Normal file
View file

0
config.sub vendored Executable file → Normal file
View file

View file

@ -1,357 +0,0 @@
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])

View file

@ -1,250 +0,0 @@
#!/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

View file

@ -1,16 +0,0 @@
#!/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";

134
missing
View file

@ -1,134 +0,0 @@
#! /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

View file

@ -1,40 +0,0 @@
#! /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

View file

@ -27,7 +27,6 @@
#include <Include/compiler.h>
#include <Debug/logstream.hxx>
#include <Misc/fgpath.hxx>
#include <Misc/fgstream.hxx>
#include <Main/options.hxx>
@ -47,15 +46,13 @@ int fgAIRPORTS::load( const string& file ) {
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);
}
@ -68,29 +65,14 @@ int fgAIRPORTS::load( const string& file ) {
*/
// read in each line of the file
#ifdef __MWERKS__
in >> skipcomment;
char c = 0;
while ( in.get(c) && c != '\0' ) {
in.putback(c);
while ( ! in.eof() )
{
in >> a;
airports.insert(a);
in >> skipcomment;
}
#else
in >> skipcomment;
while ( ! in.eof() ) {
in >> a;
airports.insert(a);
in >> skipcomment;
}
#endif
return 1;
}

View file

@ -1,19 +0,0 @@
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

View file

@ -1,176 +0,0 @@
/**************************************************************************
* 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;
}

View file

@ -1,195 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,65 +0,0 @@
/**************************************************************************
* 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;
}

View file

@ -1,38 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,59 +0,0 @@
/**************************************************************************
* 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;
}

View file

@ -1,38 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,61 +0,0 @@
/**************************************************************************
* 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);
}

View file

@ -1,38 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,401 +0,0 @@
/**************************************************************************
* 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 = &current_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
{
}
}

View file

@ -1,56 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,59 +0,0 @@
/**************************************************************************
* 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;
}

View file

@ -1,38 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,36 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,69 +0,0 @@
/**************************************************************************
* 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;
}

View file

@ -1,45 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,367 +0,0 @@
// 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();
}

View file

@ -1,45 +0,0 @@
// 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

View file

@ -1,215 +0,0 @@
/**************************************************************************
* 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();
}

View file

@ -1,91 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,271 +0,0 @@
/**************************************************************************
* 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
}
}

View file

@ -1,98 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,267 +0,0 @@
// 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");
}
}

View file

@ -1,47 +0,0 @@
// 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

View file

@ -1,60 +0,0 @@
/**************************************************************************
* 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;
}

View file

@ -1,38 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1,60 +0,0 @@
/**************************************************************************
* 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);
}

View file

@ -1,38 +0,0 @@
/**************************************************************************
* 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_

View file

@ -1103,7 +1103,7 @@ void fgUpdateHUD( void ) {
}
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();

View file

@ -57,7 +57,6 @@
FG_USING_STD(deque);
FG_USING_STD(vector);
FG_USING_NAMESPACE(std);
#ifndef WIN32
typedef struct {
@ -234,9 +233,12 @@ extern float HUD_matrix[16];
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);}
@ -432,7 +434,7 @@ class instr_item { // An Abstract Base Class (ABC)
}
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 )
{

View file

@ -1,5 +0,0 @@
noinst_LIBRARIES = libExternal.a
libExternal_a_SOURCES = external.cxx external.hxx
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Simulator

View file

@ -1,42 +0,0 @@
// 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 ) {
}

View file

@ -1,83 +0,0 @@
// 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

View file

@ -65,7 +65,7 @@ int fgJSBsimInit(double dt) {
FGPath engine_path( current_options.get_fg_root() );
engine_path.append( "Engine" );
FDMExec.GetAircraft()->LoadAircraft(aircraft_path.str(),
FDMExec.GetAircraft()->LoadAircraftEx(aircraft_path.str(),
engine_path.str(), "X15");
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" );

View file

@ -94,6 +94,43 @@ Control
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
*******************************************************************************/
@ -143,7 +180,7 @@ FGAircraft::~FGAircraft(void)
{
}
bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname)
bool FGAircraft::LoadAircraftEx(string aircraft_path, string engine_path, string fname)
{
string path;
string fullpath;
@ -153,11 +190,7 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
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;
@ -168,11 +201,9 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
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.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") {
@ -238,63 +269,97 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
} else if (holding_string == "LIFT") {
axis_descript = " Lift Coefficients ...";
axis = LiftCoeff;
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") {
axis_descript = " Drag Coefficients ...";
axis = DragCoeff;
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") {
axis_descript = " Side Coefficients ...";
axis = SideCoeff;
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") {
axis_descript = " Roll Coefficients ...";
axis = RollCoeff;
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") {
axis_descript = " Pitch Coefficients ...";
axis = PitchCoeff;
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") {
axis_descript = " Yaw Coefficients ...";
axis = YawCoeff;
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 {
}
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;
return true;
}
@ -385,14 +450,9 @@ void FGAircraft::FAero(void)
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);
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);
}

509
src/FDM/JSBSim/FGAircraft.h Normal file
View file

@ -0,0 +1,509 @@
/*******************************************************************************
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

View file

@ -71,17 +71,8 @@ bool FGAtmosphere::Run(void)
+ 7.0E-13*State->Geth()*State->Geth()
- 2.0E-18*State->Geth()*State->Geth()*State->Geth();
State->SetMach(State->GetVt()/State->Geta());
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);
}

View file

@ -58,12 +58,26 @@ 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;}
float CalcRho(float altitude);
protected:

View file

@ -30,6 +30,69 @@ 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.
@ -62,29 +125,10 @@ INCLUDES
FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile)
{
int r, c, start, end, n;
int r, c;
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();
@ -119,51 +163,19 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile)
coeffDefFile >> columns;
cout << "Cols: " << columns;
}
coeffDefFile >> LookupR;
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;
}
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());
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;
@ -244,23 +256,12 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile)
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);
@ -282,7 +283,6 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile)
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++) {
@ -299,7 +299,7 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile)
}
cout << endl;
}
break;
}
} else {
@ -353,11 +353,15 @@ float FGCoefficient::Value(float rVal, float cVal)
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;
}
@ -368,7 +372,7 @@ float FGCoefficient::Value(float Val)
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);
@ -381,10 +385,14 @@ float FGCoefficient::Value(float Val)
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;
}
@ -396,10 +404,14 @@ float FGCoefficient::Value(void)
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;
}
@ -424,42 +436,53 @@ 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();
case FG_BI2VEL:
return Aircraft->GetWingSpan()/(2.0 * State->GetVt());
case FG_CI2VEL:
return Aircraft->Getcbar()/(2.0 * State->GetVt());
}
return 0;
}

View file

@ -51,8 +51,6 @@ INCLUDES
# include <fstream>
#endif
#include <map>
/*******************************************************************************
DEFINES
*******************************************************************************/
@ -75,8 +73,6 @@ using namespace std;
#define FG_RUDDER 8192
#define FG_MACH 16384
#define FG_ALTITUDE 32768L
#define FG_BI2VEL 65536L
#define FG_CI2VEL 131072L
/*******************************************************************************
FORWARD DECLARATIONS
@ -94,11 +90,81 @@ 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
@ -115,31 +181,83 @@ FG_AILERON 4096
FG_RUDDER 8192
FG_MACH 16384
FG_ALTITUDE 32768L
FG_BI2VEL 65536L
FG_CI2VEL 131072L
********************************************************************************
</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:
typedef map<string, long> CoeffMap;
CoeffMap coeffdef;
string filename;
string description;
string name;

View file

@ -51,8 +51,11 @@ FGControls::~FGControls() {
// $Log$
// Revision 1.6 1999/06/29 15:30:33 curt
// Updated contributed by Jon Berndt.
// 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.

View file

@ -177,8 +177,11 @@ extern FGControls controls;
// $Log$
// Revision 1.6 1999/06/29 15:30:35 curt
// Updated contributed by Jon Berndt.
// 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.

View file

@ -76,4 +76,4 @@ private:
};
/******************************************************************************/
#endif
#endif

View file

@ -115,7 +115,7 @@ FGFDMExec::FGFDMExec(void)
Schedule(Translation, 1);
Schedule(Position, 1);
Schedule(Auxiliary, 1);
Schedule(Output, 1);
Schedule(Output, 5);
terminate = false;
frozen = false;

View file

@ -59,8 +59,8 @@ class FGOutput;
class FGFDMExec
{
public:
FGFDMExec::FGFDMExec(void);
FGFDMExec::~FGFDMExec(void);
FGFDMExec(void);
~FGFDMExec(void);
FGModel* FirstModel;

View file

@ -16,8 +16,8 @@ void main(int argc, char** argv)
{
FGFDMExec* FDMExec;
// struct timespec short_wait = {0,100000000};
// struct timespec no_wait = {0,100000000};
struct timespec short_wait = {0,100000000};
struct timespec no_wait = {0,100000000};
if (argc != 3) {
cout << endl
@ -28,7 +28,7 @@ void main(int argc, char** argv)
FDMExec = new FGFDMExec();
FDMExec->GetAircraft()->LoadAircraft("aircraft", "engine", string(argv[1]));
FDMExec->GetAircraft()->LoadAircraftEx("aircraft", "engine", string(argv[1]));
FDMExec->GetState()->Reset("aircraft", string(argv[2]));
while (FDMExec->GetState()->Getsim_time() <= 25.0)
@ -38,13 +38,13 @@ void main(int argc, char** argv)
//
if (FDMExec->GetState()->Getsim_time() > 5.0) {
FDMExec->GetFCS()->SetDa(0.05);
FDMExec->GetFCS()->SetDr(0.05);
FDMExec->GetFCS()->SetDe(0.05);
// FDMExec->GetFCS()->SetDr(0.05);
// FDMExec->GetFCS()->SetDa(0.05);
}
FDMExec->Run();
// nanosleep(&short_wait,&no_wait);
nanosleep(&short_wait,&no_wait);
}
delete FDMExec;

View file

@ -120,8 +120,8 @@ FGMatrix& FGMatrix::operator=(const FGMatrix& A)
data = A.data;
} else {
data = alloc(rows,cols);
for (unsigned int i=0; i<=rows; i++) {
for (unsigned int j=0; j<=cols; j++) {
for (int i=0; i<=rows; i++) {
for (int j=0; j<=cols; j++) {
data[i][j] = A.data[i][j];
}
}
@ -161,8 +161,8 @@ void FGMatrix::SetOParams(char delim,int width,int prec,int origin)
void FGMatrix::InitMatrix(double value)
{
if (data) {
for (unsigned int i=0;i<=rows;i++) {
for (unsigned int j=0;j<=cols;j++) {
for (int i=0;i<=rows;i++) {
for (int j=0;j<=cols;j++) {
operator()(i,j) = value;
}
}
@ -187,8 +187,8 @@ FGMatrix operator-(FGMatrix& A, FGMatrix& B)
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++) {
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);
}
}
@ -205,8 +205,8 @@ void operator-=(FGMatrix &A,FGMatrix &B)
exit(1);
}
for (unsigned int i=1;i<=A.Rows();i++) {
for (unsigned int j=1;j<=A.Cols();j++) {
for (int i=1;i<=A.Rows();i++) {
for (int j=1;j<=A.Cols();j++) {
A(i,j)-=B(i,j);
}
}
@ -224,8 +224,8 @@ FGMatrix operator+(FGMatrix& A, FGMatrix& B)
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++) {
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);
}
}
@ -241,8 +241,8 @@ void operator+=(FGMatrix &A,FGMatrix &B)
cout << endl;
exit(1);
}
for (unsigned int i=1;i<=A.Rows();i++) {
for (unsigned int j=1;j<=A.Cols();j++) {
for (int i=1;i<=A.Rows();i++) {
for (int j=1;j<=A.Cols();j++) {
A(i,j)+=B(i,j);
}
}
@ -253,8 +253,8 @@ 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++) {
for (int i=1;i<=A.Rows();i++) {
for (int j=1;j<=A.Cols();j++) {
Product(i,j) = scalar*A(i,j);
}
}
@ -264,8 +264,8 @@ FGMatrix operator*(double scalar,FGMatrix &A)
void operator*=(FGMatrix &A,double scalar)
{
for (unsigned int i=1;i<=A.Rows();i++) {
for (unsigned int j=1;j<=A.Cols();j++) {
for (int i=1;i<=A.Rows();i++) {
for (int j=1;j<=A.Cols();j++) {
A(i,j)*=scalar;
}
}
@ -284,10 +284,10 @@ FGMatrix operator*(FGMatrix &Left, FGMatrix &Right)
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++) {
for (int i=1;i<=Left.Rows();i++) {
for (int j=1;j<=Right.Cols();j++) {
Product(i,j) = 0;
for (unsigned int k=1;k<=Left.Cols();k++) {
for (int k=1;k<=Left.Cols();k++) {
Product(i,j)+=Left(i,k)*Right(k,j);
}
}
@ -309,10 +309,10 @@ void operator*=(FGMatrix &Left,FGMatrix &Right)
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++) {
for (int i=1;i<=Left.Rows();i++) {
for (int j=1;j<=Right.Cols();j++) {
prod[i][j] = 0;
for (unsigned int k=1;k<=Left.Cols();k++) {
for (int k=1;k<=Left.Cols();k++) {
prod[i][j]+=Left(i,k)*Right(k,j);
}
}
@ -327,8 +327,8 @@ 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++) {
for (int i=1;i<=A.Rows();i++) {
for (int j=1;j<=A.Cols();j++) {
Quot(i,j)=A(i,j)/scalar;
}
}
@ -338,8 +338,8 @@ FGMatrix operator/(FGMatrix& A, double scalar)
void operator/=(FGMatrix &A,double scalar)
{
for (unsigned int i=1;i<=A.Rows();i++) {
for (unsigned int j=1;j<=A.Cols();j++) {
for (int i=1;i<=A.Rows();i++) {
for (int j=1;j<=A.Cols();j++) {
A(i,j)/=scalar;
}
}
@ -357,8 +357,8 @@ void FGMatrix::T(void)
void FGMatrix::TransposeSquare(void)
{
for (unsigned int i=1;i<=rows;i++) {
for (unsigned int j=i+1;j<=cols;j++) {
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;
@ -372,8 +372,8 @@ 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++) {
for (int i=1;i<=rows;i++) {
for (int j=1;j<=cols;j++) {
tran[j][i]=data[i][j];
}
}

View file

@ -190,9 +190,9 @@ void FGOutput::DelimitedOutput(void)
cout << "Latitude,";
cout << "Longitude,";
cout << "QBar,";
cout << "Alpha,";
cout << "L,";
cout << "M,";
cout << "Alpha";
cout << "L";
cout << "M";
cout << "N";
cout << endl;
FirstPass = false;

View file

@ -130,7 +130,7 @@ bool FGState::Reset(string path, string fname)
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);
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);

View file

@ -76,7 +76,7 @@ FGUtility::~FGUtility()
float FGUtility::ToGeodetic()
{
float Latitude, Radius, Altitude;
float GeodeticLat, Latitude, Radius, Altitude;
float tanLat, xAlpha, muAlpha, sinmuAlpha, denom, rhoAlpha, dMu;
float lPoint, lambdaSL, sinlambdaSL, dLambda, rAlpha;
@ -85,6 +85,8 @@ float FGUtility::ToGeodetic()
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 /
@ -102,7 +104,7 @@ float FGUtility::ToGeodetic()
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));
lambdaSL = atan(ECCENTSQRD*tan(GeodeticLat));
sinlambdaSL = sin(lambdaSL);
SeaLevelR = sqrt(EARTHRADSQRD / (1 + INVECCENTSQRDM1* sinlambdaSL*sinlambdaSL));
}
@ -113,9 +115,8 @@ float FGUtility::ToGeodetic()
float FGUtility:: FromGeodetic()
{
float lambdaSL, sinlambdaSL, coslambdaSL, sinMu, cosMu, py, px;
float Altitude, SeaLevelR, Radius;
float Altitude, SeaLevelR;
Radius = State->Geth() + EARTHRAD;
lambdaSL = atan(ECCENTSQRD*tan(State->GetGeodeticLat()));
sinlambdaSL = sin(lambdaSL);
coslambdaSL = cos(lambdaSL);
@ -123,7 +124,6 @@ float FGUtility:: FromGeodetic()
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));

View file

@ -42,7 +42,7 @@ INCLUDES
DEFINES
*******************************************************************************/
using namespace std;
// FG_USING_STD(std);
/*******************************************************************************
CLASS DECLARATION

View file

@ -1,206 +0,0 @@
/*******************************************************************************
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

View file

@ -88,8 +88,6 @@
#include "ls_cockpit.h"
#include "ls_constants.h"
#include "ls_types.h"
#include "c172_aero.h"
#include <math.h>
#include <stdio.h>
@ -106,7 +104,7 @@
extern COCKPIT cockpit_;
FILE *out;
SCALAR interp(SCALAR *y_table, SCALAR *x_table, int Ntable, SCALAR x)
{
@ -123,11 +121,9 @@ 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*/
{
@ -139,67 +135,97 @@ SCALAR interp(SCALAR *y_table, SCALAR *x_table, int Ntable, SCALAR x)
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;
/* printf("Initialize= %d\n",Initialize); */
/* printf("Initializing aero model...Initialize= %d\n", Initialize);
*/ CLadot=1.7;
CLq=3.9;
CLde=0.43;
CLo=0;
if (Initialize != 0)
{
out=fopen("flight.csv","w");
/* Initialize aero coefficients */
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:
@ -212,47 +238,38 @@ void aero( SCALAR dt, int Initialize ) {
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; }
Cg=Dx_cg/cbar +0.25;
Dz_cg=Zcg*cbar;
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*/
/*scale pct control to degrees deflection*/
if ((Long_control+long_trim) <= 0)
elevator=(Long_control+long_trim)*28*DEG_TO_RAD;
elevator=(Long_control+long_trim)*-28*DEG_TO_RAD;
else
elevator=(Long_control+long_trim)*23*DEG_TO_RAD;
aileron = -1*Lat_control*17.5*DEG_TO_RAD;
rudder = -1*Rudder_pedal*16*DEG_TO_RAD;
aileron = Lat_control*17.5*DEG_TO_RAD;
rudder = Rudder_pedal*16*DEG_TO_RAD;
/*check control surface travel limits*/
/* if((elevator+long_trim) > 23)
elevator=23;
else if((elevator+long_trim) < -28)
elevator=-23; */
/*
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*/
@ -269,55 +286,50 @@ void aero( SCALAR dt, int Initialize ) {
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;
M_l_aero = I_xx*croll*qSb;
M_m_aero = I_yy*cm*qScbar;
M_n_aero = I_zz*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);
*/
}

View file

@ -65,7 +65,6 @@ $Header$
#include "ls_generic.h"
#include "ls_sim_control.h"
#include "ls_cockpit.h"
#include "c172_aero.h"
extern SIM_CONTROL sim_control_;
@ -76,10 +75,8 @@ void engine( SCALAR dt, int init ) {
/* 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];
}

View file

@ -12,7 +12,8 @@
----------------------------------------------------------------------------
GENEALOGY: Created 931012 by E. B. Jackson
GENEALOGY: Renamed navion_gear.c originally created 931012 by E. B. Jackson
----------------------------------------------------------------------------
@ -36,8 +37,36 @@
$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.
----------------------------------------------------------------------------
@ -68,48 +97,47 @@ Updated Tony's c172 model code.
#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$";
/*
@ -195,7 +223,8 @@ 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;

View file

@ -63,7 +63,7 @@
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;

View file

@ -28,423 +28,7 @@
#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
@ -455,85 +39,60 @@ int fgLaRCsimInit(double dt) {
}
// 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;
}
@ -713,7 +272,142 @@ int FGInterface_2_LaRCsim (FGInterface& f) {
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;
} */

View file

@ -36,9 +36,12 @@
$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.
----------------------------------------------------------------------------

View file

@ -33,9 +33,12 @@
$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.

View file

@ -38,9 +38,12 @@
$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.

View file

@ -47,9 +47,12 @@
$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.

View file

@ -35,6 +35,9 @@
$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.

View file

@ -40,9 +40,12 @@
$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
.

View file

@ -35,9 +35,12 @@
$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.

View file

@ -34,9 +34,12 @@
$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

Some files were not shown because too many files have changed in this diff Show more