home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-13 | 55.3 KB | 1,621 lines |
- Newsgroups: comp.sources.misc
- From: sham@cs.arizona.edu ("Shamim Zvonko Mohamed")
- Subject: v31i028: plotfoil - Plot curves (airfoils) using PostScript, Part01/03
- Message-ID: <csm-v31i028=plotfoil.155848@sparky.IMD.Sterling.COM>
- X-Md4-Signature: 6188e82fc3cf6208d15973797431874a
- Date: Mon, 13 Jul 1992 21:00:11 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: sham@cs.arizona.edu ("Shamim Zvonko Mohamed")
- Posting-number: Volume 31, Issue 28
- Archive-name: plotfoil/part01
- Environment: UNIX,VMS,DOS,SGI,Sun,PC
-
- This is a program that reads in airfoil data and generates PostScript code
- that will plot the airfoil on a PS printer. It interpolates between points
- and can understand the two most popular formats for airfoil data (sample data
- is included). It has various options for chord size, spar locations, sheeting
- allowances, and can also do multi-page plots (e.g. chord size > 11 inches).
- It has run on every system that I could find with a C compiler. The code
- generated has also printed on every PS printer I've tried. The README has
- details.
-
- Shamim Mohamed / {uunet,noao,cmcl2..}!arizona!shamim / shamim@cs.arizona.edu
- ---
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 3)."
- # Contents: plotfoil plotfoil/COPYING plotfoil/README
- # plotfoil/airfoils plotfoil/makefile plotfoil/makefile.dos
- # plotfoil/makefile.vms plotfoil/plotfoil.1 plotfoil/plotfoil.c
- # plotfoil/spline.c
- # Wrapped by sham@gilamonster on Thu Jul 9 14:52:00 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test ! -d 'plotfoil' ; then
- echo shar: Creating directory \"'plotfoil'\"
- mkdir 'plotfoil'
- fi
- if test -f 'plotfoil/COPYING' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plotfoil/COPYING'\"
- else
- echo shar: Extracting \"'plotfoil/COPYING'\" \(18054 characters\)
- sed "s/^X//" >'plotfoil/COPYING' <<'END_OF_FILE'
- X GNU GENERAL PUBLIC LICENSE
- X Version 2, June 1991
- X
- X Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X Preamble
- X
- X 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
- XFoundation'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.
- X
- X 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.
- X
- X 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.
- X
- X 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.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- X(2) offer you this license which gives you legal permission to copy,
- distribute and/or modify the software.
- X
- X 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.
- X
- X 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.
- X
- X The precise terms and conditions for copying, distribution and
- modification follow.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X GNU GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 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".
- X
- 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.
- X
- X 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.
- X
- 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.
- X
- X 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:
- X
- X a) You must cause the modified files to carry prominent notices
- X stating that you changed the files and the date of any change.
- X
- X b) You must cause any work that you distribute or publish, that in
- X whole or in part contains or is derived from the Program or any
- X part thereof, to be licensed as a whole at no charge to all third
- X parties under the terms of this License.
- X
- X c) If the modified program normally reads commands interactively
- X when run, you must cause it, when started running for such
- X interactive use in the most ordinary way, to print or display an
- X announcement including an appropriate copyright notice and a
- X notice that there is no warranty (or else, saying that you provide
- X a warranty) and that users may redistribute the program under
- X these conditions, and telling the user how to view a copy of this
- X License. (Exception: if the Program itself is interactive but
- X does not normally print such an announcement, your work based on
- X the Program is not required to print an announcement.)
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- 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.
- X
- 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.
- X
- 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.
- X
- X 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:
- X
- X a) Accompany it with the complete corresponding machine-readable
- X source code, which must be distributed under the terms of Sections
- X 1 and 2 above on a medium customarily used for software interchange; or,
- X
- X b) Accompany it with a written offer, valid for at least three
- X years, to give any third party, for a charge no more than your
- X cost of physically performing source distribution, a complete
- X machine-readable copy of the corresponding source code, to be
- X distributed under the terms of Sections 1 and 2 above on a medium
- X customarily used for software interchange; or,
- X
- X c) Accompany it with the information you received as to the offer
- X to distribute corresponding source code. (This alternative is
- X allowed only for noncommercial distribution and only if you
- X received the program in object code or executable form with such
- X an offer, in accord with Subsection b above.)
- X
- 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.
- X
- 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.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X 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.
- X
- X 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.
- X
- X 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.
- X
- X 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.
- X
- 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.
- X
- 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.
- X
- This section is intended to make thoroughly clear what is believed to
- be a consequence of the rest of this License.
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X 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.
- X
- X 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.
- X
- XEach 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
- XFoundation.
- X
- X 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.
- X
- X NO WARRANTY
- X
- X 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- XFOR 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.
- X
- X 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.
- X
- X END OF TERMS AND CONDITIONS
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X Appendix: How to Apply These Terms to Your New Programs
- X
- X 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.
- X
- X 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.
- X
- X <one line to give the program's name and a brief idea of what it does.>
- X Copyright (C) 19yy <name of author>
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 2 of the License, or
- X (at your option) any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- Also add information on how to contact you by electronic and paper mail.
- X
- If the program is interactive, make it output a short notice like this
- when it starts in an interactive mode:
- X
- X Gnomovision version 69, Copyright (C) 19yy name of author
- X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- X This is free software, and you are welcome to redistribute it
- X under certain conditions; type `show c' for details.
- X
- 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.
- X
- 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:
- X
- X Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- X `Gnomovision' (which makes passes at compilers) written by James Hacker.
- X
- X <signature of Ty Coon>, 1 April 1989
- X Ty Coon, President of Vice
- X
- 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.
- END_OF_FILE
- if test 18054 -ne `wc -c <'plotfoil/COPYING'`; then
- echo shar: \"'plotfoil/COPYING'\" unpacked with wrong size!
- fi
- # end of 'plotfoil/COPYING'
- fi
- if test -f 'plotfoil/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plotfoil/README'\"
- else
- echo shar: Extracting \"'plotfoil/README'\" \(2041 characters\)
- sed "s/^X//" >'plotfoil/README' <<'END_OF_FILE'
- X
- Copyright 1992 Shamim P. Mohamed
- X
- This is the "plotfoil" package (V2.1) for plotting airfoil sections from data.
- It generates PostScript, does interpolation, spars, templates and allowances
- for sheeting. For more info on the formats supported and options, see the
- comments in plotfoil.man. The PostScript generated is quite vanilla, and
- should print on any printer. Some printers may run out of memory trying to
- print multi-page plots with lots of data. If that happens, recompile plotfoil
- with -DSAVEMEM, which may help. Otherwise, your only hope is either find
- another printer or try removing some of the input data.
- X
- The PostScript is sent to standard output. Use redirection or a pipe to send
- it to the printer.
- X
- This program runs on all the Unix platforms I've tried, i.e. Sun3, Sun4
- X(SparcStation 1, 1+, 2, LSC, SLX), SGI (personal Iris and 4D systems), NeXT,
- Sequent Symmetry, VAX/BSD. It also runs on MS-DOS (AT, PS/2 50, 70, 80; MS C
- compiler, Turbo C++) and VMS (VAX, DEC4000). It has worked on the following
- printers: Apple LaserWriters (Plus, II and NTX), NEC LC890, LC890XL, HP
- LaserJet, QMS PS2000 and PS2200, NeWSprint/SPARCprinter, DEC LN03
- Scriptprinter.
- X
- Please send any changes to me. This program is distributed under the terms of
- the Gnu General Public License Version 2 as published by the Free Software
- XFoundation. You can give away copies of this program to whoever you like, as
- long as you provide them with source code and all the copyright notices and
- licences stay with it. Also, if you make any changes to this program, the same
- conditions apply to the modified version so that we can all benefit from them.
- X(And please send me those changes!) See the file COPYING for more details.
- X
- X(The airfoil data are not covered by this license; they are in the public
- domain)
- X
- Shamim Mohamed
- shamim@cs.arizona.edu Dept. of Computer Science
- X{uunet,cmcl2,noao,...}!arizona!shamim University of Arizona
- May 1992 Tucson, AZ 85721
- X
- Voice: +1 602 621 6613
- XFax: +1 602 621 4246
- END_OF_FILE
- if test 2041 -ne `wc -c <'plotfoil/README'`; then
- echo shar: \"'plotfoil/README'\" unpacked with wrong size!
- fi
- # end of 'plotfoil/README'
- fi
- if test ! -d 'plotfoil/airfoils' ; then
- echo shar: Creating directory \"'plotfoil/airfoils'\"
- mkdir 'plotfoil/airfoils'
- fi
- if test -f 'plotfoil/makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plotfoil/makefile'\"
- else
- echo shar: Extracting \"'plotfoil/makefile'\" \(329 characters\)
- sed "s/^X//" >'plotfoil/makefile' <<'END_OF_FILE'
- X#
- X# Makefile for plotfoil
- X#
- X
- X#CC = gcc
- X#CFLAGS = -g -O
- X
- CFLAGS = -O
- X
- plotfoil : plotfoil.o spline.o
- X $(CC) $(CFLAGS) -o plotfoil plotfoil.o spline.o -lm
- X
- lint :
- X lint plotfoil.c spline.c
- X
- clean :
- X -rm *.o *~
- X -rm -i plotfoil
- X
- dist :
- X (cd ..; tar cvf p plotfoil; compress p; uuencode plotfoil.tar.Z <p.Z >plotfoil-2.1)
- X rm ../p.Z
- END_OF_FILE
- if test 329 -ne `wc -c <'plotfoil/makefile'`; then
- echo shar: \"'plotfoil/makefile'\" unpacked with wrong size!
- fi
- # end of 'plotfoil/makefile'
- fi
- if test -f 'plotfoil/makefile.dos' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plotfoil/makefile.dos'\"
- else
- echo shar: Extracting \"'plotfoil/makefile.dos'\" \(390 characters\)
- sed "s/^X//" >'plotfoil/makefile.dos' <<'END_OF_FILE'
- X#
- X# Makefile for DOS version of plotfoil
- X#
- X# This make file is appropriate for Microsoft C Version 6.00A
- X# and Microsoft NMAKE.
- X#
- X# Just type "nmake /f makefile.dos" to build the program.
- X#
- X# Andrew Patrick, andrew@calvin.dgbt.doc.ca
- X
- plotfoil.exe : plotfoil.obj spline.obj
- X link +plotfoil+spline,plotfoil;
- X
- plotfoil.obj: plotfoil.c
- X cl /c plotfoil.c
- X
- spline.obj: spline.c
- X cl /c spline.c
- X
- END_OF_FILE
- if test 390 -ne `wc -c <'plotfoil/makefile.dos'`; then
- echo shar: \"'plotfoil/makefile.dos'\" unpacked with wrong size!
- fi
- # end of 'plotfoil/makefile.dos'
- fi
- if test -f 'plotfoil/makefile.vms' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plotfoil/makefile.vms'\"
- else
- echo shar: Extracting \"'plotfoil/makefile.vms'\" \(330 characters\)
- sed "s/^X//" >'plotfoil/makefile.vms' <<'END_OF_FILE'
- X#
- X# Makefile for VMS systems.
- X# Harm Munk (munk@prl.philips.nl)
- X#
- X
- plotfoil : plotfoil.obj spline.obj
- X link/exe=plotfoil.exe plotfoil.obj,spline.obj
- X
- plotfoil.obj : plotfoil.c
- X cc plotfoil
- X
- spline.obj : spline.c
- X cc spline.c
- X
- clean :
- X delete/noconfirm/nolog plotfoil.obj;*,spline.obj;*,plotfoil.exe;*
- X
- END_OF_FILE
- if test 330 -ne `wc -c <'plotfoil/makefile.vms'`; then
- echo shar: \"'plotfoil/makefile.vms'\" unpacked with wrong size!
- fi
- # end of 'plotfoil/makefile.vms'
- fi
- if test -f 'plotfoil/plotfoil.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plotfoil/plotfoil.1'\"
- else
- echo shar: Extracting \"'plotfoil/plotfoil.1'\" \(6731 characters\)
- sed "s/^X//" >'plotfoil/plotfoil.1' <<'END_OF_FILE'
- X.\" plotfoil.1l 2/17/92
- X.TH plotfoil 1l "Feb. 1992"
- X.SH NAME
- X\fBplotfoil\fP \- generate a PostScript plot of airfoil data.
- X.SH SYNTAX
- X\fBplotfoil\fP [\fIoptions\fP] [\fIfilename...\fP]
- X.SH DESCRIPTION
- This program plots (in PostScript) airfoil sections (well, actually any section
- that is not smoothly closed). It can also allow for spars,
- sheeting, and prints registration marks that are aligned with the L.E. and T.E.
- It uses Bezier splines to interpolate between
- data points, with an option to use straight lines instead.
- X.SH OVERVIEW
- Plotfoil reads airfoil data and generates PostScript code that when printed on
- a PostScript printer will deliver a plot of the airfoil section along with
- spars (if any). The bounds of
- the section are also drawn, with crosses, and these can be used for
- registration of the ribs or templates. If the plot is going to be larger than
- one page, it will be spread over as many pages as are required.
- X.PP
- PostScript is a printer language for describing printed pages. Printers that
- accept PostScript include the Apple LaserWriters, QMS PS- series printers,
- DataProducts LZR-2665 and 2660 and the Linotronic 100 and 300 typesetters.
- PostScript is a trademark of Adobe Systems Incorporated.
- X.PP
- Bezier splines are used to calculate interpolating curves between the points.
- In some case the process may not deliver a smooth curve, and you will
- have to use the straight-line plot option (\fB\-s\fP).
- X.PP
- The program can also account for sheeting. If the wing you are building is to
- be sheeted, the ribs you need have to be inset from the required surface
- by the thickness of the sheet. When this option is used, you will notice that
- two curves are actually plotted. The inner curve is the one to use for ribs.
- X(The outer can be used if you are building a jig or saddle that will be
- sheeted.) The airfoil
- outline is plotted with a dotted line.
- X.SH OPTIONS
- X.IP \fB\-c\fR
- Sets the chord of the section to plot. The argument is the chord, in units of
- either mm, cm or inches. The units are specified by a
- trailing `m', `c', or `i',
- with the default of mm being used if unspecified.
- X.IP \fB\-s\fR
- This flag indicates that for \fIx\fP values of greater than 2.5%,
- straight lines
- should be used to join the points. This results in a PostScript file which is
- probably just as good but should print in less time. The limit (2.5%) can be
- changed with the \fB-l\fP option.
- X.IP \fB\-l\fR
- This option changes the limit used with the \fB-s\fP option. It takes the
- percentage-chord as argument.
- X.IP \fB\-i\fR
- This option draws the section inset by the specified amount, which is what you
- would use if the wing you are building is sheeted. The units default to those
- used for the chord.
- X.IP \fB\-sp\fP
- This option adds a spar to the plot. It takes two arguments, the offset
- X(expressed as a percentage of the chord) and the thickness of the spar
- X(default units:
- same as used for the chord). This option can be used multiple times to
- draw more than one spar. Also, 0-thickness spars can be used to draw vertical
- lines on the plot.
- X.IP \fB\-th\fR
- This option sets the height of the template outline, measured from the chord
- line. The default is 0.
- X.IP \fB\-tl\fR
- X.IP \fB\-tt\fR
- These options set the horizontal extents of the template. The value specified
- is the distance of the edge of the template from the {leading, trailing} edge.
- The units default to those specified while setting the chord. The default
- value is 0.
- X.IP
- If any of \fB\-th\fR, \fB\-tl\fR or \fB\-tt\fR is used, a template will be
- drawn.
- X.IP \fB\-h\fR
- Prints some help information.
- X.IP \fB\-o\fR
- Writes the output to the specified file.
- X.SH INPUT FORMATS
- There are two formats for input data, distinguished by how coordinates are
- specified. The first line of the file is taken to be the name of the section
- and is printed along with the plot.
- X.PP
- All the \fIx\fP values have to be positive, with 0 being the L.E. and the
- max value
- being the T.E. The \fIx\fP values don't have to be in the range [0, 1] anymore,
- but can be [0, \fIa\fP].
- X.PP
- This is the first format:
- X SD-8020
- X 1.0 0
- X 0.9 0.011
- X 0.85 0.02
- X ...
- X 1.0 0
- X.br
- Note: it starts at \fIx\fP=1.0 (the trailing edge), goes around
- and ends again at the
- T.E. This is the format used by the sections in Soartech 8.
- X.PP
- This is the second format:
- X Clark YH
- X 0 0 0
- X 0.0125 0.0409 -0.0183
- X 0.025 .0529 -.0271
- X ...
- X 1.0 0 0
- X.br
- This starts at the L.E. and ends at the T.E., with the columns being the upper
- and lower ordinate values. This is the format that most of the NACA sections
- were published in.
- X.SH EXAMPLES
- This command:
- X.IP
- plotfoil -c 20c -i 2m -sp 32 0.2 sd8020 | lpr
- X.LP
- will plot the SD-8020 section with a chord of 20cm, with a sheeting allowance
- of 2mm, and a spar 2mm wide at 32% chord. The name of the section and the
- sheeting allowance are also printed.
- X.IP
- plotfoil -c 8.5i -i 0.125 -s -l 10 clarkYH | lpr
- X.LP
- will plot the Clark YH with a chord of 8.5 inches. Only the area from the L.E.
- to 10% back will interpolated with splines, and from 10% to the T.E.; straight
- lines will be used to connect the points. A sheeting allowance of 0.125" (1/8")
- will also be drawn.
- X.SH DISTRIBUTION
- X\fBplotfoil\fP is free; anyone may redistribute copies of it to anyone
- under the terms stated in the Gnu General Public License version 2, a
- copy of which should accompany each copy of plotfoil. See the file ``COPYING''
- in the source area. If you do not have this file, a copy may be obtained from:
- X Free Software Foundation
- X 1000 Mass Ave.
- X Cambridge, MA 02138
- X.br
- or from the author.
- X.LP
- Also, if you make any changes to this program and re-distribute it, the same
- conditions apply to the modified version so that we can all benefit from
- it. And please send me those changes!
- X.SH AUTHOR
- Shamim Mohamed (shamim@cs.arizona.edu)
- X.br
- Dept of Computer Science
- X.br
- University of Arizona
- X.br
- Tucson, AZ 85721
- X.SH BUGS
- On some printers, there may be a stack overflow if the plot is on more than one
- page and there are more than a certain number of coordinate values. If this
- happens, first try compiling with -DSAVEMEM and run again, then try
- X.IP
- a) finding another printer, or
- X.IP
- b) removing some of the airfoil data.
- X.LP
- In the latter case you may still get satisfactory results because of the
- smooth interpolation used.
- X.PP
- Since the program doesn't know how big the printer page size is, it can get
- confused. This should only err conservatively, like producing an extra blank
- page on a multi-page plot. As long as the page is higher than about 11 inches
- X(27 cm) everything should be fine.
- X.PP
- I don't know of any other bugs right now,
- but please send all bug reports to me. Include
- version number and the exact details (input files, command-line options etc.),
- please.
- END_OF_FILE
- if test 6731 -ne `wc -c <'plotfoil/plotfoil.1'`; then
- echo shar: \"'plotfoil/plotfoil.1'\" unpacked with wrong size!
- fi
- # end of 'plotfoil/plotfoil.1'
- fi
- if test -f 'plotfoil/plotfoil.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plotfoil/plotfoil.c'\"
- else
- echo shar: Extracting \"'plotfoil/plotfoil.c'\" \(17198 characters\)
- sed "s/^X//" >'plotfoil/plotfoil.c' <<'END_OF_FILE'
- X/*
- X * Copyright 1992 Shamim P. Mohamed
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X *
- X * Author:
- X * shamim@cs.arizona.edu
- X * Shamim Mohamed
- X * Dept. of Computer Science
- X * University of Arizona
- X *
- X * ---------------------------------------------------------------------------
- X *
- X * Plots airfoils (or indeed any section)
- X * ---------------------------------------------------------------------------
- X * There are two formats for input data. Here are examples of each:
- X *
- X * Input formats:
- X * 1 Title
- X * 1.0 0
- X * 0.9 0.011
- X * 0.85 0.02
- X * ...
- X * 1.0 0
- X * This should start at the trailing edge (x = 1.0), follow a surface to the
- X * LE (x = 0), and continue back to the TE (assuming the LE is smooth).
- X * Or:
- X * 2 Title
- X * 0 0 0
- X * .0125 .0409 -.0183
- X * .025 .0529 -.0271
- X * ...
- X * 1.0 0 0
- X * The values go across the foil from LE (x = 0) to TE (x = 1).
- X *
- X * Remember: the digit in the first line ("1" or "2") is important!
- X *
- X * ---------------------------------------------------------------------------
- X * Options:
- X * -c : Chord size (trailing c, m or i represents cm, mm or in)
- X * -s : Use straight line approximation for x values > limit
- X * -l : The limit used in -s (default: 0.025)
- X * -i : Draw allowance for sheeting, of i units (units are same as chord)
- X * -t?: Draw template
- X * -spar : Draw spar
- X * -h : help
- X *
- X * Try: plotfoil -c 200m -i 2 file
- X * (means chord = 200mm, with allowance for a 2mm skin)
- X *
- X */
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include <string.h>
- X
- X#define streq(a, b) (strcmp((a),(b)) == 0)
- X
- X#define MAXPOINTS 100
- X#define MAX_SPARS 10
- X
- X/* output scaling etc. */
- X#define SCALE 10000 /* size of the field (output) */
- X#define RADIUS 10 /* radius of circles denoting points */
- X#define TXTSIZ 20 /* size to be used for text */
- X
- static int sflag, iflag, tflag, nsheets, nspars=0;
- static float c = 1.0, s_limit = 0.025;
- X
- extern void interpolate();
- X
- void init_output(), put_line(), put_curve(), put_title(), end_output(),
- X draw_template(), draw_spar(), end_lines(), draw_double_line(), get_value(),
- X do_scaling(), process();
- X
- typedef struct {
- X double x, y;
- X} point;
- X
- typedef struct {
- X float raw_value, scale, pts;
- X char *units;
- X} value;
- X
- typedef struct {
- X float offset;
- X value thick;
- X} spar_desc;
- X
- static value
- X chord = {100.0, 2.834, 283.4, "mm"},
- X sheeting = {0.0, 1.0, 0.0, ""},
- X templ_h = {0.0, 1.0, 0.0, ""},
- X templ_le = {0.0, 1.0, 0.0, ""},
- X templ_te = {0.0, 1.0, 0.0, ""};
- X
- spar_desc spars[MAX_SPARS];
- X
- static FILE *fout = stdout;
- X
- main(argc, argv)
- int argc;
- char *argv[];
- X{
- X char *pointfile = "";
- X int ch, i, n, k, qflag=0;
- X char cont, *p;
- X FILE *fp, *get_file();
- X int argp = 1;
- X
- X while(argc > argp) {
- X p = argv[argp];
- X if(*p == '-' && *(p+1) != 0) {
- X switch (*(p+1)) {
- X case 'l':
- X sscanf(argv[++argp], "%f", &s_limit);
- X s_limit /= 100.0;
- X break;
- X case 's':
- X if(*(p+2) == 'p') {
- X sscanf(argv[++argp], "%f", &spars[nspars].offset);
- X get_value(argv[++argp], &spars[nspars].thick);
- X spars[nspars].offset /= 100.0;
- X nspars++;
- X }
- X else
- X sflag++;
- X break;
- X case 'q': qflag++; break;
- X case 'i':
- X iflag++;
- X get_value(argv[++argp], &sheeting);
- X break;
- X case 'c':
- X get_value(argv[++argp], &chord);
- X break;
- X case 't':
- X tflag++;
- X switch (*(p+2)) {
- X case 'h':
- X get_value(argv[++argp], &templ_h);
- X break;
- X case 't':
- X get_value(argv[++argp], &templ_te);
- X break;
- X case 'l':
- X get_value(argv[++argp], &templ_le);
- X break;
- X default:
- X break;
- X }
- X break;
- X case 'o':
- X if((fout = fopen(argv[++argp], "w")) == NULL) {
- X fprintf(stderr, "Could not open \"%s\" for writing!\n");
- X fout = stdout;
- X }
- X break;
- X case '-':
- X goto done_opts;
- X default:
- X fprintf(stderr,
- X "\nUsage: %s [-hqs] [-c<n>[cim]] [-l<n>] [-i<n>] [-sp <offset> <thickness>] [-tt <n>] [-th <n>] [-tl <n>] [-o outfile] [files]\n",
- X argv[0]);
- X fputs(" -h : Print this message\n", stderr);
- X fputs(" -q : Skip the copyright message at startup\n", stderr);
- X fputs(" -s : Use straight-line segments for x > s_limit\n",
- X stderr);
- X fputs("These take arguments:\n", stderr);
- X fputs(" -c : Set chord size. A trailing unit can be ", stderr);
- X fputs("specified:\n c = cm, i = inches, m = mm (default)\n",
- X stderr);
- X fputs(" -l : Set s_limit to n (default is 0.025)\n", stderr);
- X fputs(" -i : Draw sheeting allowance of n units (units same as chord)\n", stderr);
- X fputs(" -sp: Draw a spar at offset of specified thickness\n",
- X stderr);
- X fputs(" -t.: Draw template outlines of specified size\n",
- X stderr);
- X fputs(" -o : Write output to file\n", stderr);
- X fputs("\nA good place to start is:\n", stderr);
- X fprintf(stderr, " %s -c 200m file1\n\n", argv[0]);
- X exit(1);
- X }
- X }
- X else
- X break;
- X argp++;
- X }
- X
- X done_opts:
- X
- X if(!qflag) {
- X fputs("Plotfoil v2.1, Copyright 1992 Shamim Mohamed. This is", stderr);
- X fputs(" free software\nand is freely distributable under", stderr);
- X fputs(" certain conditions. See\nthe file \"COPYING\" in the", stderr);
- X fputs(" source area for details.\n", stderr);
- X }
- X
- X
- X if(*chord.units == '\0') {
- X chord.units = "mm";
- X chord.scale = 2.834;
- X }
- X do_scaling(&chord, 0);
- X do_scaling(&sheeting, &chord);
- X do_scaling(&templ_h, &chord);
- X do_scaling(&templ_te, &chord);
- X do_scaling(&templ_le, &chord);
- X for(i = 0; i < nspars; i++)
- X do_scaling(&spars[i].thick, &chord);
- X
- X nsheets = (chord.pts+templ_te.pts+templ_le.pts)/720 + 1;
- X
- X if(argp >= argc)
- X process(stdin, "<stdin>");
- X else
- X for (; argp < argc; argp++) {
- X if((fp = fopen(argv[argp], "r")) == NULL) {
- X fprintf(stderr, "%s: can't open \"%s\"\n", argv[0], argv[argp]);
- X continue;
- X }
- X process(fp, argv[argp]);
- X close(fp);
- X }
- X
- X exit(0);
- X}
- X
- void get_value(s, val)
- char *s;
- value *val;
- X{
- X char c;
- X
- X if(sscanf(s, "%f%c", &val->raw_value, &c) == 1) {
- X val->scale = 1.0;
- X val->units = "";
- X }
- X else
- X switch((int)c) {
- X case 'i': val->scale = 72.0; val->units = "\""; break;
- X case 'c': val->scale = 28.34; val->units = "cm"; break;
- X case 'm':
- X default:
- X val->units = "mm";
- X val->scale = 2.834; break;
- X }
- X val->pts = val->raw_value * val->scale;
- X}
- void do_scaling(val, master)
- value *val, *master;
- X{
- X if(val->units[0] == '\0' && master) {
- X val->units = master->units;
- X val->scale = master->scale;
- X }
- X val->pts = val->raw_value * val->scale;
- X}
- X
- float U[MAXPOINTS], L[MAXPOINTS], X[MAXPOINTS], Y[MAXPOINTS];
- char title[100];
- X
- void process(fp, f)
- XFILE *fp;
- char *f;
- X{
- X float x, upper, lower, minx, maxx;
- X int i, n, bar;
- X char temp_buf[BUFSIZ];
- X
- X init_output();
- X /* fmt_type = fgetc(fp); (void) fgetc(fp); */
- X fgets(title, 100, fp);
- X put_title(title);
- X (void) fgets(temp_buf, BUFSIZ, fp);
- X n = sscanf(temp_buf, "%f %f %f", &x, &upper, &lower);
- X if(n == 2) {
- X /* It's a straight x-y file, starting at the T.E. */
- X minx = maxx = X[0] = x; Y[0] = upper;
- X i = 1;
- X
- X while((n = fscanf(fp, "%f %f", &x, &upper)) != EOF && n == 2) {
- X X[i] = x; Y[i] = upper;
- X if(minx > x) minx = x; if(maxx < x) maxx = x;
- X i++;
- X }
- X if(n != EOF && n != 2) {
- X fprintf(stderr, "Invalid input in \"%s\" (line %d)\n", f, i+2);
- X return;
- X }
- X if(X[0] != X[i-1] || Y[0] != Y[i-1]) {
- X fprintf(stderr,
- X "Invalid input: data does not start and end at the same point.\n");
- X return;
- X }
- X if(minx < 0.0) {
- X fprintf(stderr, "Error: x values cannot be negative.\n");
- X return;
- X }
- X if(maxx == 0.0) {
- X fprintf(stderr, "Error: no x values?\n");
- X return;
- X }
- X plot_points(-i, maxx);
- X }
- X else if(n == 3) {
- X minx = maxx = X[0] = x; U[0] = upper; L[0] = lower;
- X i = 1;
- X
- X while((n = fscanf(fp, "%f %f %f", &x, &upper, &lower)) != EOF && n == 3){
- X X[i] = x; U[i] = upper; L[i] = lower;
- X if(minx > x) minx = x; if(maxx < x) maxx = x;
- X i++;
- X }
- X if(n != EOF && n != 3) {
- X fprintf(stderr, "Invalid input in \"%s\" (line %d)\n", f, i+2);
- X return;
- X }
- X if(minx < 0.0) {
- X fprintf(stderr, "Error: x values cannot be negative.\n");
- X return;
- X }
- X if(maxx == 0.0) {
- X fprintf(stderr, "Error: no x values?\n");
- X return;
- X }
- X
- X plot_points(i, maxx);
- X }
- X else
- X fprintf(stderr, "Invalid input in \"%s\" (line 2)\n", f);
- X}
- X
- static float upperx, uppery, lowerx, lowery;
- X
- X/* Misc. math. */
- double sqr(x)
- double x;
- X{
- X return x*x;
- X}
- X
- X/*
- X * The Bezier part:
- X */
- X
- X#define px(i) (points[(i)].x)
- X#define py(i) (points[(i)].y)
- X
- point points[MAXPOINTS];
- X
- plot_points(n, maxx)
- int n;
- float maxx;
- X{
- X
- X int i, j, npoints = 0;
- X double m1, m2, m, l, p2x, p2y, p3x, p3y;
- X double d = 3.0, e = 0.2;
- X void init_lines(), put_curve();
- X
- X /* first, collect all the points into one array points: */
- X if(n < 0) {
- X n = -n;
- X for(i = n - 1; i >= 0; i--, npoints++) {
- X px(npoints) = X[i]/maxx;
- X py(npoints) = Y[i]/maxx;
- X }
- X }
- X else {
- X for(i = n - 1; i >= 0; i--, npoints++) {
- X px(npoints) = X[i]/maxx;
- X py(npoints) = L[i]/maxx;
- X }
- X for(i = 1; i < n; i++, npoints++) {
- X px(npoints) = X[i]/maxx;
- X py(npoints) = U[i]/maxx;
- X }
- X }
- X
- X if(tflag) {
- X draw_template(templ_h.pts, templ_le.pts, templ_te.pts);
- X }
- X
- X for(i = 0; i < nspars; i++)
- X draw_spar(spars[i].offset, spars[i].thick.pts, points, npoints);
- X
- X i = 0;
- X if(sflag) {
- X /* In the region s_limit to 100%, use straight lines to plot */
- X i = 1;
- X init_lines(px(0), py(0));
- X while(px(i) > s_limit && px(i) < 1.0) {
- X put_line(px(i), py(i));
- X i++;
- X }
- X i--;
- X
- X for(j = i+1; px(j) <= s_limit && px(j) <= 1.0; j++)
- X ;
- X
- X interpolate(points+i, j-i-1, d, e, init_lines, put_curve);
- X
- X i = j;
- X /* Finish off rest i.e. 2.5% to 100% with straight lines */
- X for(;;) {
- X put_line(px(i), py(i));
- X if(px(i++) >= 1.0) break;
- X }
- X }
- X else
- X interpolate(points, npoints, d, e, init_lines, put_curve);
- X
- X end_output();
- X}
- X
- void draw_spar(offset, thick, points, n)
- float offset, thick;
- point *points;
- int n;
- X{
- X float upper, lower;
- X int i;
- X
- X i = 0;
- X while(i < n) {
- X if(offset >= points[i].x) {
- X upper = points[i].y +
- X (points[i].y - points[i-1].y)/(points[i].x - points[i-1].x)*
- X (points[i].x - offset);
- X break;
- X }
- X i++;
- X }
- X while(i < n) {
- X if(offset <= points[i].x) {
- X lower = points[i].y +
- X (points[i].y - points[i-1].y)/(points[i].x - points[i-1].x)*
- X (points[i].x - offset);
- X break;
- X }
- X i++;
- X }
- X
- X draw_double_line(offset, upper, offset, lower, thick);
- X
- X}
- X
- X/* ========================= PostScript routines =========================== */
- X
- void init_output()
- X{
- X fputs("%!\n% Created by Plotfoil 2.0\n", fout);
- X fprintf(fout, "%%%%Orientation: Landscape\n");
- X fputs("/S {stroke} bind def /L {lineto} bind def /M {moveto} bind def\n",
- X fout);
- X fputs("/X {moveto 10 0 rmoveto -20 0 rlineto 10 0 rmoveto\n", fout);
- X fputs(" 0 10 rmoveto 0 -20 rlineto 0 10 rmoveto} bind def\n", fout);
- X fputs("/drawbbox {4 dict begin\n", fout);
- X fputs(" /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n", fout);
- X fputs(" x1 y1 X x1 y2 X x2 y2 X x2 y1 X\n", fout);
- X fputs("end} bind def\n", fout);
- X fputs("/drawrect {4 dict begin newpath\n", fout);
- X fputs(" /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n", fout);
- X fputs(" x1 y1 moveto x1 y2 lineto x2 y2 lineto x2 y1 lineto closepath\n",
- X fout);
- X fputs(" stroke\nend} bind def\n", fout);
- X fputs("/landscape {newpath clippath pathbbox pop exch pop add 0 translate\n",
- X fout);
- X fputs("90 rotate newpath} bind def\n", fout);
- X
- X fputs("/C {curveto} bind def\n", fout);
- X if(nsheets > 1) {
- X fputs("/plarge { /ii exch def /jj exch def /bproc exch def 0 1 ii\n",
- X fout);
- X fputs("1 sub { /i exch def 0 1 jj 1 sub { /j exch def newpath lm\n",
- X fout);
- X fputs("bm moveto 0 pht rlineto pwt 0 rlineto 0 pht neg rlineto\n", fout);
- X fputs("closepath gsave 0 setlinewidth stroke grestore clip gsave\n",
- X fout);
- X fputs("pwt j mul neg pht i mul neg translate bproc showpage\n", fout);
- X fputs("grestore } for } for } def newpath clippath pathbbox\n", fout);
- X fputs("1 sub /top exch def 1 sub /right exch def 1 add /bm exch def\n",
- X fout);
- X fputs("1 add /lm exch def /pwt right lm sub def /pht top bm sub def\n",
- X fout);
- X fputs("newpath\n", fout);
- X }
- X}
- X
- void put_curve(x1, y1, x2, y2, x3, y3)
- double x1, y1, x2, y2, x3, y3;
- X{
- X x1 *= chord.pts; y1 *= chord.pts; x2 *= chord.pts; y2 *= chord.pts;
- X x3 *= chord.pts; y3 *= chord.pts;
- X fprintf(fout, "%.2f %.2f %.2f %.2f %.2f %.2f C\n", x1, y1, x2, y2, x3, y3);
- X}
- X
- void init_lines(x, y)
- double x, y;
- X{
- X x *= chord.pts;
- X y *= chord.pts;
- X#ifdef SAVEMEM
- X if(nsheets > 1)
- X fprintf(fout, "newpath } def /buildpath { %.2f %.2f M\n", x, y);
- X else
- X fprintf(fout, "newpath %.2f %.2f M\n", x, y);
- X#else
- X fprintf(fout, "newpath %.2f %.2f M\n", x, y);
- X#endif
- X}
- X
- void put_line(x, y)
- double x, y;
- X{
- X fprintf(fout, "%.2f %.2f L\n", x*chord.pts, y*chord.pts);
- X}
- X
- void end_lines()
- X{
- X fputs("stroke\n", fout);
- X}
- X
- void draw_double_line(x1, y1, x2, y2, spacing)
- float x1, y1, x2, y2, spacing;
- X{
- X fprintf(fout, "%.2f %.2f M %.2f %.2f L\n",
- X x1*chord.pts, y1*chord.pts, x2*chord.pts, y2*chord.pts);
- X if(spacing >= 1.0) {
- X fprintf(fout,
- X "gsave gsave %.1f setlinewidth 0 setgray stroke\n", spacing);
- X fprintf(fout,
- X "grestore %.1f setlinewidth 1 setgray stroke grestore newpath\n",
- X spacing-0.5);
- X }
- X else
- X fputs("stroke\n", fout);
- X}
- X
- void draw_template(h, le, te)
- float h, te, le;
- X{
- X fprintf(fout, "-%.2f -%.2f %.2f %.2f drawrect\n", le, h, te+chord.pts, h);
- X}
- X
- char *ftoa(x)
- float x;
- X{
- X static char buf[25];
- X char *p;
- X sprintf(buf, "%f", x);
- X
- X p = buf; while(*p) p++;
- X p--;
- X while(*p == '0') p--;
- X if(*p == '.') p--;
- X p[1] = 0;
- X return buf;
- X}
- X
- void put_title(s)
- char *s;
- X{
- X char *p;
- X int i;
- X float y;
- X
- X p = s;
- X while(*p != '\n' && *p != '\0') p++;
- X *p = '\0';
- X
- X fputs("gsave landscape\n", fout);
- X fprintf(fout,
- X "/Times-Roman findfont 30 scalefont setfont 50 130 M (%s) show\n",
- X s);
- X fputs("/Times-Roman findfont 11 scalefont setfont\n", fout);
- X y = 110.0;
- X fprintf(fout, "50 %.4g M (Chord: %.3g%s) show\n",y, chord.raw_value, chord.units);
- X y -= 13.4;
- X if(iflag) {
- X fprintf(fout, "50 %.4g M (with %.3g%s sheeting allowance) show\n", y,
- X sheeting.raw_value, sheeting.units);
- X y -= 13.4;
- X }
- X
- X if(tflag) {
- X fprintf(fout, "50 %.4g M (template: height %.3g%s", y,
- X templ_h.raw_value, templ_h.units);
- X fprintf(fout, ", %.3g%s at LE,", templ_le.raw_value, templ_le.units);
- X fprintf(fout, " %.3g%s at TE) show\n", templ_te.raw_value,
- X templ_te.units);
- X y -= 13.4;
- X }
- X for(i = 0; i < nspars; i++, y -= 13.4)
- X fprintf(fout,
- X "50 %.4g M (Spar at %.3g %% chord, thickness %.3g%s) show\n",
- X y, spars[i].offset*100, spars[i].thick.raw_value,
- X spars[i].thick.units);
- X fputs("grestore newpath\n", fout);
- X#ifdef SAVEMEM
- X if(nsheets > 1)
- X fputs("/setup {\n", fout);
- X#else
- X if(nsheets > 1) putc('{', fout);
- X#endif
- X fprintf(fout,
- X "0.1 setlinewidth landscape %.4g 300 translate\n", templ_le.pts+30);
- X}
- X
- void end_output()
- X{
- X#ifdef SAVEMEM
- X if(nsheets > 1) fputs("} def /trail {", fout);
- X#endif
- X if(iflag) {
- X fputs("gsave gsave gsave\n", fout);
- X fprintf(fout, "0 setgray %.4g setlinewidth stroke\n", sheeting.pts*2);
- X fprintf(fout, "grestore %.4g setlinewidth 1 setgray\n",
- X sheeting.pts*2-0.5);
- X fputs("stroke grestore [2 4] 0 setdash stroke grestore\n", fout);
- X }
- X else
- X fputs("gsave stroke grestore\n", fout);
- X
- X fputs("pathbbox newpath drawbbox stroke\n", fout);
- X fprintf(fout,
- X "gsave .8 setgray %.4g 0 moveto %.4g 0 lineto stroke grestore\n",
- X -templ_le.pts, chord.pts+templ_te.pts);
- X#ifdef SAVEMEM
- X if(nsheets > 1) fputs("} def {setup buildpath trail\n", fout);
- X#endif
- X if(nsheets > 1)
- X fprintf(fout, "} 1 %d plarge\n", nsheets);
- X else
- X fputs("showpage\n", fout);
- X}
- X
- END_OF_FILE
- if test 17198 -ne `wc -c <'plotfoil/plotfoil.c'`; then
- echo shar: \"'plotfoil/plotfoil.c'\" unpacked with wrong size!
- fi
- # end of 'plotfoil/plotfoil.c'
- fi
- if test -f 'plotfoil/spline.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'plotfoil/spline.c'\"
- else
- echo shar: Extracting \"'plotfoil/spline.c'\" \(4617 characters\)
- sed "s/^X//" >'plotfoil/spline.c' <<'END_OF_FILE'
- X
- X/*
- X * Code to generate bezier control points to interpolate between points.
- X * Copyright Shamim Mohamed 1991
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X *
- X * shamim@cs.arizona.edu
- X * Shamim Mohamed
- X * Dept of Computer Science
- X * University of Arizona
- X * Tucson, AZ 85721
- X *
- X * --------------------------------------------------------------------------
- X *
- X * Inputs: an array of points, the number of points, two fudge-factors,
- X * and two procedures that are called for moveto and curveto. I use d = 3.0
- X * and e = 0.2. d controls the slope of the curve depending on the neighbours
- X * (it's not prob. worth futzing with it) and e controls the shape of the ends
- X * of the curve. Experimenting with e may be fruitful.
- X * This is NOT an approximation algorithm. Given n points, it ALWAYS generates
- X * n-1 splines that pass through all the given points. For some sort of
- X * optimum approximation, see the paper in "Graphics Gems", Klossner ed. (It's
- X * the last source-code in the Appendix.)
- X *
- X * The callback procedures can be something like:
- X * void moveto(x, y)
- X * double x, y;
- X * {
- X * printf("%g %g moveto\n", x, y);
- X * }
- X * void curveto(x1, y1, x2, y2, x3, y3)
- X * double x, y;
- X * {
- X * printf("%g %g %g %g %g curveto\n", x1, y1, x2, y2, x3, y3);
- X * }
- X *
- X */
- X
- X
- X#include <stdio.h>
- X#include <math.h>
- X
- X#define MAXPOINTS 100
- X#define sqr(a) ((a)*(a))
- X
- typedef struct {
- X double x, y;
- X} point;
- X
- point cp[MAXPOINTS], cpp[MAXPOINTS];
- double l[MAXPOINTS];
- X
- void interpolate(p, npoints, d, e, moveto, curveto)
- point *p;
- int npoints;
- double d, e;
- void (*moveto)(), (*curveto)();
- X{
- X int i;
- X point slope_prev, slope_next;
- X
- X l[1] = sqrt(sqr(p[0].x-p[1].x)+sqr(p[0].y-p[1].y));
- X slope_prev.x = p[1].x - p[0].x;
- X slope_prev.y = p[1].y - p[0].y;
- X for(i = 1; i < npoints-1; i++) {
- X point slope;
- X double m;
- X
- X l[i+1] = sqrt(sqr(p[i].x-p[i+1].x)+sqr(p[i].y-p[i+1].y));
- X
- X slope_next.x = p[i+1].x - p[i].x;
- X slope_next.y = p[i+1].y - p[i].y;
- X
- X /*
- X * Slope of the curve at this point is the weighted ave. of
- X * straight-line slopes to neighbours (weighted by length of chord)
- X */
- X
- X slope.x = slope_prev.x * l[i+1] + slope_next.x * l[i];
- X slope.y = slope_prev.y * l[i+1] + slope_next.y * l[i];
- X
- X slope_prev = slope_next;
- X
- X /*
- X * Alternative method:
- X * Parameters:
- X * a 0 Higher number makes curve tighter. -1<a<1.
- X * b .1 Higher number makes sharp curves tighter
- X * and broad curves less tight. -1<b<1
- X *
- X * Given points A B and C, bezier control points for B are aligned along
- X * a line that is perpendicular to the line the bisects the angle ABC.
- X * The distance of the control points from B is determined by the
- X * following formula that was found by trial and error is has no
- X * particular theory behind it:
- X * Distance of control point from B towards A =
- X * (1/2)*(distance between A and B)*
- X * (cos(ABC)^(a*b + a + b))(b + 2(1-b)(1-a)/(3-a))
- X * (Timothy van Zandt <tvz@princeton.edu>)
- X * My opinion: one has to take an inverse cosine and raise it to a
- X * fractional power, and the results are very close to my simpler
- X * algorithm, so I don't think it's worth it.
- X */
- X
- X /* Now we have slope: m is for the normalisation. */
- X m = sqrt(sqr(slope.x)+sqr(slope.y));
- X cp[i].x = p[i].x - l[i]*slope.x/(d*m);
- X cp[i].y = p[i].y - l[i]*slope.y/(d*m);
- X cpp[i].x = p[i].x + l[i+1]*slope.x/(d*m);
- X cpp[i].y = p[i].y + l[i+1]*slope.y/(d*m);
- X }
- X cpp[0].x = (e*cp[1].x + p[0].x)/(1+e);
- X cpp[0].y = (e*cp[1].y + p[0].y)/(1+e);
- X cp[npoints-1].x = (e*cpp[npoints-2].x + p[npoints-1].x)/(1+e);
- X cp[npoints-1].y = (e*cpp[npoints-2].y + p[npoints-1].y)/(1+e);
- X
- X (*moveto)(p[0].x, p[0].y);
- X for(i = 1; i < npoints; i++)
- X (*curveto)(cpp[i-1].x, cpp[i-1].y, cp[i].x, cp[i].y, p[i].x, p[i].y);
- X}
- X
- END_OF_FILE
- if test 4617 -ne `wc -c <'plotfoil/spline.c'`; then
- echo shar: \"'plotfoil/spline.c'\" unpacked with wrong size!
- fi
- # end of 'plotfoil/spline.c'
- fi
- echo shar: End of archive 1 \(of 3\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
-