home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume31 / plotfoil / part01 < prev    next >
Encoding:
Text File  |  1992-07-13  |  55.3 KB  |  1,621 lines

  1. Newsgroups: comp.sources.misc
  2. From: sham@cs.arizona.edu ("Shamim Zvonko Mohamed")
  3. Subject:  v31i028: plotfoil - Plot curves (airfoils) using PostScript, Part01/03
  4. Message-ID: <csm-v31i028=plotfoil.155848@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 6188e82fc3cf6208d15973797431874a
  6. Date: Mon, 13 Jul 1992 21:00:11 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: sham@cs.arizona.edu ("Shamim Zvonko Mohamed")
  10. Posting-number: Volume 31, Issue 28
  11. Archive-name: plotfoil/part01
  12. Environment: UNIX,VMS,DOS,SGI,Sun,PC
  13.  
  14. This is a program that reads in airfoil data and generates PostScript code
  15. that will plot the airfoil on a PS printer. It interpolates between points
  16. and can understand the two most popular formats for airfoil data (sample data
  17. is included). It has various options for chord size, spar locations, sheeting 
  18. allowances, and can also do multi-page plots (e.g. chord size > 11 inches). 
  19. It has run on every system that I could find with a C compiler. The code 
  20. generated has also printed on every PS printer I've tried. The README has 
  21. details.
  22.  
  23. Shamim Mohamed / {uunet,noao,cmcl2..}!arizona!shamim / shamim@cs.arizona.edu
  24. ---
  25. #! /bin/sh
  26. # This is a shell archive.  Remove anything before this line, then unpack
  27. # it by saving it into a file and typing "sh file".  To overwrite existing
  28. # files, type "sh file -c".  You can also feed this as standard input via
  29. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  30. # will see the following message at the end:
  31. #        "End of archive 1 (of 3)."
  32. # Contents:  plotfoil plotfoil/COPYING plotfoil/README
  33. #   plotfoil/airfoils plotfoil/makefile plotfoil/makefile.dos
  34. #   plotfoil/makefile.vms plotfoil/plotfoil.1 plotfoil/plotfoil.c
  35. #   plotfoil/spline.c
  36. # Wrapped by sham@gilamonster on Thu Jul  9 14:52:00 1992
  37. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  38. if test ! -d 'plotfoil' ; then
  39.     echo shar: Creating directory \"'plotfoil'\"
  40.     mkdir 'plotfoil'
  41. fi
  42. if test -f 'plotfoil/COPYING' -a "${1}" != "-c" ; then 
  43.   echo shar: Will not clobber existing file \"'plotfoil/COPYING'\"
  44. else
  45. echo shar: Extracting \"'plotfoil/COPYING'\" \(18054 characters\)
  46. sed "s/^X//" >'plotfoil/COPYING' <<'END_OF_FILE'
  47. X            GNU GENERAL PUBLIC LICENSE
  48. X               Version 2, June 1991
  49. X
  50. X Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  51. X                          675 Mass Ave, Cambridge, MA 02139, USA
  52. X Everyone is permitted to copy and distribute verbatim copies
  53. X of this license document, but changing it is not allowed.
  54. X
  55. X                Preamble
  56. X
  57. X  The licenses for most software are designed to take away your
  58. freedom to share and change it.  By contrast, the GNU General Public
  59. License is intended to guarantee your freedom to share and change free
  60. software--to make sure the software is free for all its users.  This
  61. General Public License applies to most of the Free Software
  62. XFoundation's software and to any other program whose authors commit to
  63. using it.  (Some other Free Software Foundation software is covered by
  64. the GNU Library General Public License instead.)  You can apply it to
  65. your programs, too.
  66. X
  67. X  When we speak of free software, we are referring to freedom, not
  68. price.  Our General Public Licenses are designed to make sure that you
  69. have the freedom to distribute copies of free software (and charge for
  70. this service if you wish), that you receive source code or can get it
  71. if you want it, that you can change the software or use pieces of it
  72. in new free programs; and that you know you can do these things.
  73. X
  74. X  To protect your rights, we need to make restrictions that forbid
  75. anyone to deny you these rights or to ask you to surrender the rights.
  76. These restrictions translate to certain responsibilities for you if you
  77. distribute copies of the software, or if you modify it.
  78. X
  79. X  For example, if you distribute copies of such a program, whether
  80. gratis or for a fee, you must give the recipients all the rights that
  81. you have.  You must make sure that they, too, receive or can get the
  82. source code.  And you must show them these terms so they know their
  83. rights.
  84. X
  85. X  We protect your rights with two steps: (1) copyright the software, and
  86. X(2) offer you this license which gives you legal permission to copy,
  87. distribute and/or modify the software.
  88. X
  89. X  Also, for each author's protection and ours, we want to make certain
  90. that everyone understands that there is no warranty for this free
  91. software.  If the software is modified by someone else and passed on, we
  92. want its recipients to know that what they have is not the original, so
  93. that any problems introduced by others will not reflect on the original
  94. authors' reputations.
  95. X
  96. X  Finally, any free program is threatened constantly by software
  97. patents.  We wish to avoid the danger that redistributors of a free
  98. program will individually obtain patent licenses, in effect making the
  99. program proprietary.  To prevent this, we have made it clear that any
  100. patent must be licensed for everyone's free use or not licensed at all.
  101. X
  102. X  The precise terms and conditions for copying, distribution and
  103. modification follow.
  104. X
  105. X
  106. X
  107. X
  108. X
  109. X
  110. X
  111. X
  112. X
  113. X
  114. X
  115. X
  116. X
  117. X
  118. X
  119. X
  120. X
  121. X
  122. X
  123. X
  124. X
  125. X
  126. X
  127. X
  128. X
  129. X
  130. X
  131. X
  132. X
  133. X            GNU GENERAL PUBLIC LICENSE
  134. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  135. X
  136. X  0. This License applies to any program or other work which contains
  137. a notice placed by the copyright holder saying it may be distributed
  138. under the terms of this General Public License.  The "Program", below,
  139. refers to any such program or work, and a "work based on the Program"
  140. means either the Program or any derivative work under copyright law:
  141. that is to say, a work containing the Program or a portion of it,
  142. either verbatim or with modifications and/or translated into another
  143. language.  (Hereinafter, translation is included without limitation in
  144. the term "modification".)  Each licensee is addressed as "you".
  145. X
  146. Activities other than copying, distribution and modification are not
  147. covered by this License; they are outside its scope.  The act of
  148. running the Program is not restricted, and the output from the Program
  149. is covered only if its contents constitute a work based on the
  150. Program (independent of having been made by running the Program).
  151. Whether that is true depends on what the Program does.
  152. X
  153. X  1. You may copy and distribute verbatim copies of the Program's
  154. source code as you receive it, in any medium, provided that you
  155. conspicuously and appropriately publish on each copy an appropriate
  156. copyright notice and disclaimer of warranty; keep intact all the
  157. notices that refer to this License and to the absence of any warranty;
  158. and give any other recipients of the Program a copy of this License
  159. along with the Program.
  160. X
  161. You may charge a fee for the physical act of transferring a copy, and
  162. you may at your option offer warranty protection in exchange for a fee.
  163. X
  164. X  2. You may modify your copy or copies of the Program or any portion
  165. of it, thus forming a work based on the Program, and copy and
  166. distribute such modifications or work under the terms of Section 1
  167. above, provided that you also meet all of these conditions:
  168. X
  169. X    a) You must cause the modified files to carry prominent notices
  170. X    stating that you changed the files and the date of any change.
  171. X
  172. X    b) You must cause any work that you distribute or publish, that in
  173. X    whole or in part contains or is derived from the Program or any
  174. X    part thereof, to be licensed as a whole at no charge to all third
  175. X    parties under the terms of this License.
  176. X
  177. X    c) If the modified program normally reads commands interactively
  178. X    when run, you must cause it, when started running for such
  179. X    interactive use in the most ordinary way, to print or display an
  180. X    announcement including an appropriate copyright notice and a
  181. X    notice that there is no warranty (or else, saying that you provide
  182. X    a warranty) and that users may redistribute the program under
  183. X    these conditions, and telling the user how to view a copy of this
  184. X    License.  (Exception: if the Program itself is interactive but
  185. X    does not normally print such an announcement, your work based on
  186. X    the Program is not required to print an announcement.)
  187. X
  188. X
  189. X
  190. X
  191. X
  192. X
  193. X
  194. X
  195. X
  196. X
  197. X
  198. X
  199. X
  200. X
  201. These requirements apply to the modified work as a whole.  If
  202. identifiable sections of that work are not derived from the Program,
  203. and can be reasonably considered independent and separate works in
  204. themselves, then this License, and its terms, do not apply to those
  205. sections when you distribute them as separate works.  But when you
  206. distribute the same sections as part of a whole which is a work based
  207. on the Program, the distribution of the whole must be on the terms of
  208. this License, whose permissions for other licensees extend to the
  209. entire whole, and thus to each and every part regardless of who wrote it.
  210. X
  211. Thus, it is not the intent of this section to claim rights or contest
  212. your rights to work written entirely by you; rather, the intent is to
  213. exercise the right to control the distribution of derivative or
  214. collective works based on the Program.
  215. X
  216. In addition, mere aggregation of another work not based on the Program
  217. with the Program (or with a work based on the Program) on a volume of
  218. a storage or distribution medium does not bring the other work under
  219. the scope of this License.
  220. X
  221. X  3. You may copy and distribute the Program (or a work based on it,
  222. under Section 2) in object code or executable form under the terms of
  223. Sections 1 and 2 above provided that you also do one of the following:
  224. X
  225. X    a) Accompany it with the complete corresponding machine-readable
  226. X    source code, which must be distributed under the terms of Sections
  227. X    1 and 2 above on a medium customarily used for software interchange; or,
  228. X
  229. X    b) Accompany it with a written offer, valid for at least three
  230. X    years, to give any third party, for a charge no more than your
  231. X    cost of physically performing source distribution, a complete
  232. X    machine-readable copy of the corresponding source code, to be
  233. X    distributed under the terms of Sections 1 and 2 above on a medium
  234. X    customarily used for software interchange; or,
  235. X
  236. X    c) Accompany it with the information you received as to the offer
  237. X    to distribute corresponding source code.  (This alternative is
  238. X    allowed only for noncommercial distribution and only if you
  239. X    received the program in object code or executable form with such
  240. X    an offer, in accord with Subsection b above.)
  241. X
  242. The source code for a work means the preferred form of the work for
  243. making modifications to it.  For an executable work, complete source
  244. code means all the source code for all modules it contains, plus any
  245. associated interface definition files, plus the scripts used to
  246. control compilation and installation of the executable.  However, as a
  247. special exception, the source code distributed need not include
  248. anything that is normally distributed (in either source or binary
  249. form) with the major components (compiler, kernel, and so on) of the
  250. operating system on which the executable runs, unless that component
  251. itself accompanies the executable.
  252. X
  253. If distribution of executable or object code is made by offering
  254. access to copy from a designated place, then offering equivalent
  255. access to copy the source code from the same place counts as
  256. distribution of the source code, even though third parties are not
  257. compelled to copy the source along with the object code.
  258. X
  259. X
  260. X
  261. X
  262. X
  263. X
  264. X
  265. X
  266. X
  267. X
  268. X
  269. X  4. You may not copy, modify, sublicense, or distribute the Program
  270. except as expressly provided under this License.  Any attempt
  271. otherwise to copy, modify, sublicense or distribute the Program is
  272. void, and will automatically terminate your rights under this License.
  273. However, parties who have received copies, or rights, from you under
  274. this License will not have their licenses terminated so long as such
  275. parties remain in full compliance.
  276. X
  277. X  5. You are not required to accept this License, since you have not
  278. signed it.  However, nothing else grants you permission to modify or
  279. distribute the Program or its derivative works.  These actions are
  280. prohibited by law if you do not accept this License.  Therefore, by
  281. modifying or distributing the Program (or any work based on the
  282. Program), you indicate your acceptance of this License to do so, and
  283. all its terms and conditions for copying, distributing or modifying
  284. the Program or works based on it.
  285. X
  286. X  6. Each time you redistribute the Program (or any work based on the
  287. Program), the recipient automatically receives a license from the
  288. original licensor to copy, distribute or modify the Program subject to
  289. these terms and conditions.  You may not impose any further
  290. restrictions on the recipients' exercise of the rights granted herein.
  291. You are not responsible for enforcing compliance by third parties to
  292. this License.
  293. X
  294. X  7. If, as a consequence of a court judgment or allegation of patent
  295. infringement or for any other reason (not limited to patent issues),
  296. conditions are imposed on you (whether by court order, agreement or
  297. otherwise) that contradict the conditions of this License, they do not
  298. excuse you from the conditions of this License.  If you cannot
  299. distribute so as to satisfy simultaneously your obligations under this
  300. License and any other pertinent obligations, then as a consequence you
  301. may not distribute the Program at all.  For example, if a patent
  302. license would not permit royalty-free redistribution of the Program by
  303. all those who receive copies directly or indirectly through you, then
  304. the only way you could satisfy both it and this License would be to
  305. refrain entirely from distribution of the Program.
  306. X
  307. If any portion of this section is held invalid or unenforceable under
  308. any particular circumstance, the balance of the section is intended to
  309. apply and the section as a whole is intended to apply in other
  310. circumstances.
  311. X
  312. It is not the purpose of this section to induce you to infringe any
  313. patents or other property right claims or to contest validity of any
  314. such claims; this section has the sole purpose of protecting the
  315. integrity of the free software distribution system, which is
  316. implemented by public license practices.  Many people have made
  317. generous contributions to the wide range of software distributed
  318. through that system in reliance on consistent application of that
  319. system; it is up to the author/donor to decide if he or she is willing
  320. to distribute software through any other system and a licensee cannot
  321. impose that choice.
  322. X
  323. This section is intended to make thoroughly clear what is believed to
  324. be a consequence of the rest of this License.
  325. X
  326. X
  327. X
  328. X
  329. X
  330. X
  331. X
  332. X
  333. X
  334. X
  335. X
  336. X
  337. X  8. If the distribution and/or use of the Program is restricted in
  338. certain countries either by patents or by copyrighted interfaces, the
  339. original copyright holder who places the Program under this License
  340. may add an explicit geographical distribution limitation excluding
  341. those countries, so that distribution is permitted only in or among
  342. countries not thus excluded.  In such case, this License incorporates
  343. the limitation as if written in the body of this License.
  344. X
  345. X  9. The Free Software Foundation may publish revised and/or new versions
  346. of the General Public License from time to time.  Such new versions will
  347. be similar in spirit to the present version, but may differ in detail to
  348. address new problems or concerns.
  349. X
  350. XEach version is given a distinguishing version number.  If the Program
  351. specifies a version number of this License which applies to it and "any
  352. later version", you have the option of following the terms and conditions
  353. either of that version or of any later version published by the Free
  354. Software Foundation.  If the Program does not specify a version number of
  355. this License, you may choose any version ever published by the Free Software
  356. XFoundation.
  357. X
  358. X  10. If you wish to incorporate parts of the Program into other free
  359. programs whose distribution conditions are different, write to the author
  360. to ask for permission.  For software which is copyrighted by the Free
  361. Software Foundation, write to the Free Software Foundation; we sometimes
  362. make exceptions for this.  Our decision will be guided by the two goals
  363. of preserving the free status of all derivatives of our free software and
  364. of promoting the sharing and reuse of software generally.
  365. X
  366. X                NO WARRANTY
  367. X
  368. X  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  369. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  370. OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  371. PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  372. OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  373. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  374. TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  375. PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  376. REPAIR OR CORRECTION.
  377. X
  378. X  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  379. WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  380. REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  381. INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  382. OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  383. TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  384. YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  385. PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  386. POSSIBILITY OF SUCH DAMAGES.
  387. X
  388. X             END OF TERMS AND CONDITIONS
  389. X
  390. X
  391. X
  392. X
  393. X
  394. X
  395. X
  396. X
  397. X
  398. X
  399. X
  400. X
  401. X
  402. X
  403. X
  404. X
  405. X    Appendix: How to Apply These Terms to Your New Programs
  406. X
  407. X  If you develop a new program, and you want it to be of the greatest
  408. possible use to the public, the best way to achieve this is to make it
  409. free software which everyone can redistribute and change under these terms.
  410. X
  411. X  To do so, attach the following notices to the program.  It is safest
  412. to attach them to the start of each source file to most effectively
  413. convey the exclusion of warranty; and each file should have at least
  414. the "copyright" line and a pointer to where the full notice is found.
  415. X
  416. X    <one line to give the program's name and a brief idea of what it does.>
  417. X    Copyright (C) 19yy  <name of author>
  418. X
  419. X    This program is free software; you can redistribute it and/or modify
  420. X    it under the terms of the GNU General Public License as published by
  421. X    the Free Software Foundation; either version 2 of the License, or
  422. X    (at your option) any later version.
  423. X
  424. X    This program is distributed in the hope that it will be useful,
  425. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  426. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  427. X    GNU General Public License for more details.
  428. X
  429. X    You should have received a copy of the GNU General Public License
  430. X    along with this program; if not, write to the Free Software
  431. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  432. X
  433. Also add information on how to contact you by electronic and paper mail.
  434. X
  435. If the program is interactive, make it output a short notice like this
  436. when it starts in an interactive mode:
  437. X
  438. X    Gnomovision version 69, Copyright (C) 19yy name of author
  439. X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  440. X    This is free software, and you are welcome to redistribute it
  441. X    under certain conditions; type `show c' for details.
  442. X
  443. The hypothetical commands `show w' and `show c' should show the appropriate
  444. parts of the General Public License.  Of course, the commands you use may
  445. be called something other than `show w' and `show c'; they could even be
  446. mouse-clicks or menu items--whatever suits your program.
  447. X
  448. You should also get your employer (if you work as a programmer) or your
  449. school, if any, to sign a "copyright disclaimer" for the program, if
  450. necessary.  Here is a sample; alter the names:
  451. X
  452. X  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  453. X  `Gnomovision' (which makes passes at compilers) written by James Hacker.
  454. X
  455. X  <signature of Ty Coon>, 1 April 1989
  456. X  Ty Coon, President of Vice
  457. X
  458. This General Public License does not permit incorporating your program into
  459. proprietary programs.  If your program is a subroutine library, you may
  460. consider it more useful to permit linking proprietary applications with the
  461. library.  If this is what you want to do, use the GNU Library General
  462. Public License instead of this License.
  463. END_OF_FILE
  464. if test 18054 -ne `wc -c <'plotfoil/COPYING'`; then
  465.     echo shar: \"'plotfoil/COPYING'\" unpacked with wrong size!
  466. fi
  467. # end of 'plotfoil/COPYING'
  468. fi
  469. if test -f 'plotfoil/README' -a "${1}" != "-c" ; then 
  470.   echo shar: Will not clobber existing file \"'plotfoil/README'\"
  471. else
  472. echo shar: Extracting \"'plotfoil/README'\" \(2041 characters\)
  473. sed "s/^X//" >'plotfoil/README' <<'END_OF_FILE'
  474. X
  475. Copyright 1992 Shamim P. Mohamed
  476. X
  477. This is the "plotfoil" package (V2.1) for plotting airfoil sections from data.
  478. It generates PostScript, does interpolation, spars, templates and allowances
  479. for sheeting.  For more info on the formats supported and options, see the
  480. comments in plotfoil.man.  The PostScript generated is quite vanilla, and
  481. should print on any printer. Some printers may run out of memory trying to
  482. print multi-page plots with lots of data. If that happens, recompile plotfoil
  483. with -DSAVEMEM, which may help. Otherwise, your only hope is either find
  484. another printer or try removing some of the input data.
  485. X
  486. The PostScript is sent to standard output. Use redirection or a pipe to send
  487. it to the printer.
  488. X
  489. This program runs on all the Unix platforms I've tried, i.e. Sun3, Sun4
  490. X(SparcStation 1, 1+, 2, LSC, SLX), SGI (personal Iris and 4D systems), NeXT,
  491. Sequent Symmetry, VAX/BSD. It also runs on MS-DOS (AT, PS/2 50, 70, 80; MS C
  492. compiler, Turbo C++) and VMS (VAX, DEC4000). It has worked on the following
  493. printers: Apple LaserWriters (Plus, II and NTX), NEC LC890, LC890XL, HP
  494. LaserJet, QMS PS2000 and PS2200, NeWSprint/SPARCprinter, DEC LN03
  495. Scriptprinter.
  496. X
  497. Please send any changes to me. This program is distributed under the terms of
  498. the Gnu General Public License Version 2 as published by the Free Software
  499. XFoundation. You can give away copies of this program to whoever you like, as
  500. long as you provide them with source code and all the copyright notices and
  501. licences stay with it. Also, if you make any changes to this program, the same
  502. conditions apply to the modified version so that we can all benefit from them.
  503. X(And please send me those changes!) See the file COPYING for more details.
  504. X
  505. X(The airfoil data are not covered by this license; they are in the public
  506. domain)
  507. X
  508. Shamim Mohamed
  509. shamim@cs.arizona.edu                      Dept. of Computer Science
  510. X{uunet,cmcl2,noao,...}!arizona!shamim       University of Arizona
  511. May 1992                                Tucson, AZ 85721
  512. X
  513. Voice: +1 602 621 6613
  514. XFax:   +1 602 621 4246
  515. END_OF_FILE
  516. if test 2041 -ne `wc -c <'plotfoil/README'`; then
  517.     echo shar: \"'plotfoil/README'\" unpacked with wrong size!
  518. fi
  519. # end of 'plotfoil/README'
  520. fi
  521. if test ! -d 'plotfoil/airfoils' ; then
  522.     echo shar: Creating directory \"'plotfoil/airfoils'\"
  523.     mkdir 'plotfoil/airfoils'
  524. fi
  525. if test -f 'plotfoil/makefile' -a "${1}" != "-c" ; then 
  526.   echo shar: Will not clobber existing file \"'plotfoil/makefile'\"
  527. else
  528. echo shar: Extracting \"'plotfoil/makefile'\" \(329 characters\)
  529. sed "s/^X//" >'plotfoil/makefile' <<'END_OF_FILE'
  530. X#
  531. X# Makefile for plotfoil
  532. X#
  533. X
  534. X#CC = gcc
  535. X#CFLAGS = -g -O
  536. X
  537. CFLAGS = -O
  538. X
  539. plotfoil : plotfoil.o spline.o
  540. X    $(CC) $(CFLAGS) -o plotfoil plotfoil.o spline.o -lm
  541. X
  542. lint :
  543. X    lint plotfoil.c spline.c
  544. X
  545. clean :
  546. X    -rm *.o *~
  547. X    -rm -i plotfoil
  548. X
  549. dist :
  550. X    (cd ..; tar cvf p plotfoil; compress p; uuencode plotfoil.tar.Z <p.Z >plotfoil-2.1)
  551. X    rm ../p.Z
  552. END_OF_FILE
  553. if test 329 -ne `wc -c <'plotfoil/makefile'`; then
  554.     echo shar: \"'plotfoil/makefile'\" unpacked with wrong size!
  555. fi
  556. # end of 'plotfoil/makefile'
  557. fi
  558. if test -f 'plotfoil/makefile.dos' -a "${1}" != "-c" ; then 
  559.   echo shar: Will not clobber existing file \"'plotfoil/makefile.dos'\"
  560. else
  561. echo shar: Extracting \"'plotfoil/makefile.dos'\" \(390 characters\)
  562. sed "s/^X//" >'plotfoil/makefile.dos' <<'END_OF_FILE'
  563. X#
  564. X# Makefile for DOS version of plotfoil
  565. X#
  566. X# This make file is appropriate for Microsoft C Version 6.00A
  567. X# and Microsoft NMAKE.
  568. X#
  569. X# Just type "nmake /f makefile.dos" to build the program.
  570. X#
  571. X# Andrew Patrick, andrew@calvin.dgbt.doc.ca
  572. X
  573. plotfoil.exe : plotfoil.obj spline.obj
  574. X    link +plotfoil+spline,plotfoil;
  575. X
  576. plotfoil.obj: plotfoil.c
  577. X    cl /c plotfoil.c
  578. X
  579. spline.obj: spline.c
  580. X    cl /c spline.c
  581. X
  582. END_OF_FILE
  583. if test 390 -ne `wc -c <'plotfoil/makefile.dos'`; then
  584.     echo shar: \"'plotfoil/makefile.dos'\" unpacked with wrong size!
  585. fi
  586. # end of 'plotfoil/makefile.dos'
  587. fi
  588. if test -f 'plotfoil/makefile.vms' -a "${1}" != "-c" ; then 
  589.   echo shar: Will not clobber existing file \"'plotfoil/makefile.vms'\"
  590. else
  591. echo shar: Extracting \"'plotfoil/makefile.vms'\" \(330 characters\)
  592. sed "s/^X//" >'plotfoil/makefile.vms' <<'END_OF_FILE'
  593. X#
  594. X# Makefile for VMS systems.
  595. X# Harm Munk (munk@prl.philips.nl)
  596. X#
  597. X
  598. plotfoil : plotfoil.obj spline.obj
  599. X        link/exe=plotfoil.exe plotfoil.obj,spline.obj
  600. X
  601. plotfoil.obj : plotfoil.c
  602. X        cc plotfoil
  603. X
  604. spline.obj : spline.c
  605. X        cc spline.c
  606. X
  607. clean :
  608. X        delete/noconfirm/nolog plotfoil.obj;*,spline.obj;*,plotfoil.exe;*
  609. X
  610. END_OF_FILE
  611. if test 330 -ne `wc -c <'plotfoil/makefile.vms'`; then
  612.     echo shar: \"'plotfoil/makefile.vms'\" unpacked with wrong size!
  613. fi
  614. # end of 'plotfoil/makefile.vms'
  615. fi
  616. if test -f 'plotfoil/plotfoil.1' -a "${1}" != "-c" ; then 
  617.   echo shar: Will not clobber existing file \"'plotfoil/plotfoil.1'\"
  618. else
  619. echo shar: Extracting \"'plotfoil/plotfoil.1'\" \(6731 characters\)
  620. sed "s/^X//" >'plotfoil/plotfoil.1' <<'END_OF_FILE'
  621. X.\" plotfoil.1l 2/17/92
  622. X.TH plotfoil 1l "Feb. 1992"
  623. X.SH NAME
  624. X\fBplotfoil\fP \- generate a PostScript plot of airfoil data.
  625. X.SH SYNTAX
  626. X\fBplotfoil\fP [\fIoptions\fP] [\fIfilename...\fP]
  627. X.SH DESCRIPTION
  628. This program plots (in PostScript) airfoil sections (well, actually any section
  629. that is not smoothly closed). It can also allow for spars, 
  630. sheeting, and prints registration marks that are aligned with the L.E. and T.E.
  631. It uses Bezier splines to interpolate between
  632. data points, with an option to use straight lines instead.
  633. X.SH OVERVIEW
  634. Plotfoil reads airfoil data and generates PostScript code that when printed on
  635. a PostScript printer will deliver a plot of the airfoil section along with
  636. spars (if any). The bounds of
  637. the section are also drawn, with crosses, and these can be used for
  638. registration of the ribs or templates. If the plot is going to be larger than
  639. one page, it will be spread over as many pages as are required.
  640. X.PP
  641. PostScript is a printer language for describing printed pages. Printers that
  642. accept PostScript include the Apple LaserWriters, QMS PS- series printers,
  643. DataProducts LZR-2665 and 2660 and the Linotronic 100 and 300 typesetters.
  644. PostScript is a trademark of Adobe Systems Incorporated.
  645. X.PP
  646. Bezier splines are used to calculate interpolating curves between the points.
  647. In some case the process may not deliver a smooth curve, and you will
  648. have to use the straight-line plot option (\fB\-s\fP).
  649. X.PP
  650. The program can also account for sheeting. If the wing you are building is to
  651. be sheeted, the ribs you need have to be inset from the required surface
  652. by the thickness of the sheet. When this option is used, you will notice that
  653. two curves are actually plotted. The inner curve is the one to use for ribs.
  654. X(The outer can be used if you are building a jig or saddle that will be
  655. sheeted.) The airfoil
  656. outline is plotted with a dotted line.
  657. X.SH OPTIONS
  658. X.IP \fB\-c\fR
  659. Sets the chord of the section to plot. The argument is the chord, in units of
  660. either mm, cm or inches. The units are specified by a
  661. trailing `m', `c', or `i',
  662. with the default of mm being used if unspecified.
  663. X.IP \fB\-s\fR
  664. This flag indicates that for \fIx\fP values of greater than 2.5%,
  665. straight lines
  666. should be used to join the points. This results in a PostScript file which is
  667. probably just as good but should print in less time. The limit (2.5%) can be
  668. changed with the \fB-l\fP option.
  669. X.IP \fB\-l\fR
  670. This option changes the limit used with the \fB-s\fP option. It takes the
  671. percentage-chord as argument.
  672. X.IP \fB\-i\fR
  673. This option draws the section inset by the specified amount, which is what you
  674. would use if the wing you are building is sheeted. The units default to those
  675. used for the chord.
  676. X.IP \fB\-sp\fP
  677. This option adds a spar to the plot. It takes two arguments, the offset
  678. X(expressed as a percentage of the chord) and the thickness of the spar
  679. X(default units:
  680. same as used for the chord). This option can be used multiple times to
  681. draw more than one spar. Also, 0-thickness spars can be used to draw vertical
  682. lines on the plot.
  683. X.IP \fB\-th\fR
  684. This option sets the height of the template outline, measured from the chord
  685. line. The default is 0.
  686. X.IP \fB\-tl\fR
  687. X.IP \fB\-tt\fR
  688. These options set the horizontal extents of the template. The value specified
  689. is the distance of the edge of the template from the {leading, trailing} edge.
  690. The units default to those specified while setting the chord. The default
  691. value is 0.
  692. X.IP
  693. If any of \fB\-th\fR, \fB\-tl\fR or \fB\-tt\fR is used, a template will be
  694. drawn.
  695. X.IP \fB\-h\fR
  696. Prints some help information.
  697. X.IP \fB\-o\fR
  698. Writes the output to the specified file.
  699. X.SH INPUT FORMATS
  700. There are two formats for input data, distinguished by how coordinates are
  701. specified. The first line of the file is taken to be the name of the section
  702. and is printed along with the plot.
  703. X.PP
  704. All the \fIx\fP values have to be positive, with 0 being the L.E. and the 
  705. max value
  706. being the T.E. The \fIx\fP values don't have to be in the range [0, 1] anymore,
  707. but can be [0, \fIa\fP].
  708. X.PP
  709. This is the first format:
  710. X   SD-8020
  711. X   1.0 0
  712. X   0.9 0.011
  713. X   0.85 0.02
  714. X   ...
  715. X   1.0 0
  716. X.br
  717. Note: it starts at \fIx\fP=1.0 (the trailing edge), goes around 
  718. and ends again at the
  719. T.E. This is the format used by the sections in Soartech 8.
  720. X.PP
  721. This is the second format:
  722. X   Clark YH
  723. X   0 0 0
  724. X   0.0125 0.0409 -0.0183
  725. X   0.025 .0529 -.0271
  726. X   ...
  727. X   1.0 0 0
  728. X.br
  729. This starts at the L.E. and ends at the T.E., with the columns being the upper
  730. and lower ordinate values. This is the format that most of the NACA sections
  731. were published in.
  732. X.SH EXAMPLES
  733. This command:
  734. X.IP
  735. plotfoil -c 20c -i 2m -sp 32 0.2 sd8020 | lpr
  736. X.LP
  737. will plot the SD-8020 section with a chord of 20cm, with a sheeting allowance
  738. of 2mm, and a spar 2mm wide at 32% chord. The name of the section and the
  739. sheeting allowance are also printed.
  740. X.IP
  741. plotfoil -c 8.5i -i 0.125 -s -l 10 clarkYH | lpr
  742. X.LP
  743. will plot the Clark YH with a chord of 8.5 inches. Only the area from the L.E.
  744. to 10% back will interpolated with splines, and from 10% to the T.E.; straight
  745. lines will be used to connect the points. A sheeting allowance of 0.125" (1/8")
  746. will also be drawn.
  747. X.SH DISTRIBUTION
  748. X\fBplotfoil\fP is free; anyone may redistribute copies of it to anyone
  749. under the terms stated in the Gnu General Public License version 2, a
  750. copy of which should accompany each copy of plotfoil. See the file ``COPYING''
  751. in the source area. If you do not have this file, a copy may be obtained from:
  752. X   Free Software Foundation
  753. X   1000 Mass Ave.
  754. X   Cambridge, MA 02138
  755. X.br
  756. or from the author.
  757. X.LP
  758. Also, if you make any changes to this program and re-distribute it, the same
  759. conditions apply to the modified version so that we can all benefit from
  760. it. And please send me those changes!
  761. X.SH AUTHOR
  762. Shamim Mohamed (shamim@cs.arizona.edu)
  763. X.br
  764. Dept of Computer Science
  765. X.br
  766. University of Arizona
  767. X.br
  768. Tucson, AZ 85721
  769. X.SH BUGS
  770. On some printers, there may be a stack overflow if the plot is on more than one
  771. page and there are more than a certain number of coordinate values. If this
  772. happens, first try compiling with -DSAVEMEM and run again, then try
  773. X.IP
  774. a) finding another printer, or
  775. X.IP
  776. b) removing some of the airfoil data.
  777. X.LP
  778. In the latter case you may still get satisfactory results because of the
  779. smooth interpolation used.
  780. X.PP
  781. Since the program doesn't know how big the printer page size is, it can get
  782. confused. This should only err conservatively, like producing an extra blank
  783. page on a multi-page plot. As long as the page is higher than about 11 inches
  784. X(27 cm) everything should be fine.
  785. X.PP
  786. I don't know of any other bugs right now,
  787. but please send all bug reports to me. Include
  788. version number and the exact details (input files, command-line options  etc.),
  789. please.
  790. END_OF_FILE
  791. if test 6731 -ne `wc -c <'plotfoil/plotfoil.1'`; then
  792.     echo shar: \"'plotfoil/plotfoil.1'\" unpacked with wrong size!
  793. fi
  794. # end of 'plotfoil/plotfoil.1'
  795. fi
  796. if test -f 'plotfoil/plotfoil.c' -a "${1}" != "-c" ; then 
  797.   echo shar: Will not clobber existing file \"'plotfoil/plotfoil.c'\"
  798. else
  799. echo shar: Extracting \"'plotfoil/plotfoil.c'\" \(17198 characters\)
  800. sed "s/^X//" >'plotfoil/plotfoil.c' <<'END_OF_FILE'
  801. X/*
  802. X * Copyright 1992 Shamim P. Mohamed
  803. X *
  804. X * This program is free software; you can redistribute it and/or modify
  805. X * it under the terms of the GNU General Public License as published by
  806. X * the Free Software Foundation; either version 2 of the License, or
  807. X * (at your option) any later version.
  808. X *
  809. X * This program is distributed in the hope that it will be useful,
  810. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  811. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  812. X * GNU General Public License for more details.
  813. X *
  814. X * You should have received a copy of the GNU General Public License
  815. X * along with this program; if not, write to the Free Software
  816. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  817. X *
  818. X * Author:
  819. X * shamim@cs.arizona.edu
  820. X * Shamim Mohamed
  821. X * Dept. of Computer Science
  822. X * University of Arizona
  823. X *
  824. X * ---------------------------------------------------------------------------
  825. X *
  826. X * Plots airfoils (or indeed any section)
  827. X * ---------------------------------------------------------------------------
  828. X * There are two formats for input data. Here are examples of each:
  829. X *
  830. X * Input formats:
  831. X *    1 Title
  832. X *    1.0    0
  833. X *    0.9    0.011
  834. X *    0.85    0.02
  835. X *    ...
  836. X *    1.0    0
  837. X * This should start at the trailing edge (x = 1.0), follow a surface to the
  838. X * LE (x = 0), and continue back to the TE (assuming the LE is smooth).
  839. X * Or:
  840. X *    2 Title
  841. X *    0        0    0
  842. X *    .0125    .0409   -.0183
  843. X *    .025    .0529    -.0271
  844. X *    ...
  845. X *    1.0    0    0
  846. X * The values go across the foil from LE (x = 0) to TE (x = 1).
  847. X *
  848. X * Remember: the digit in the first line ("1" or "2") is important!
  849. X *
  850. X * ---------------------------------------------------------------------------
  851. X * Options:
  852. X *    -c : Chord size (trailing c, m or i represents cm, mm or in)
  853. X *    -s : Use straight line approximation for x values > limit
  854. X *    -l : The limit used in -s (default: 0.025)
  855. X *    -i : Draw allowance for sheeting, of i units (units are same as chord)
  856. X *    -t?: Draw template
  857. X *    -spar : Draw spar
  858. X *    -h : help
  859. X *
  860. X * Try: plotfoil -c 200m -i 2 file
  861. X * (means chord = 200mm, with allowance for a 2mm skin)
  862. X *
  863. X */
  864. X
  865. X#include <stdio.h>
  866. X#include <math.h>
  867. X#include <string.h>
  868. X
  869. X#define streq(a, b)   (strcmp((a),(b)) == 0)
  870. X
  871. X#define MAXPOINTS 100
  872. X#define MAX_SPARS  10
  873. X
  874. X/* output scaling etc. */
  875. X#define SCALE  10000       /* size of the field (output)        */
  876. X#define RADIUS    10       /* radius of circles denoting points */
  877. X#define TXTSIZ    20       /* size to be used for text          */
  878. X
  879. static int sflag, iflag, tflag, nsheets, nspars=0;
  880. static float c = 1.0, s_limit = 0.025;
  881. X
  882. extern void interpolate();
  883. X
  884. void init_output(), put_line(), put_curve(), put_title(), end_output(),
  885. X   draw_template(), draw_spar(), end_lines(), draw_double_line(), get_value(),
  886. X   do_scaling(), process();
  887. X
  888. typedef struct {
  889. X   double x, y;
  890. X} point;
  891. X
  892. typedef struct {
  893. X   float raw_value, scale, pts;
  894. X   char *units;
  895. X} value;
  896. X
  897. typedef struct {
  898. X   float offset;
  899. X   value thick;
  900. X} spar_desc;
  901. X
  902. static value
  903. X   chord = {100.0, 2.834, 283.4, "mm"},
  904. X   sheeting = {0.0, 1.0, 0.0, ""},
  905. X   templ_h = {0.0, 1.0, 0.0, ""},
  906. X   templ_le = {0.0, 1.0, 0.0, ""},
  907. X   templ_te = {0.0, 1.0, 0.0, ""}; 
  908. X   
  909. spar_desc spars[MAX_SPARS];
  910. X
  911. static FILE *fout = stdout;
  912. X
  913. main(argc, argv)
  914. int argc;
  915. char *argv[];
  916. X{
  917. X   char *pointfile = "";
  918. X   int ch, i, n, k, qflag=0;
  919. X   char cont, *p;
  920. X   FILE *fp, *get_file();
  921. X   int argp = 1;
  922. X
  923. X   while(argc > argp) {
  924. X      p = argv[argp];
  925. X      if(*p == '-' && *(p+1) != 0) {
  926. X     switch (*(p+1)) {
  927. X     case 'l':
  928. X        sscanf(argv[++argp], "%f", &s_limit);
  929. X        s_limit /= 100.0;
  930. X        break;
  931. X     case 's':
  932. X        if(*(p+2) == 'p') {
  933. X           sscanf(argv[++argp], "%f", &spars[nspars].offset);
  934. X           get_value(argv[++argp], &spars[nspars].thick);
  935. X           spars[nspars].offset /= 100.0;
  936. X           nspars++;
  937. X        }
  938. X        else
  939. X           sflag++;
  940. X        break;
  941. X     case 'q': qflag++; break;
  942. X     case 'i':
  943. X        iflag++;
  944. X        get_value(argv[++argp], &sheeting);
  945. X        break;
  946. X     case 'c':
  947. X        get_value(argv[++argp], &chord);
  948. X        break;
  949. X     case 't':
  950. X        tflag++;
  951. X        switch (*(p+2)) {
  952. X        case 'h':
  953. X           get_value(argv[++argp], &templ_h);
  954. X           break;
  955. X        case 't':
  956. X           get_value(argv[++argp], &templ_te);
  957. X           break;
  958. X        case 'l':
  959. X           get_value(argv[++argp], &templ_le);
  960. X           break;
  961. X        default:
  962. X           break;
  963. X        }
  964. X        break;
  965. X     case 'o':
  966. X        if((fout = fopen(argv[++argp], "w")) == NULL) {
  967. X           fprintf(stderr, "Could not open \"%s\" for writing!\n");
  968. X           fout = stdout;
  969. X        }
  970. X        break;
  971. X     case '-':
  972. X        goto done_opts;
  973. X     default:
  974. X        fprintf(stderr,
  975. X            "\nUsage: %s [-hqs] [-c<n>[cim]] [-l<n>] [-i<n>] [-sp <offset> <thickness>] [-tt <n>] [-th <n>] [-tl <n>] [-o outfile] [files]\n",
  976. X            argv[0]);
  977. X        fputs("   -h : Print this message\n", stderr);
  978. X        fputs("   -q : Skip the copyright message at startup\n", stderr);
  979. X        fputs("   -s : Use straight-line segments for x > s_limit\n",
  980. X          stderr);
  981. X        fputs("These take arguments:\n", stderr);
  982. X        fputs("   -c : Set chord size. A trailing unit can be ", stderr);
  983. X        fputs("specified:\n        c = cm, i = inches, m = mm (default)\n",
  984. X          stderr);
  985. X        fputs("   -l : Set s_limit to n (default is 0.025)\n", stderr);
  986. X        fputs("   -i : Draw sheeting allowance of n units (units same as chord)\n", stderr);
  987. X        fputs("   -sp: Draw a spar at offset of specified thickness\n",
  988. X          stderr);
  989. X        fputs("   -t.: Draw template outlines of specified size\n",
  990. X          stderr);
  991. X        fputs("   -o : Write output to file\n", stderr);
  992. X        fputs("\nA good place to start is:\n", stderr);
  993. X        fprintf(stderr, " %s -c 200m file1\n\n", argv[0]);
  994. X        exit(1);
  995. X     }
  996. X      }
  997. X      else
  998. X     break;
  999. X      argp++;
  1000. X   }
  1001. X
  1002. X done_opts:
  1003. X   
  1004. X   if(!qflag) {
  1005. X      fputs("Plotfoil v2.1, Copyright 1992 Shamim Mohamed. This is", stderr);
  1006. X      fputs(" free software\nand is freely distributable under", stderr);
  1007. X      fputs(" certain conditions. See\nthe file \"COPYING\" in the", stderr);
  1008. X      fputs(" source area for details.\n", stderr);
  1009. X   }
  1010. X
  1011. X
  1012. X   if(*chord.units == '\0') {
  1013. X      chord.units = "mm";
  1014. X      chord.scale = 2.834;
  1015. X   }
  1016. X   do_scaling(&chord, 0);
  1017. X   do_scaling(&sheeting, &chord);
  1018. X   do_scaling(&templ_h, &chord);
  1019. X   do_scaling(&templ_te, &chord);
  1020. X   do_scaling(&templ_le, &chord);
  1021. X   for(i = 0; i < nspars; i++)
  1022. X      do_scaling(&spars[i].thick, &chord);
  1023. X   
  1024. X   nsheets = (chord.pts+templ_te.pts+templ_le.pts)/720 + 1;
  1025. X
  1026. X   if(argp >= argc)
  1027. X      process(stdin, "<stdin>");
  1028. X   else
  1029. X      for (; argp < argc; argp++) {
  1030. X         if((fp = fopen(argv[argp], "r")) == NULL) {
  1031. X            fprintf(stderr, "%s: can't open \"%s\"\n", argv[0], argv[argp]);
  1032. X            continue;
  1033. X         }
  1034. X         process(fp, argv[argp]);
  1035. X         close(fp);
  1036. X      }
  1037. X
  1038. X   exit(0);
  1039. X}
  1040. X
  1041. void get_value(s, val)
  1042. char *s;
  1043. value *val;
  1044. X{
  1045. X   char c;
  1046. X   
  1047. X   if(sscanf(s, "%f%c", &val->raw_value, &c) == 1) {
  1048. X      val->scale = 1.0;
  1049. X      val->units = "";
  1050. X   }
  1051. X   else
  1052. X      switch((int)c) {
  1053. X      case 'i': val->scale = 72.0; val->units = "\""; break;
  1054. X      case 'c': val->scale = 28.34; val->units = "cm"; break;
  1055. X      case 'm':
  1056. X      default:
  1057. X     val->units = "mm";
  1058. X     val->scale = 2.834; break;
  1059. X      }
  1060. X   val->pts = val->raw_value * val->scale;
  1061. X}
  1062. void do_scaling(val, master)
  1063. value *val, *master;
  1064. X{
  1065. X   if(val->units[0] == '\0' && master) {
  1066. X      val->units = master->units;
  1067. X      val->scale = master->scale;
  1068. X   }
  1069. X   val->pts = val->raw_value * val->scale;
  1070. X}
  1071. X
  1072. float U[MAXPOINTS], L[MAXPOINTS], X[MAXPOINTS], Y[MAXPOINTS];
  1073. char title[100];
  1074. X
  1075. void process(fp, f)
  1076. XFILE *fp;
  1077. char *f;
  1078. X{
  1079. X   float x, upper, lower, minx, maxx;
  1080. X   int i, n, bar;
  1081. X   char temp_buf[BUFSIZ];
  1082. X
  1083. X   init_output();
  1084. X   /* fmt_type = fgetc(fp); (void) fgetc(fp); */
  1085. X   fgets(title, 100, fp);
  1086. X   put_title(title);
  1087. X   (void) fgets(temp_buf, BUFSIZ, fp);
  1088. X   n = sscanf(temp_buf, "%f %f %f", &x, &upper, &lower);
  1089. X   if(n == 2) {
  1090. X      /* It's a straight x-y file, starting at the T.E. */
  1091. X      minx = maxx = X[0] = x; Y[0] = upper;
  1092. X      i = 1;
  1093. X
  1094. X      while((n = fscanf(fp, "%f %f", &x, &upper)) != EOF && n == 2) {
  1095. X         X[i] = x; Y[i] = upper;
  1096. X     if(minx > x) minx = x; if(maxx < x) maxx = x;
  1097. X         i++;
  1098. X      }
  1099. X      if(n != EOF && n != 2) {
  1100. X     fprintf(stderr, "Invalid input in \"%s\" (line %d)\n", f, i+2);
  1101. X     return;
  1102. X      }
  1103. X      if(X[0] != X[i-1] || Y[0] != Y[i-1]) {
  1104. X     fprintf(stderr,
  1105. X        "Invalid input: data does not start and end at the same point.\n");
  1106. X     return;
  1107. X      }
  1108. X      if(minx < 0.0) {
  1109. X     fprintf(stderr, "Error: x values cannot be negative.\n");
  1110. X     return;
  1111. X      }
  1112. X      if(maxx == 0.0) {
  1113. X     fprintf(stderr, "Error: no x values?\n");
  1114. X     return;
  1115. X      }
  1116. X      plot_points(-i, maxx);
  1117. X   }
  1118. X   else if(n == 3) {
  1119. X      minx = maxx = X[0] = x; U[0] = upper; L[0] = lower;
  1120. X      i = 1;
  1121. X
  1122. X      while((n = fscanf(fp, "%f %f %f", &x, &upper, &lower)) != EOF && n == 3){
  1123. X         X[i] = x; U[i] = upper; L[i] = lower;
  1124. X     if(minx > x) minx = x; if(maxx < x) maxx = x;
  1125. X         i++;
  1126. X      }
  1127. X      if(n != EOF && n != 3) {
  1128. X     fprintf(stderr, "Invalid input in \"%s\" (line %d)\n", f, i+2);
  1129. X     return;
  1130. X      }
  1131. X      if(minx < 0.0) {
  1132. X     fprintf(stderr, "Error: x values cannot be negative.\n");
  1133. X     return;
  1134. X      }
  1135. X      if(maxx == 0.0) {
  1136. X     fprintf(stderr, "Error: no x values?\n");
  1137. X     return;
  1138. X      }
  1139. X
  1140. X      plot_points(i, maxx);
  1141. X   }
  1142. X   else
  1143. X      fprintf(stderr, "Invalid input in \"%s\" (line 2)\n", f);
  1144. X}
  1145. X
  1146. static float upperx, uppery, lowerx, lowery;
  1147. X
  1148. X/* Misc. math. */
  1149. double sqr(x)
  1150. double x;
  1151. X{
  1152. X   return x*x;
  1153. X}
  1154. X
  1155. X/*
  1156. X * The Bezier part:
  1157. X */
  1158. X
  1159. X#define px(i) (points[(i)].x)
  1160. X#define py(i) (points[(i)].y)
  1161. X
  1162. point points[MAXPOINTS];
  1163. X
  1164. plot_points(n, maxx)
  1165. int n;
  1166. float maxx;
  1167. X{
  1168. X
  1169. X   int i, j, npoints = 0;
  1170. X   double m1, m2, m, l, p2x, p2y, p3x, p3y;
  1171. X   double d = 3.0, e = 0.2;
  1172. X   void init_lines(), put_curve();
  1173. X
  1174. X   /* first, collect all the points into one array points: */
  1175. X   if(n < 0) {
  1176. X      n = -n;
  1177. X      for(i = n - 1; i >= 0; i--, npoints++) {
  1178. X         px(npoints) = X[i]/maxx;
  1179. X         py(npoints) = Y[i]/maxx;
  1180. X      }
  1181. X   }
  1182. X   else {
  1183. X      for(i = n - 1; i >= 0; i--, npoints++) {
  1184. X         px(npoints) = X[i]/maxx;
  1185. X         py(npoints) = L[i]/maxx;
  1186. X      }
  1187. X      for(i = 1; i < n; i++, npoints++) {
  1188. X         px(npoints) = X[i]/maxx;
  1189. X         py(npoints) = U[i]/maxx;
  1190. X      }
  1191. X   }
  1192. X   
  1193. X   if(tflag) {
  1194. X      draw_template(templ_h.pts, templ_le.pts, templ_te.pts);
  1195. X   }
  1196. X
  1197. X   for(i = 0; i < nspars; i++)
  1198. X      draw_spar(spars[i].offset, spars[i].thick.pts, points, npoints);
  1199. X   
  1200. X   i = 0;
  1201. X   if(sflag) {
  1202. X      /* In the region s_limit to 100%, use straight lines to plot */
  1203. X      i = 1;
  1204. X      init_lines(px(0), py(0));
  1205. X      while(px(i) > s_limit && px(i) < 1.0) {
  1206. X         put_line(px(i), py(i));
  1207. X         i++;
  1208. X      }
  1209. X      i--;
  1210. X      
  1211. X      for(j = i+1; px(j) <= s_limit && px(j) <= 1.0; j++)
  1212. X     ;
  1213. X      
  1214. X      interpolate(points+i, j-i-1, d, e, init_lines, put_curve);
  1215. X      
  1216. X      i = j;
  1217. X      /* Finish off rest i.e. 2.5% to 100% with straight lines */
  1218. X      for(;;) {
  1219. X     put_line(px(i), py(i));
  1220. X     if(px(i++) >= 1.0) break;
  1221. X      }
  1222. X   }
  1223. X   else
  1224. X      interpolate(points, npoints, d, e, init_lines, put_curve);
  1225. X
  1226. X   end_output();
  1227. X}
  1228. X
  1229. void draw_spar(offset, thick, points, n)
  1230. float offset, thick;
  1231. point *points;
  1232. int n;
  1233. X{
  1234. X   float upper, lower;
  1235. X   int i;
  1236. X
  1237. X   i = 0;
  1238. X   while(i < n) {
  1239. X      if(offset >= points[i].x) {
  1240. X     upper = points[i].y +
  1241. X        (points[i].y - points[i-1].y)/(points[i].x - points[i-1].x)*
  1242. X           (points[i].x - offset);
  1243. X     break;
  1244. X      }
  1245. X      i++;
  1246. X   }
  1247. X   while(i < n) {
  1248. X      if(offset <= points[i].x) {
  1249. X     lower = points[i].y +
  1250. X        (points[i].y - points[i-1].y)/(points[i].x - points[i-1].x)*
  1251. X           (points[i].x - offset);
  1252. X     break;
  1253. X      }
  1254. X      i++;
  1255. X   }
  1256. X
  1257. X   draw_double_line(offset, upper, offset, lower, thick);
  1258. X   
  1259. X}
  1260. X
  1261. X/* ========================= PostScript routines =========================== */
  1262. X
  1263. void init_output()
  1264. X{
  1265. X   fputs("%!\n% Created by Plotfoil 2.0\n", fout);
  1266. X   fprintf(fout, "%%%%Orientation: Landscape\n");
  1267. X   fputs("/S {stroke} bind def /L {lineto} bind def /M {moveto} bind def\n",
  1268. X     fout);
  1269. X   fputs("/X {moveto 10 0 rmoveto -20 0 rlineto 10 0 rmoveto\n", fout);
  1270. X   fputs("    0 10 rmoveto 0 -20 rlineto 0 10 rmoveto} bind def\n", fout);
  1271. X   fputs("/drawbbox {4 dict begin\n", fout);
  1272. X   fputs("   /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n", fout);
  1273. X   fputs("   x1 y1 X x1 y2 X x2 y2 X x2 y1 X\n", fout);
  1274. X   fputs("end} bind def\n", fout);
  1275. X   fputs("/drawrect {4 dict begin newpath\n", fout);
  1276. X   fputs("   /y2 exch def /x2 exch def /y1 exch def /x1 exch def\n", fout);
  1277. X   fputs("   x1 y1 moveto x1 y2 lineto x2 y2 lineto x2 y1 lineto closepath\n",
  1278. X     fout);
  1279. X   fputs("   stroke\nend} bind def\n", fout);
  1280. X   fputs("/landscape {newpath clippath pathbbox pop exch pop add 0 translate\n",
  1281. X     fout);
  1282. X   fputs("90 rotate newpath} bind def\n", fout);
  1283. X
  1284. X   fputs("/C {curveto} bind def\n", fout);
  1285. X   if(nsheets > 1) {
  1286. X      fputs("/plarge { /ii exch def /jj exch def /bproc exch def 0 1 ii\n",
  1287. X        fout);
  1288. X      fputs("1 sub { /i exch def 0 1 jj 1 sub { /j exch def newpath lm\n",
  1289. X        fout);
  1290. X      fputs("bm moveto 0 pht rlineto pwt 0 rlineto 0 pht neg rlineto\n", fout);
  1291. X      fputs("closepath gsave 0 setlinewidth stroke grestore clip gsave\n",
  1292. X        fout);
  1293. X      fputs("pwt j mul neg pht i mul neg translate bproc showpage\n", fout);
  1294. X      fputs("grestore } for } for } def newpath clippath pathbbox\n", fout);
  1295. X      fputs("1 sub /top exch def 1 sub /right exch def 1 add /bm exch def\n",
  1296. X        fout);
  1297. X      fputs("1 add /lm exch def /pwt right lm sub def /pht top bm sub def\n",
  1298. X        fout);
  1299. X      fputs("newpath\n", fout);
  1300. X   }
  1301. X}
  1302. X
  1303. void put_curve(x1, y1, x2, y2, x3, y3)
  1304. double x1, y1, x2, y2, x3, y3;
  1305. X{
  1306. X   x1 *= chord.pts; y1 *= chord.pts; x2 *= chord.pts; y2 *= chord.pts;
  1307. X   x3 *= chord.pts; y3 *= chord.pts;
  1308. X   fprintf(fout, "%.2f %.2f %.2f %.2f %.2f %.2f C\n", x1, y1, x2, y2, x3, y3);
  1309. X}
  1310. X
  1311. void init_lines(x, y)
  1312. double x, y;
  1313. X{
  1314. X   x *= chord.pts;
  1315. X   y *= chord.pts;
  1316. X#ifdef SAVEMEM
  1317. X   if(nsheets > 1)
  1318. X      fprintf(fout, "newpath } def /buildpath { %.2f %.2f M\n", x, y);
  1319. X   else
  1320. X      fprintf(fout, "newpath %.2f %.2f M\n", x, y);
  1321. X#else
  1322. X   fprintf(fout, "newpath %.2f %.2f M\n", x, y);
  1323. X#endif
  1324. X}
  1325. X
  1326. void put_line(x, y)
  1327. double x, y;
  1328. X{
  1329. X   fprintf(fout, "%.2f %.2f L\n", x*chord.pts, y*chord.pts);
  1330. X}
  1331. X
  1332. void end_lines()
  1333. X{
  1334. X   fputs("stroke\n", fout);
  1335. X}
  1336. X
  1337. void draw_double_line(x1, y1, x2, y2, spacing)
  1338. float x1, y1, x2, y2, spacing;
  1339. X{
  1340. X   fprintf(fout, "%.2f %.2f M %.2f %.2f L\n",
  1341. X       x1*chord.pts, y1*chord.pts, x2*chord.pts, y2*chord.pts);
  1342. X   if(spacing >= 1.0) {
  1343. X      fprintf(fout,
  1344. X          "gsave gsave %.1f setlinewidth 0 setgray stroke\n", spacing);
  1345. X      fprintf(fout,
  1346. X          "grestore %.1f setlinewidth 1 setgray stroke grestore newpath\n",
  1347. X          spacing-0.5);
  1348. X   }
  1349. X   else
  1350. X      fputs("stroke\n", fout);
  1351. X}
  1352. X
  1353. void draw_template(h, le, te)
  1354. float h, te, le;
  1355. X{
  1356. X   fprintf(fout, "-%.2f -%.2f %.2f %.2f drawrect\n", le, h, te+chord.pts, h);
  1357. X}
  1358. X
  1359. char *ftoa(x)
  1360. float x;
  1361. X{
  1362. X   static char buf[25];
  1363. X   char *p;
  1364. X   sprintf(buf, "%f", x);
  1365. X
  1366. X   p = buf; while(*p) p++;
  1367. X   p--;
  1368. X   while(*p == '0') p--;
  1369. X   if(*p == '.') p--;
  1370. X   p[1] = 0;
  1371. X   return buf;
  1372. X}
  1373. X
  1374. void put_title(s)
  1375. char *s;
  1376. X{
  1377. X   char *p;
  1378. X   int i;
  1379. X   float y;
  1380. X   
  1381. X   p = s;
  1382. X   while(*p != '\n' && *p != '\0') p++;
  1383. X   *p = '\0';
  1384. X
  1385. X   fputs("gsave landscape\n", fout);
  1386. X   fprintf(fout,
  1387. X       "/Times-Roman findfont 30 scalefont setfont 50 130 M (%s) show\n",
  1388. X      s);
  1389. X   fputs("/Times-Roman findfont 11 scalefont setfont\n", fout);
  1390. X   y = 110.0;
  1391. X   fprintf(fout, "50 %.4g M (Chord: %.3g%s) show\n",y, chord.raw_value, chord.units);
  1392. X   y -= 13.4;
  1393. X   if(iflag) {
  1394. X      fprintf(fout, "50 %.4g M (with %.3g%s sheeting allowance) show\n", y,
  1395. X             sheeting.raw_value, sheeting.units);
  1396. X      y -= 13.4;
  1397. X   }
  1398. X
  1399. X   if(tflag) {
  1400. X      fprintf(fout, "50 %.4g M (template: height %.3g%s", y,
  1401. X         templ_h.raw_value, templ_h.units);
  1402. X      fprintf(fout, ", %.3g%s at LE,", templ_le.raw_value, templ_le.units);
  1403. X      fprintf(fout, " %.3g%s at TE) show\n", templ_te.raw_value,
  1404. X          templ_te.units);
  1405. X      y -= 13.4;
  1406. X   }
  1407. X   for(i = 0; i < nspars; i++, y -= 13.4)
  1408. X      fprintf(fout,
  1409. X          "50 %.4g M (Spar at %.3g %% chord, thickness %.3g%s) show\n",
  1410. X          y, spars[i].offset*100, spars[i].thick.raw_value,
  1411. X          spars[i].thick.units);
  1412. X   fputs("grestore newpath\n", fout);
  1413. X#ifdef SAVEMEM
  1414. X   if(nsheets > 1)
  1415. X      fputs("/setup {\n", fout);
  1416. X#else   
  1417. X   if(nsheets > 1) putc('{', fout);
  1418. X#endif
  1419. X   fprintf(fout,
  1420. X       "0.1 setlinewidth landscape %.4g 300 translate\n", templ_le.pts+30);
  1421. X}
  1422. X
  1423. void end_output()
  1424. X{
  1425. X#ifdef SAVEMEM
  1426. X   if(nsheets > 1) fputs("} def /trail {", fout);
  1427. X#endif
  1428. X   if(iflag) {
  1429. X      fputs("gsave gsave gsave\n", fout);
  1430. X      fprintf(fout, "0 setgray %.4g setlinewidth stroke\n", sheeting.pts*2);
  1431. X      fprintf(fout, "grestore %.4g setlinewidth 1 setgray\n",
  1432. X          sheeting.pts*2-0.5);
  1433. X      fputs("stroke grestore [2 4] 0 setdash stroke grestore\n", fout);
  1434. X   }
  1435. X   else
  1436. X      fputs("gsave stroke grestore\n", fout);
  1437. X   
  1438. X   fputs("pathbbox newpath drawbbox stroke\n", fout);
  1439. X   fprintf(fout,
  1440. X       "gsave .8 setgray %.4g 0 moveto %.4g 0 lineto stroke grestore\n",
  1441. X       -templ_le.pts, chord.pts+templ_te.pts);
  1442. X#ifdef SAVEMEM
  1443. X   if(nsheets > 1) fputs("} def {setup buildpath trail\n", fout);
  1444. X#endif
  1445. X   if(nsheets > 1)
  1446. X      fprintf(fout, "} 1 %d plarge\n", nsheets);
  1447. X   else
  1448. X      fputs("showpage\n", fout);
  1449. X}
  1450. X
  1451. END_OF_FILE
  1452. if test 17198 -ne `wc -c <'plotfoil/plotfoil.c'`; then
  1453.     echo shar: \"'plotfoil/plotfoil.c'\" unpacked with wrong size!
  1454. fi
  1455. # end of 'plotfoil/plotfoil.c'
  1456. fi
  1457. if test -f 'plotfoil/spline.c' -a "${1}" != "-c" ; then 
  1458.   echo shar: Will not clobber existing file \"'plotfoil/spline.c'\"
  1459. else
  1460. echo shar: Extracting \"'plotfoil/spline.c'\" \(4617 characters\)
  1461. sed "s/^X//" >'plotfoil/spline.c' <<'END_OF_FILE'
  1462. X
  1463. X/*
  1464. X * Code to generate bezier control points to interpolate between points.
  1465. X * Copyright Shamim Mohamed 1991
  1466. X *
  1467. X * This program is free software; you can redistribute it and/or modify
  1468. X * it under the terms of the GNU General Public License as published by
  1469. X * the Free Software Foundation; either version 2 of the License, or
  1470. X * (at your option) any later version.
  1471. X *
  1472. X * This program is distributed in the hope that it will be useful,
  1473. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1474. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1475. X * GNU General Public License for more details.
  1476. X *
  1477. X * You should have received a copy of the GNU General Public License
  1478. X * along with this program; if not, write to the Free Software
  1479. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1480. X *
  1481. X * shamim@cs.arizona.edu
  1482. X * Shamim Mohamed
  1483. X * Dept of Computer Science
  1484. X * University of Arizona
  1485. X * Tucson, AZ 85721
  1486. X *
  1487. X * --------------------------------------------------------------------------
  1488. X *
  1489. X * Inputs: an array of points, the number of points, two fudge-factors,
  1490. X * and two procedures that are called for moveto and curveto. I use d = 3.0
  1491. X * and e = 0.2. d controls the slope of the curve depending on the neighbours
  1492. X * (it's not prob. worth futzing with it) and e controls the shape of the ends
  1493. X * of the curve. Experimenting with e may be fruitful.
  1494. X * This is NOT an approximation algorithm. Given n points, it ALWAYS generates
  1495. X * n-1 splines that pass through all the given points. For some sort of
  1496. X * optimum approximation, see the paper in "Graphics Gems", Klossner ed. (It's
  1497. X * the last source-code in the Appendix.)
  1498. X *
  1499. X * The callback procedures can be something like:
  1500. X * void moveto(x, y)
  1501. X * double x, y;
  1502. X * {
  1503. X *    printf("%g %g moveto\n", x, y);
  1504. X * }
  1505. X * void curveto(x1, y1, x2, y2, x3, y3)
  1506. X * double x, y;
  1507. X * {
  1508. X *    printf("%g %g %g %g %g curveto\n", x1, y1, x2, y2, x3, y3);
  1509. X * }
  1510. X *
  1511. X */
  1512. X
  1513. X
  1514. X#include <stdio.h>
  1515. X#include <math.h>
  1516. X
  1517. X#define MAXPOINTS 100
  1518. X#define sqr(a) ((a)*(a))
  1519. X
  1520. typedef struct {
  1521. X   double x, y;
  1522. X} point;
  1523. X
  1524. point cp[MAXPOINTS], cpp[MAXPOINTS];
  1525. double l[MAXPOINTS];
  1526. X
  1527. void interpolate(p, npoints, d, e, moveto, curveto)
  1528. point *p;
  1529. int npoints;
  1530. double d, e;
  1531. void (*moveto)(), (*curveto)();
  1532. X{
  1533. X   int i;
  1534. X   point slope_prev, slope_next;
  1535. X
  1536. X   l[1] = sqrt(sqr(p[0].x-p[1].x)+sqr(p[0].y-p[1].y));
  1537. X   slope_prev.x = p[1].x - p[0].x;
  1538. X   slope_prev.y = p[1].y - p[0].y;
  1539. X   for(i = 1; i < npoints-1; i++) {
  1540. X      point slope;
  1541. X      double m;
  1542. X      
  1543. X      l[i+1] = sqrt(sqr(p[i].x-p[i+1].x)+sqr(p[i].y-p[i+1].y));
  1544. X
  1545. X      slope_next.x = p[i+1].x - p[i].x;
  1546. X      slope_next.y = p[i+1].y - p[i].y;
  1547. X      
  1548. X      /*
  1549. X       * Slope of the curve at this point is the weighted ave. of
  1550. X       * straight-line slopes to neighbours (weighted by length of chord)
  1551. X       */
  1552. X
  1553. X      slope.x = slope_prev.x * l[i+1] + slope_next.x * l[i];
  1554. X      slope.y = slope_prev.y * l[i+1] + slope_next.y * l[i];
  1555. X      
  1556. X      slope_prev = slope_next;
  1557. X
  1558. X      /*
  1559. X       * Alternative method:
  1560. X       * Parameters:
  1561. X       *  a 0     Higher number makes curve tighter. -1<a<1.
  1562. X       *  b .1    Higher number makes sharp curves tighter
  1563. X       *          and broad curves less tight. -1<b<1
  1564. X       *       
  1565. X       * Given points A B and C, bezier control points for B are aligned along
  1566. X       * a line that is perpendicular to the line the bisects the angle ABC.
  1567. X       * The distance of the control points from B is determined by the
  1568. X       * following formula that was found by trial and error is has no
  1569. X       * particular theory behind it:
  1570. X       * Distance of control point from B towards A =
  1571. X       *    (1/2)*(distance between A and B)*
  1572. X       *       (cos(ABC)^(a*b + a + b))(b + 2(1-b)(1-a)/(3-a))
  1573. X       * (Timothy van Zandt <tvz@princeton.edu>)
  1574. X       * My opinion: one has to take an inverse cosine and raise it to a
  1575. X       * fractional power, and the results are very close to my simpler
  1576. X       * algorithm, so I don't think it's worth it.
  1577. X       */
  1578. X      
  1579. X      /* Now we have slope: m is for the normalisation. */
  1580. X      m = sqrt(sqr(slope.x)+sqr(slope.y));
  1581. X      cp[i].x = p[i].x - l[i]*slope.x/(d*m);
  1582. X      cp[i].y = p[i].y - l[i]*slope.y/(d*m);
  1583. X      cpp[i].x = p[i].x + l[i+1]*slope.x/(d*m);
  1584. X      cpp[i].y = p[i].y + l[i+1]*slope.y/(d*m);
  1585. X   }
  1586. X   cpp[0].x = (e*cp[1].x + p[0].x)/(1+e);
  1587. X   cpp[0].y = (e*cp[1].y + p[0].y)/(1+e);
  1588. X   cp[npoints-1].x = (e*cpp[npoints-2].x + p[npoints-1].x)/(1+e);
  1589. X   cp[npoints-1].y = (e*cpp[npoints-2].y + p[npoints-1].y)/(1+e);
  1590. X
  1591. X   (*moveto)(p[0].x, p[0].y);
  1592. X   for(i = 1; i < npoints; i++)
  1593. X      (*curveto)(cpp[i-1].x, cpp[i-1].y, cp[i].x, cp[i].y, p[i].x, p[i].y);
  1594. X}
  1595. X
  1596. END_OF_FILE
  1597. if test 4617 -ne `wc -c <'plotfoil/spline.c'`; then
  1598.     echo shar: \"'plotfoil/spline.c'\" unpacked with wrong size!
  1599. fi
  1600. # end of 'plotfoil/spline.c'
  1601. fi
  1602. echo shar: End of archive 1 \(of 3\).
  1603. cp /dev/null ark1isdone
  1604. MISSING=""
  1605. for I in 1 2 3 ; do
  1606.     if test ! -f ark${I}isdone ; then
  1607.     MISSING="${MISSING} ${I}"
  1608.     fi
  1609. done
  1610. if test "${MISSING}" = "" ; then
  1611.     echo You have unpacked all 3 archives.
  1612.     rm -f ark[1-9]isdone
  1613. else
  1614.     echo You still need to unpack the following archives:
  1615.     echo "        " ${MISSING}
  1616. fi
  1617. ##  End of shell archive.
  1618. exit 0
  1619.  
  1620. exit 0 # Just in case...
  1621.