home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume40 / gnuplot / part07 < prev    next >
Encoding:
Text File  |  1993-10-21  |  79.7 KB  |  3,274 lines

  1. Newsgroups: comp.sources.misc
  2. From: woo@playfair.stanford.edu ("Alexander Woo")
  3. Subject: v40i019:  gnuplot - interactive function plotting utility, Part07/33
  4. Message-ID: <1993Oct21.144414.1785@sparky.sterling.com>
  5. X-Md4-Signature: 77b14b6bec5b53b7431a8cf0cc78d06b
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Thu, 21 Oct 1993 14:44:14 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: woo@playfair.stanford.edu ("Alexander Woo")
  12. Posting-number: Volume 40, Issue 19
  13. Archive-name: gnuplot/part07
  14. Environment: UNIX, MS-DOS, VMS
  15. Supersedes: gnuplot3: Volume 24, Issue 23-48
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  gnuplot/demo/klein.dat gnuplot/graphics.c
  22. # Wrapped by kent@sparky on Wed Oct 20 17:14:40 1993
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 7 (of 33)."'
  26. if test -f 'gnuplot/demo/klein.dat' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'gnuplot/demo/klein.dat'\"
  28. else
  29.   echo shar: Extracting \"'gnuplot/demo/klein.dat'\" \(20117 characters\)
  30.   sed "s/^X//" >'gnuplot/demo/klein.dat' <<'END_OF_FILE'
  31. X1 0 0
  32. X0.924 -0.383 0
  33. X0.707 -0.707 0
  34. X0.383 -0.924 0
  35. X0 -1 0
  36. X-0.383 -0.924 0
  37. X-0.707 -0.707 0
  38. X-0.924 -0.383 0
  39. X-1 0 0
  40. X-0.924 0.383 0
  41. X-0.707 0.707 0
  42. X-0.383 0.924 0
  43. X0 1 0
  44. X0.383 0.924 0
  45. X0.707 0.707 0
  46. X0.924 0.383 0
  47. X1 0 0
  48. X
  49. X1.076 0 0.673
  50. X0.994 -0.412 0.673
  51. X0.761 -0.761 0.673
  52. X0.412 -0.994 0.673
  53. X0 -1.076 0.673
  54. X-0.412 -0.994 0.673
  55. X-0.761 -0.761 0.673
  56. X-0.994 -0.412 0.673
  57. X-1.076 0 0.673
  58. X-0.994 0.412 0.673
  59. X-0.761 0.761 0.673
  60. X-0.412 0.994 0.673
  61. X0 1.076 0.673
  62. X0.412 0.994 0.673
  63. X0.761 0.761 0.673
  64. X0.994 0.412 0.673
  65. X1.076 0 0.673
  66. X
  67. X1.304 0 1.315
  68. X1.205 -0.499 1.315
  69. X0.922 -0.922 1.315
  70. X0.499 -1.205 1.315
  71. X0 -1.304 1.315
  72. X-0.499 -1.205 1.315
  73. X-0.922 -0.922 1.315
  74. X-1.205 -0.499 1.315
  75. X-1.304 0 1.315
  76. X-1.205 0.499 1.315
  77. X-0.922 0.922 1.315
  78. X-0.499 1.205 1.315
  79. X0 1.304 1.315
  80. X0.499 1.205 1.315
  81. X0.922 0.922 1.315
  82. X1.205 0.499 1.315
  83. X1.304 0 1.315
  84. X
  85. X1.757 0 2.206
  86. X1.623 -0.672 2.206
  87. X1.242 -1.242 2.206
  88. X0.672 -1.623 2.206
  89. X0 -1.757 2.206
  90. X-0.672 -1.623 2.206
  91. X-1.242 -1.242 2.206
  92. X-1.623 -0.672 2.206
  93. X-1.757 0 2.206
  94. X-1.623 0.672 2.206
  95. X-1.242 1.242 2.206
  96. X-0.672 1.623 2.206
  97. X0 1.757 2.206
  98. X0.672 1.623 2.206
  99. X1.242 1.242 2.206
  100. X1.623 0.672 2.206
  101. X1.757 0 2.206
  102. X
  103. X2.21 0 3.097
  104. X2.042 -0.846 3.097
  105. X1.563 -1.563 3.097
  106. X0.846 -2.042 3.097
  107. X0 -2.21 3.097
  108. X-0.846 -2.042 3.097
  109. X-1.563 -1.563 3.097
  110. X-2.042 -0.846 3.097
  111. X-2.21 0 3.097
  112. X-2.042 0.846 3.097
  113. X-1.563 1.563 3.097
  114. X-0.846 2.042 3.097
  115. X0 2.21 3.097
  116. X0.846 2.042 3.097
  117. X1.563 1.563 3.097
  118. X2.042 0.846 3.097
  119. X2.21 0 3.097
  120. X
  121. X2.663 0 3.988
  122. X2.46 -1.019 3.988
  123. X1.883 -1.883 3.988
  124. X1.019 -2.46 3.988
  125. X0 -2.663 3.988
  126. X-1.019 -2.46 3.988
  127. X-1.883 -1.883 3.988
  128. X-2.46 -1.019 3.988
  129. X-2.663 0 3.988
  130. X-2.46 1.019 3.988
  131. X-1.883 1.883 3.988
  132. X-1.019 2.46 3.988
  133. X0 2.663 3.988
  134. X1.019 2.46 3.988
  135. X1.883 1.883 3.988
  136. X2.46 1.019 3.988
  137. X2.663 0 3.988
  138. X
  139. X3.116 0 4.879
  140. X2.879 -1.192 4.879
  141. X2.203 -2.203 4.879
  142. X1.192 -2.879 4.879
  143. X0 -3.116 4.879
  144. X-1.192 -2.879 4.879
  145. X-2.203 -2.203 4.879
  146. X-2.879 -1.192 4.879
  147. X-3.116 0 4.879
  148. X-2.879 1.192 4.879
  149. X-2.203 2.203 4.879
  150. X-1.192 2.879 4.879
  151. X0 3.116 4.879
  152. X1.192 2.879 4.879
  153. X2.203 2.203 4.879
  154. X2.879 1.192 4.879
  155. X3.116 0 4.879
  156. X
  157. X3.569 0 5.77
  158. X3.297 -1.366 5.77
  159. X2.524 -2.524 5.77
  160. X1.366 -3.297 5.77
  161. X0 -3.569 5.77
  162. X-1.366 -3.297 5.77
  163. X-2.524 -2.524 5.77
  164. X-3.297 -1.366 5.77
  165. X-3.569 0 5.77
  166. X-3.297 1.366 5.77
  167. X-2.524 2.524 5.77
  168. X-1.366 3.297 5.77
  169. X0 3.569 5.77
  170. X1.366 3.297 5.77
  171. X2.524 2.524 5.77
  172. X3.297 1.366 5.77
  173. X3.569 0 5.77
  174. X
  175. X4.022 0 6.661
  176. X3.716 -1.539 6.661
  177. X2.844 -2.844 6.661
  178. X1.539 -3.716 6.661
  179. X0 -4.022 6.661
  180. X-1.539 -3.716 6.661
  181. X-2.844 -2.844 6.661
  182. X-3.716 -1.539 6.661
  183. X-4.022 0 6.661
  184. X-3.716 1.539 6.661
  185. X-2.844 2.844 6.661
  186. X-1.539 3.716 6.661
  187. X0 4.022 6.661
  188. X1.539 3.716 6.661
  189. X2.844 2.844 6.661
  190. X3.716 1.539 6.661
  191. X4.022 0 6.661
  192. X
  193. X4.475 0 7.552
  194. X4.134 -1.713 7.552
  195. X3.164 -3.164 7.552
  196. X1.713 -4.134 7.552
  197. X0 -4.475 7.552
  198. X-1.713 -4.134 7.552
  199. X-3.164 -3.164 7.552
  200. X-4.134 -1.713 7.552
  201. X-4.475 0 7.552
  202. X-4.134 1.713 7.552
  203. X-3.164 3.164 7.552
  204. X-1.713 4.134 7.552
  205. X0 4.475 7.552
  206. X1.713 4.134 7.552
  207. X3.164 3.164 7.552
  208. X4.134 1.713 7.552
  209. X4.475 0 7.552
  210. X
  211. X4.928 0 8.443
  212. X4.553 -1.886 8.443
  213. X3.485 -3.485 8.443
  214. X1.886 -4.553 8.443
  215. X0 -4.928 8.443
  216. X-1.886 -4.553 8.443
  217. X-3.485 -3.485 8.443
  218. X-4.553 -1.886 8.443
  219. X-4.928 0 8.443
  220. X-4.553 1.886 8.443
  221. X-3.485 3.485 8.443
  222. X-1.886 4.553 8.443
  223. X0 4.928 8.443
  224. X1.886 4.553 8.443
  225. X3.485 3.485 8.443
  226. X4.553 1.886 8.443
  227. X4.928 0 8.443
  228. X
  229. X5.381 0 9.334
  230. X4.971 -2.059 9.334
  231. X3.805 -3.805 9.334
  232. X2.059 -4.971 9.334
  233. X0 -5.381 9.334
  234. X-2.059 -4.971 9.334
  235. X-3.805 -3.805 9.334
  236. X-4.971 -2.059 9.334
  237. X-5.381 0 9.334
  238. X-4.971 2.059 9.334
  239. X-3.805 3.805 9.334
  240. X-2.059 4.971 9.334
  241. X0 5.381 9.334
  242. X2.059 4.971 9.334
  243. X3.805 3.805 9.334
  244. X4.971 2.059 9.334
  245. X5.381 0 9.334
  246. X
  247. X5.834 0 10.225
  248. X5.39 -2.233 10.225
  249. X4.125 -4.125 10.225
  250. X2.233 -5.39 10.225
  251. X0 -5.834 10.225
  252. X-2.233 -5.39 10.225
  253. X-4.125 -4.125 10.225
  254. X-5.39 -2.233 10.225
  255. X-5.834 0 10.225
  256. X-5.39 2.233 10.225
  257. X-4.125 4.125 10.225
  258. X-2.233 5.39 10.225
  259. X0 5.834 10.225
  260. X2.233 5.39 10.225
  261. X4.125 4.125 10.225
  262. X5.39 2.233 10.225
  263. X5.834 0 10.225
  264. X
  265. X6.287 0 11.116
  266. X5.808 -2.406 11.116
  267. X4.446 -4.446 11.116
  268. X2.406 -5.808 11.116
  269. X0 -6.287 11.116
  270. X-2.406 -5.808 11.116
  271. X-4.446 -4.446 11.116
  272. X-5.808 -2.406 11.116
  273. X-6.287 0 11.116
  274. X-5.808 2.406 11.116
  275. X-4.446 4.446 11.116
  276. X-2.406 5.808 11.116
  277. X0 6.287 11.116
  278. X2.406 5.808 11.116
  279. X4.446 4.446 11.116
  280. X5.808 2.406 11.116
  281. X6.287 0 11.116
  282. X
  283. X6.74 0 12.007
  284. X6.227 -2.579 12.007
  285. X4.766 -4.766 12.007
  286. X2.579 -6.227 12.007
  287. X0 -6.74 12.007
  288. X-2.579 -6.227 12.007
  289. X-4.766 -4.766 12.007
  290. X-6.227 -2.579 12.007
  291. X-6.74 0 12.007
  292. X-6.227 2.579 12.007
  293. X-4.766 4.766 12.007
  294. X-2.579 6.227 12.007
  295. X0 6.74 12.007
  296. X2.579 6.227 12.007
  297. X4.766 4.766 12.007
  298. X6.227 2.579 12.007
  299. X6.74 0 12.007
  300. X
  301. X7.193 0 12.898
  302. X6.645 -2.753 12.898
  303. X5.086 -5.086 12.898
  304. X2.753 -6.645 12.898
  305. X0 -7.193 12.898
  306. X-2.753 -6.645 12.898
  307. X-5.086 -5.086 12.898
  308. X-6.645 -2.753 12.898
  309. X-7.193 0 12.898
  310. X-6.645 2.753 12.898
  311. X-5.086 5.086 12.898
  312. X-2.753 6.645 12.898
  313. X0 7.193 12.898
  314. X2.753 6.645 12.898
  315. X5.086 5.086 12.898
  316. X6.645 2.753 12.898
  317. X7.193 0 12.898
  318. X
  319. X7.648 0 13.97
  320. X7.066 -2.927 13.97
  321. X5.408 -5.408 13.97
  322. X2.927 -7.066 13.97
  323. X0 -7.648 13.97
  324. X-2.927 -7.066 13.97
  325. X-5.408 -5.408 13.97
  326. X-7.066 -2.927 13.97
  327. X-7.648 0 13.97
  328. X-7.066 2.927 13.97
  329. X-5.408 5.408 13.97
  330. X-2.927 7.066 13.97
  331. X0 7.648 13.97
  332. X2.927 7.066 13.97
  333. X5.408 5.408 13.97
  334. X7.066 2.927 13.97
  335. X7.648 0 13.97
  336. X
  337. X7.946 0 14.887
  338. X7.341 -3.041 14.887
  339. X5.619 -5.619 14.887
  340. X3.041 -7.341 14.887
  341. X0 -7.946 14.887
  342. X-3.041 -7.341 14.887
  343. X-5.619 -5.619 14.887
  344. X-7.341 -3.041 14.887
  345. X-7.946 0 14.887
  346. X-7.341 3.041 14.887
  347. X-5.619 5.619 14.887
  348. X-3.041 7.341 14.887
  349. X0 7.946 14.887
  350. X3.041 7.341 14.887
  351. X5.619 5.619 14.887
  352. X7.341 3.041 14.887
  353. X7.946 0 14.887
  354. X
  355. X7.982 0 15.851
  356. X7.375 -3.055 15.851
  357. X5.644 -5.644 15.851
  358. X3.055 -7.375 15.851
  359. X0 -7.982 15.851
  360. X-3.055 -7.375 15.851
  361. X-5.644 -5.644 15.851
  362. X-7.375 -3.055 15.851
  363. X-7.982 0 15.851
  364. X-7.375 3.055 15.851
  365. X-5.644 5.644 15.851
  366. X-3.055 7.375 15.851
  367. X0 7.982 15.851
  368. X3.055 7.375 15.851
  369. X5.644 5.644 15.851
  370. X7.375 3.055 15.851
  371. X7.982 0 15.851
  372. X
  373. X7.754 0 16.788
  374. X7.164 -2.967 16.788
  375. X5.483 -5.483 16.788
  376. X2.967 -7.164 16.788
  377. X0 -7.754 16.788
  378. X-2.967 -7.164 16.788
  379. X-5.483 -5.483 16.788
  380. X-7.164 -2.967 16.788
  381. X-7.754 0 16.788
  382. X-7.164 2.967 16.788
  383. X-5.483 5.483 16.788
  384. X-2.967 7.164 16.788
  385. X0 7.754 16.788
  386. X2.967 7.164 16.788
  387. X5.483 5.483 16.788
  388. X7.164 2.967 16.788
  389. X7.754 0 16.788
  390. X
  391. X7.279 0 17.628
  392. X6.725 -2.786 17.628
  393. X5.147 -5.147 17.628
  394. X2.786 -6.725 17.628
  395. X0 -7.279 17.628
  396. X-2.786 -6.725 17.628
  397. X-5.147 -5.147 17.628
  398. X-6.725 -2.786 17.628
  399. X-7.279 0 17.628
  400. X-6.725 2.786 17.628
  401. X-5.147 5.147 17.628
  402. X-2.786 6.725 17.628
  403. X0 7.279 17.628
  404. X2.786 6.725 17.628
  405. X5.147 5.147 17.628
  406. X6.725 2.786 17.628
  407. X7.279 0 17.628
  408. X
  409. X6.593 0 18.305
  410. X6.091 -2.523 18.305
  411. X4.662 -4.662 18.305
  412. X2.523 -6.091 18.305
  413. X0 -6.593 18.305
  414. X-2.523 -6.091 18.305
  415. X-4.662 -4.662 18.305
  416. X-6.091 -2.523 18.305
  417. X-6.593 0 18.305
  418. X-6.091 2.523 18.305
  419. X-4.662 4.662 18.305
  420. X-2.523 6.091 18.305
  421. X0 6.593 18.305
  422. X2.523 6.091 18.305
  423. X4.662 4.662 18.305
  424. X6.091 2.523 18.305
  425. X6.593 0 18.305
  426. X
  427. X5.747 0 18.77
  428. X5.31 -2.199 18.77
  429. X4.064 -4.064 18.77
  430. X2.199 -5.31 18.77
  431. X0 -5.747 18.77
  432. X-2.199 -5.31 18.77
  433. X-4.064 -4.064 18.77
  434. X-5.31 -2.199 18.77
  435. X-5.747 0 18.77
  436. X-5.31 2.199 18.77
  437. X-4.064 4.064 18.77
  438. X-2.199 5.31 18.77
  439. X0 5.747 18.77
  440. X2.199 5.31 18.77
  441. X4.064 4.064 18.77
  442. X5.31 2.199 18.77
  443. X5.747 0 18.77
  444. X
  445. X4.807 0 18.986
  446. X4.442 -1.84 18.986
  447. X3.399 -3.399 18.986
  448. X1.84 -4.442 18.986
  449. X0 -4.807 18.986
  450. X-1.84 -4.442 18.986
  451. X-3.399 -3.399 18.986
  452. X-4.442 -1.84 18.986
  453. X-4.807 0 18.986
  454. X-4.442 1.84 18.986
  455. X-3.399 3.399 18.986
  456. X-1.84 4.442 18.986
  457. X0 4.807 18.986
  458. X1.84 4.442 18.986
  459. X3.399 3.399 18.986
  460. X4.442 1.84 18.986
  461. X4.807 0 18.986
  462. X
  463. X3.844 0 18.938
  464. X3.552 -1.471 18.938
  465. X2.718 -2.718 18.938
  466. X1.471 -3.552 18.938
  467. X0 -3.844 18.938
  468. X-1.471 -3.552 18.938
  469. X-2.718 -2.718 18.938
  470. X-3.552 -1.471 18.938
  471. X-3.844 0 18.938
  472. X-3.552 1.471 18.938
  473. X-2.718 2.718 18.938
  474. X-1.471 3.552 18.938
  475. X0 3.844 18.938
  476. X1.471 3.552 18.938
  477. X2.718 2.718 18.938
  478. X3.552 1.471 18.938
  479. X3.844 0 18.938
  480. X
  481. X2.931 0 18.628
  482. X2.708 -1.122 18.628
  483. X2.072 -2.072 18.628
  484. X1.122 -2.708 18.628
  485. X0 -2.931 18.628
  486. X-1.122 -2.708 18.628
  487. X-2.072 -2.072 18.628
  488. X-2.708 -1.122 18.628
  489. X-2.931 0 18.628
  490. X-2.708 1.122 18.628
  491. X-2.072 2.072 18.628
  492. X-1.122 2.708 18.628
  493. X0 2.931 18.628
  494. X1.122 2.708 18.628
  495. X2.072 2.072 18.628
  496. X2.708 1.122 18.628
  497. X2.931 0 18.628
  498. X
  499. X2.136 0 18.081
  500. X1.974 -0.818 18.081
  501. X1.511 -1.511 18.081
  502. X0.818 -1.974 18.081
  503. X0 -2.136 18.081
  504. X-0.818 -1.974 18.081
  505. X-1.511 -1.511 18.081
  506. X-1.974 -0.818 18.081
  507. X-2.136 0 18.081
  508. X-1.974 0.818 18.081
  509. X-1.511 1.511 18.081
  510. X-0.818 1.974 18.081
  511. X0 2.136 18.081
  512. X0.818 1.974 18.081
  513. X1.511 1.511 18.081
  514. X1.974 0.818 18.081
  515. X2.136 0 18.081
  516. X
  517. X1.522 0 17.338
  518. X1.406 -0.582 17.338
  519. X1.076 -1.076 17.338
  520. X0.582 -1.406 17.338
  521. X0 -1.522 17.338
  522. X-0.582 -1.406 17.338
  523. X-1.076 -1.076 17.338
  524. X-1.406 -0.582 17.338
  525. X-1.522 0 17.338
  526. X-1.406 0.582 17.338
  527. X-1.076 1.076 17.338
  528. X-0.582 1.406 17.338
  529. X0 1.522 17.338
  530. X0.582 1.406 17.338
  531. X1.076 1.076 17.338
  532. X1.406 0.582 17.338
  533. X1.522 0 17.338
  534. X
  535. X1.133 0 16.455
  536. X1.047 -0.434 16.455
  537. X0.801 -0.801 16.455
  538. X0.434 -1.047 16.455
  539. X0 -1.133 16.455
  540. X-0.434 -1.047 16.455
  541. X-0.801 -0.801 16.455
  542. X-1.047 -0.434 16.455
  543. X-1.133 0 16.455
  544. X-1.047 0.434 16.455
  545. X-0.801 0.801 16.455
  546. X-0.434 1.047 16.455
  547. X0 1.133 16.455
  548. X0.434 1.047 16.455
  549. X0.801 0.801 16.455
  550. X1.047 0.434 16.455
  551. X1.133 0 16.455
  552. X
  553. X1 0 15.5
  554. X0.924 -0.383 15.5
  555. X0.707 -0.707 15.5
  556. X0.383 -0.924 15.5
  557. X0 -1 15.5
  558. X-0.383 -0.924 15.5
  559. X-0.707 -0.707 15.5
  560. X-0.924 -0.383 15.5
  561. X-1 0 15.5
  562. X-0.924 0.383 15.5
  563. X-0.707 0.707 15.5
  564. X-0.383 0.924 15.5
  565. X0 1 15.5
  566. X0.383 0.924 15.5
  567. X0.707 0.707 15.5
  568. X0.924 0.383 15.5
  569. X1 0 15.5
  570. X
  571. X0.911 0 14.515
  572. X0.836 -0.383 14.528
  573. X0.623 -0.707 14.567
  574. X0.304 -0.924 14.625
  575. X-0.073 -1 14.694
  576. X-0.449 -0.924 14.762
  577. X-0.768 -0.707 14.821
  578. X-0.982 -0.383 14.859
  579. X-1.057 0 14.873
  580. X-0.982 0.383 14.859
  581. X-0.768 0.707 14.821
  582. X-0.449 0.924 14.762
  583. X-0.073 1 14.694
  584. X0.304 0.924 14.625
  585. X0.623 0.707 14.567
  586. X0.836 0.383 14.528
  587. X0.911 0 14.515
  588. X
  589. X0.647 0 13.561
  590. X0.576 -0.383 13.588
  591. X0.373 -0.707 13.665
  592. X0.069 -0.924 13.779
  593. X-0.289 -1 13.914
  594. X-0.647 -0.924 14.049
  595. X-0.951 -0.707 14.163
  596. X-1.153 -0.383 14.239
  597. X-1.225 0 14.266
  598. X-1.153 0.383 14.239
  599. X-0.951 0.707 14.163
  600. X-0.647 0.924 14.049
  601. X-0.289 1 13.914
  602. X0.069 0.924 13.779
  603. X0.373 0.707 13.665
  604. X0.576 0.383 13.588
  605. X0.647 0 13.561
  606. X
  607. X0.205 0 12.653
  608. X0.14 -0.383 12.693
  609. X-0.043 -0.707 12.808
  610. X-0.318 -0.924 12.98
  611. X-0.643 -1 13.182
  612. X-0.968 -0.924 13.384
  613. X-1.243 -0.707 13.556
  614. X-1.426 -0.383 13.671
  615. X-1.491 0 13.711
  616. X-1.426 0.383 13.671
  617. X-1.243 0.707 13.556
  618. X-0.968 0.924 13.384
  619. X-0.643 1 13.182
  620. X-0.318 0.924 12.98
  621. X-0.043 0.707 12.808
  622. X0.14 0.383 12.693
  623. X0.205 0 12.653
  624. X
  625. X-0.324 0 11.805
  626. X-0.389 -0.383 11.845
  627. X-0.572 -0.707 11.96
  628. X-0.847 -0.924 12.132
  629. X-1.172 -1 12.334
  630. X-1.497 -0.924 12.536
  631. X-1.772 -0.707 12.708
  632. X-1.955 -0.383 12.823
  633. X-2.02 0 12.863
  634. X-1.955 0.383 12.823
  635. X-1.772 0.707 12.708
  636. X-1.497 0.924 12.536
  637. X-1.172 1 12.334
  638. X-0.847 0.924 12.132
  639. X-0.572 0.707 11.96
  640. X-0.389 0.383 11.845
  641. X-0.324 0 11.805
  642. X
  643. X-0.853 0 10.957
  644. X-0.918 -0.383 10.997
  645. X-1.101 -0.707 11.112
  646. X-1.376 -0.924 11.284
  647. X-1.701 -1 11.486
  648. X-2.026 -0.924 11.688
  649. X-2.301 -0.707 11.86
  650. X-2.484 -0.383 11.975
  651. X-2.549 0 12.015
  652. X-2.484 0.383 11.975
  653. X-2.301 0.707 11.86
  654. X-2.026 0.924 11.688
  655. X-1.701 1 11.486
  656. X-1.376 0.924 11.284
  657. X-1.101 0.707 11.112
  658. X-0.918 0.383 10.997
  659. X-0.853 0 10.957
  660. X
  661. X-1.382 0 10.109
  662. X-1.447 -0.383 10.149
  663. X-1.63 -0.707 10.264
  664. X-1.905 -0.924 10.436
  665. X-2.23 -1 10.638
  666. X-2.555 -0.924 10.84
  667. X-2.83 -0.707 11.012
  668. X-3.013 -0.383 11.127
  669. X-3.078 0 11.167
  670. X-3.013 0.383 11.127
  671. X-2.83 0.707 11.012
  672. X-2.555 0.924 10.84
  673. X-2.23 1 10.638
  674. X-1.905 0.924 10.436
  675. X-1.63 0.707 10.264
  676. X-1.447 0.383 10.149
  677. X-1.382 0 10.109
  678. X
  679. X-1.911 0 9.261
  680. X-1.976 -0.383 9.301
  681. X-2.159 -0.707 9.416
  682. X-2.434 -0.924 9.588
  683. X-2.759 -1 9.79
  684. X-3.084 -0.924 9.992
  685. X-3.359 -0.707 10.164
  686. X-3.542 -0.383 10.279
  687. X-3.607 0 10.319
  688. X-3.542 0.383 10.279
  689. X-3.359 0.707 10.164
  690. X-3.084 0.924 9.992
  691. X-2.759 1 9.79
  692. X-2.434 0.924 9.588
  693. X-2.159 0.707 9.416
  694. X-1.976 0.383 9.301
  695. X-1.911 0 9.261
  696. X
  697. X-2.44 0 8.413
  698. X-2.505 -0.383 8.453
  699. X-2.688 -0.707 8.568
  700. X-2.963 -0.924 8.74
  701. X-3.288 -1 8.942
  702. X-3.613 -0.924 9.144
  703. X-3.888 -0.707 9.316
  704. X-4.071 -0.383 9.431
  705. X-4.136 0 9.471
  706. X-4.071 0.383 9.431
  707. X-3.888 0.707 9.316
  708. X-3.613 0.924 9.144
  709. X-3.288 1 8.942
  710. X-2.963 0.924 8.74
  711. X-2.688 0.707 8.568
  712. X-2.505 0.383 8.453
  713. X-2.44 0 8.413
  714. X
  715. X-2.969 0 7.565
  716. X-3.034 -0.383 7.605
  717. X-3.217 -0.707 7.72
  718. X-3.492 -0.924 7.892
  719. X-3.817 -1 8.094
  720. X-4.142 -0.924 8.296
  721. X-4.417 -0.707 8.468
  722. X-4.6 -0.383 8.583
  723. X-4.665 0 8.623
  724. X-4.6 0.383 8.583
  725. X-4.417 0.707 8.468
  726. X-4.142 0.924 8.296
  727. X-3.817 1 8.094
  728. X-3.492 0.924 7.892
  729. X-3.217 0.707 7.72
  730. X-3.034 0.383 7.605
  731. X-2.969 0 7.565
  732. X
  733. X-3.498 0 6.717
  734. X-3.563 -0.383 6.757
  735. X-3.746 -0.707 6.872
  736. X-4.021 -0.924 7.044
  737. X-4.346 -1 7.246
  738. X-4.671 -0.924 7.448
  739. X-4.946 -0.707 7.62
  740. X-5.129 -0.383 7.735
  741. X-5.194 0 7.775
  742. X-5.129 0.383 7.735
  743. X-4.946 0.707 7.62
  744. X-4.671 0.924 7.448
  745. X-4.346 1 7.246
  746. X-4.021 0.924 7.044
  747. X-3.746 0.707 6.872
  748. X-3.563 0.383 6.757
  749. X-3.498 0 6.717
  750. X
  751. X-4.027 0 5.869
  752. X-4.092 -0.383 5.909
  753. X-4.275 -0.707 6.024
  754. X-4.55 -0.924 6.196
  755. X-4.875 -1 6.398
  756. X-5.2 -0.924 6.6
  757. X-5.475 -0.707 6.772
  758. X-5.658 -0.383 6.887
  759. X-5.723 0 6.927
  760. X-5.658 0.383 6.887
  761. X-5.475 0.707 6.772
  762. X-5.2 0.924 6.6
  763. X-4.875 1 6.398
  764. X-4.55 0.924 6.196
  765. X-4.275 0.707 6.024
  766. X-4.092 0.383 5.909
  767. X-4.027 0 5.869
  768. X
  769. X-4.556 0 5.021
  770. X-4.621 -0.383 5.061
  771. X-4.804 -0.707 5.176
  772. X-5.079 -0.924 5.348
  773. X-5.404 -1 5.55
  774. X-5.729 -0.924 5.752
  775. X-6.004 -0.707 5.924
  776. X-6.187 -0.383 6.039
  777. X-6.252 0 6.079
  778. X-6.187 0.383 6.039
  779. X-6.004 0.707 5.924
  780. X-5.729 0.924 5.752
  781. X-5.404 1 5.55
  782. X-5.079 0.924 5.348
  783. X-4.804 0.707 5.176
  784. X-4.621 0.383 5.061
  785. X-4.556 0 5.021
  786. X
  787. X-5.085 0 4.173
  788. X-5.15 -0.383 4.213
  789. X-5.333 -0.707 4.328
  790. X-5.608 -0.924 4.5
  791. X-5.933 -1 4.702
  792. X-6.258 -0.924 4.904
  793. X-6.533 -0.707 5.076
  794. X-6.716 -0.383 5.191
  795. X-6.781 0 5.231
  796. X-6.716 0.383 5.191
  797. X-6.533 0.707 5.076
  798. X-6.258 0.924 4.904
  799. X-5.933 1 4.702
  800. X-5.608 0.924 4.5
  801. X-5.333 0.707 4.328
  802. X-5.15 0.383 4.213
  803. X-5.085 0 4.173
  804. X
  805. X-5.614 0 3.325
  806. X-5.679 -0.383 3.365
  807. X-5.862 -0.707 3.48
  808. X-6.137 -0.924 3.652
  809. X-6.462 -1 3.854
  810. X-6.787 -0.924 4.056
  811. X-7.062 -0.707 4.228
  812. X-7.245 -0.383 4.343
  813. X-7.31 0 4.383
  814. X-7.245 0.383 4.343
  815. X-7.062 0.707 4.228
  816. X-6.787 0.924 4.056
  817. X-6.462 1 3.854
  818. X-6.137 0.924 3.652
  819. X-5.862 0.707 3.48
  820. X-5.679 0.383 3.365
  821. X-5.614 0 3.325
  822. X
  823. X-6.143 0 2.477
  824. X-6.208 -0.383 2.517
  825. X-6.391 -0.707 2.632
  826. X-6.666 -0.924 2.804
  827. X-6.991 -1 3.006
  828. X-7.316 -0.924 3.208
  829. X-7.591 -0.707 3.38
  830. X-7.774 -0.383 3.495
  831. X-7.839 0 3.535
  832. X-7.774 0.383 3.495
  833. X-7.591 0.707 3.38
  834. X-7.316 0.924 3.208
  835. X-6.991 1 3.006
  836. X-6.666 0.924 2.804
  837. X-6.391 0.707 2.632
  838. X-6.208 0.383 2.517
  839. X-6.143 0 2.477
  840. X
  841. X-6.573 0 1.543
  842. X-6.638 -0.383 1.582
  843. X-6.824 -0.707 1.694
  844. X-7.102 -0.924 1.861
  845. X-7.43 -1 2.058
  846. X-7.758 -0.924 2.255
  847. X-8.036 -0.707 2.422
  848. X-8.222 -0.383 2.533
  849. X-8.288 0 2.572
  850. X-8.222 0.383 2.533
  851. X-8.036 0.707 2.422
  852. X-7.758 0.924 2.255
  853. X-7.43 1 2.058
  854. X-7.102 0.924 1.861
  855. X-6.824 0.707 1.694
  856. X-6.638 0.383 1.582
  857. X-6.573 0 1.543
  858. X
  859. X-6.822 0 1.019
  860. X-6.893 -0.383 1.045
  861. X-7.097 -0.707 1.119
  862. X-7.402 -0.924 1.229
  863. X-7.762 -1 1.359
  864. X-8.122 -0.924 1.489
  865. X-8.427 -0.707 1.599
  866. X-8.631 -0.383 1.672
  867. X-8.703 0 1.698
  868. X-8.631 0.383 1.672
  869. X-8.427 0.707 1.599
  870. X-8.122 0.924 1.489
  871. X-7.762 1 1.359
  872. X-7.402 0.924 1.229
  873. X-7.097 0.707 1.119
  874. X-6.893 0.383 1.045
  875. X-6.822 0 1.019
  876. X
  877. X-6.965 0 0.457
  878. X-7.04 -0.383 0.468
  879. X-7.255 -0.707 0.501
  880. X-7.575 -0.924 0.551
  881. X-7.953 -1 0.609
  882. X-8.332 -0.924 0.667
  883. X-8.652 -0.707 0.716
  884. X-8.867 -0.383 0.749
  885. X-8.942 0 0.761
  886. X-8.867 0.383 0.749
  887. X-8.652 0.707 0.716
  888. X-8.332 0.924 0.667
  889. X-7.953 1 0.609
  890. X-7.575 0.924 0.551
  891. X-7.255 0.707 0.501
  892. X-7.04 0.383 0.468
  893. X-6.965 0 0.457
  894. X
  895. X-6.997 0 -0.123
  896. X-7.074 -0.383 -0.126
  897. X-7.29 -0.707 -0.135
  898. X-7.614 -0.924 -0.148
  899. X-7.997 -1 -0.164
  900. X-8.379 -0.924 -0.18
  901. X-8.703 -0.707 -0.193
  902. X-8.92 -0.383 -0.202
  903. X-8.996 0 -0.205
  904. X-8.92 0.383 -0.202
  905. X-8.703 0.707 -0.193
  906. X-8.379 0.924 -0.18
  907. X-7.997 1 -0.164
  908. X-7.614 0.924 -0.148
  909. X-7.29 0.707 -0.135
  910. X-7.074 0.383 -0.126
  911. X-6.997 0 -0.123
  912. X
  913. X-6.918 0 -0.698
  914. X-6.992 -0.383 -0.716
  915. X-7.203 -0.707 -0.766
  916. X-7.518 -0.924 -0.842
  917. X-7.89 -1 -0.931
  918. X-8.262 -0.924 -1.02
  919. X-8.578 -0.707 -1.095
  920. X-8.789 -0.383 -1.145
  921. X-8.863 0 -1.163
  922. X-8.789 0.383 -1.145
  923. X-8.578 0.707 -1.095
  924. X-8.262 0.924 -1.02
  925. X-7.89 1 -0.931
  926. X-7.518 0.924 -0.842
  927. X-7.203 0.707 -0.766
  928. X-6.992 0.383 -0.716
  929. X-6.918 0 -0.698
  930. X
  931. X-6.729 0 -1.247
  932. X-6.798 -0.383 -1.278
  933. X-6.995 -0.707 -1.368
  934. X-7.29 -0.924 -1.503
  935. X-7.638 -1 -1.662
  936. X-7.986 -0.924 -1.821
  937. X-8.281 -0.707 -1.956
  938. X-8.479 -0.383 -2.046
  939. X-8.548 0 -2.078
  940. X-8.479 0.383 -2.046
  941. X-8.281 0.707 -1.956
  942. X-7.986 0.924 -1.821
  943. X-7.638 1 -1.662
  944. X-7.29 0.924 -1.503
  945. X-6.995 0.707 -1.368
  946. X-6.798 0.383 -1.278
  947. X-6.729 0 -1.247
  948. X
  949. X-6.438 0 -1.749
  950. X-6.499 -0.383 -1.793
  951. X-6.675 -0.707 -1.92
  952. X-6.939 -0.924 -2.109
  953. X-7.25 -1 -2.332
  954. X-7.561 -0.924 -2.555
  955. X-7.825 -0.707 -2.744
  956. X-8.001 -0.383 -2.87
  957. X-8.063 0 -2.915
  958. X-8.001 0.383 -2.87
  959. X-7.825 0.707 -2.744
  960. X-7.561 0.924 -2.555
  961. X-7.25 1 -2.332
  962. X-6.939 0.924 -2.109
  963. X-6.675 0.707 -1.92
  964. X-6.499 0.383 -1.793
  965. X-6.438 0 -1.749
  966. X
  967. X-6.055 0 -2.186
  968. X-6.107 -0.383 -2.241
  969. X-6.256 -0.707 -2.399
  970. X-6.478 -0.924 -2.635
  971. X-6.74 -1 -2.914
  972. X-7.002 -0.924 -3.193
  973. X-7.225 -0.707 -3.429
  974. X-7.373 -0.383 -3.587
  975. X-7.425 0 -3.643
  976. X-7.373 0.383 -3.587
  977. X-7.225 0.707 -3.429
  978. X-7.002 0.924 -3.193
  979. X-6.74 1 -2.914
  980. X-6.478 0.924 -2.635
  981. X-6.256 0.707 -2.399
  982. X-6.107 0.383 -2.241
  983. X-6.055 0 -2.186
  984. X
  985. X-5.596 0 -2.54
  986. X-5.636 -0.383 -2.605
  987. X-5.752 -0.707 -2.788
  988. X-5.924 -0.924 -3.063
  989. X-6.128 -1 -3.387
  990. X-6.331 -0.924 -3.711
  991. X-6.504 -0.707 -3.986
  992. X-6.619 -0.383 -4.17
  993. X-6.66 0 -4.234
  994. X-6.619 0.383 -4.17
  995. X-6.504 0.707 -3.986
  996. X-6.331 0.924 -3.711
  997. X-6.128 1 -3.387
  998. X-5.924 0.924 -3.063
  999. X-5.752 0.707 -2.788
  1000. X-5.636 0.383 -2.605
  1001. X-5.596 0 -2.54
  1002. X
  1003. X-5.077 0 -2.8
  1004. X-5.104 -0.383 -2.871
  1005. X-5.182 -0.707 -3.074
  1006. X-5.298 -0.924 -3.376
  1007. X-5.436 -1 -3.734
  1008. X-5.573 -0.924 -4.091
  1009. X-5.689 -0.707 -4.394
  1010. X-5.767 -0.383 -4.596
  1011. X-5.794 0 -4.667
  1012. X-5.767 0.383 -4.596
  1013. X-5.689 0.707 -4.394
  1014. X-5.573 0.924 -4.091
  1015. X-5.436 1 -3.734
  1016. X-5.298 0.924 -3.376
  1017. X-5.182 0.707 -3.074
  1018. X-5.104 0.383 -2.871
  1019. X-5.077 0 -2.8
  1020. X
  1021. X-4.517 0 -2.955
  1022. X-4.53 -0.383 -3.03
  1023. X-4.568 -0.707 -3.244
  1024. X-4.624 -0.924 -3.563
  1025. X-4.69 -1 -3.94
  1026. X-4.756 -0.924 -4.317
  1027. X-4.812 -0.707 -4.637
  1028. X-4.849 -0.383 -4.85
  1029. X-4.862 0 -4.925
  1030. X-4.849 0.383 -4.85
  1031. X-4.812 0.707 -4.637
  1032. X-4.756 0.924 -4.317
  1033. X-4.69 1 -3.94
  1034. X-4.624 0.924 -3.563
  1035. X-4.568 0.707 -3.244
  1036. X-4.53 0.383 -3.03
  1037. X-4.517 0 -2.955
  1038. X
  1039. X-3.938 0 -2.999
  1040. X-3.937 -0.383 -3.075
  1041. X-3.932 -0.707 -3.292
  1042. X-3.926 -0.924 -3.617
  1043. X-3.918 -1 -3.999
  1044. X-3.91 -0.924 -4.382
  1045. X-3.903 -0.707 -4.706
  1046. X-3.899 -0.383 -4.923
  1047. X-3.897 0 -4.999
  1048. X-3.899 0.383 -4.923
  1049. X-3.903 0.707 -4.706
  1050. X-3.91 0.924 -4.382
  1051. X-3.918 1 -3.999
  1052. X-3.926 0.924 -3.617
  1053. X-3.932 0.707 -3.292
  1054. X-3.937 0.383 -3.075
  1055. X-3.938 0 -2.999
  1056. X
  1057. X-3.362 0 -2.931
  1058. X-3.346 -0.383 -3.006
  1059. X-3.3 -0.707 -3.218
  1060. X-3.231 -0.924 -3.535
  1061. X-3.149 -1 -3.909
  1062. X-3.068 -0.924 -4.282
  1063. X-2.999 -0.707 -4.599
  1064. X-2.953 -0.383 -4.811
  1065. X-2.937 0 -4.886
  1066. X-2.953 0.383 -4.811
  1067. X-2.999 0.707 -4.599
  1068. X-3.068 0.924 -4.282
  1069. X-3.149 1 -3.909
  1070. X-3.231 0.924 -3.535
  1071. X-3.3 0.707 -3.218
  1072. X-3.346 0.383 -3.006
  1073. X-3.362 0 -2.931
  1074. X
  1075. X-2.809 0 -2.754
  1076. X-2.779 -0.383 -2.824
  1077. X-2.693 -0.707 -3.023
  1078. X-2.564 -0.924 -3.32
  1079. X-2.413 -1 -3.672
  1080. X-2.261 -0.924 -4.023
  1081. X-2.132 -0.707 -4.321
  1082. X-2.046 -0.383 -4.52
  1083. X-2.016 0 -4.589
  1084. X-2.046 0.383 -4.52
  1085. X-2.132 0.707 -4.321
  1086. X-2.261 0.924 -4.023
  1087. X-2.413 1 -3.672
  1088. X-2.564 0.924 -3.32
  1089. X-2.693 0.707 -3.023
  1090. X-2.779 0.383 -2.824
  1091. X-2.809 0 -2.754
  1092. X
  1093. X-2.301 0 -2.473
  1094. X-2.258 -0.383 -2.536
  1095. X-2.136 -0.707 -2.714
  1096. X-1.952 -0.924 -2.982
  1097. X-1.735 -1 -3.297
  1098. X-1.519 -0.924 -3.613
  1099. X-1.335 -0.707 -3.88
  1100. X-1.212 -0.383 -4.059
  1101. X-1.169 0 -4.121
  1102. X-1.212 0.383 -4.059
  1103. X-1.335 0.707 -3.88
  1104. X-1.519 0.924 -3.613
  1105. X-1.735 1 -3.297
  1106. X-1.952 0.924 -2.982
  1107. X-2.136 0.707 -2.714
  1108. X-2.258 0.383 -2.536
  1109. X-2.301 0 -2.473
  1110. X
  1111. X-1.857 0 -2.099
  1112. X-1.803 -0.383 -2.153
  1113. X-1.648 -0.707 -2.304
  1114. X-1.416 -0.924 -2.531
  1115. X-1.143 -1 -2.799
  1116. X-0.869 -0.924 -3.067
  1117. X-0.638 -0.707 -3.294
  1118. X-0.483 -0.383 -3.446
  1119. X-0.428 0 -3.499
  1120. X-0.483 0.383 -3.446
  1121. X-0.638 0.707 -3.294
  1122. X-0.869 0.924 -3.067
  1123. X-1.143 1 -2.799
  1124. X-1.416 0.924 -2.531
  1125. X-1.648 0.707 -2.304
  1126. X-1.803 0.383 -2.153
  1127. X-1.857 0 -2.099
  1128. X
  1129. X-1.493 0 -1.647
  1130. X-1.429 -0.383 -1.689
  1131. X-1.248 -0.707 -1.808
  1132. X-0.977 -0.924 -1.986
  1133. X-0.657 -1 -2.197
  1134. X-0.337 -0.924 -2.407
  1135. X-0.066 -0.707 -2.585
  1136. X0.115 -0.383 -2.704
  1137. X0.179 0 -2.746
  1138. X0.115 0.383 -2.704
  1139. X-0.066 0.707 -2.585
  1140. X-0.337 0.924 -2.407
  1141. X-0.657 1 -2.197
  1142. X-0.977 0.924 -1.986
  1143. X-1.248 0.707 -1.808
  1144. X-1.429 0.383 -1.689
  1145. X-1.493 0 -1.647
  1146. X
  1147. X-1.223 0 -1.134
  1148. X-1.152 -0.383 -1.163
  1149. X-0.951 -0.707 -1.245
  1150. X-0.651 -0.924 -1.367
  1151. X-0.297 -1 -1.512
  1152. X0.058 -0.924 -1.656
  1153. X0.358 -0.707 -1.779
  1154. X0.559 -0.383 -1.861
  1155. X0.629 0 -1.89
  1156. X0.559 0.383 -1.861
  1157. X0.358 0.707 -1.779
  1158. X0.058 0.924 -1.656
  1159. X-0.297 1 -1.512
  1160. X-0.651 0.924 -1.367
  1161. X-0.951 0.707 -1.245
  1162. X-1.152 0.383 -1.163
  1163. X-1.223 0 -1.134
  1164. X
  1165. X-1.056 0 -0.578
  1166. X-0.981 -0.383 -0.592
  1167. X-0.769 -0.707 -0.634
  1168. X-0.45 -0.924 -0.697
  1169. X-0.075 -1 -0.77
  1170. X0.301 -0.924 -0.844
  1171. X0.619 -0.707 -0.906
  1172. X0.832 -0.383 -0.948
  1173. X0.906 0 -0.963
  1174. X0.832 0.383 -0.948
  1175. X0.619 0.707 -0.906
  1176. X0.301 0.924 -0.844
  1177. X-0.075 1 -0.77
  1178. X-0.45 0.924 -0.697
  1179. X-0.769 0.707 -0.634
  1180. X-0.981 0.383 -0.592
  1181. X-1.056 0 -0.578
  1182. X
  1183. X-1 0 0
  1184. X-0.924 -0.383 0
  1185. X-0.707 -0.707 0
  1186. X-0.383 -0.924 0
  1187. X0 -1 0
  1188. X0.383 -0.924 0
  1189. X0.707 -0.707 0
  1190. X0.924 -0.383 0
  1191. X1 0 0
  1192. X0.924 0.383 0
  1193. X0.707 0.707 0
  1194. X0.383 0.924 0
  1195. X0 1 0
  1196. X-0.383 0.924 0
  1197. X-0.707 0.707 0
  1198. X-0.924 0.383 0
  1199. X-1 0 0
  1200. X
  1201. END_OF_FILE
  1202.   if test 20117 -ne `wc -c <'gnuplot/demo/klein.dat'`; then
  1203.     echo shar: \"'gnuplot/demo/klein.dat'\" unpacked with wrong size!
  1204.   fi
  1205.   # end of 'gnuplot/demo/klein.dat'
  1206. fi
  1207. if test -f 'gnuplot/graphics.c' -a "${1}" != "-c" ; then 
  1208.   echo shar: Will not clobber existing file \"'gnuplot/graphics.c'\"
  1209. else
  1210.   echo shar: Extracting \"'gnuplot/graphics.c'\" \(55795 characters\)
  1211.   sed "s/^X//" >'gnuplot/graphics.c' <<'END_OF_FILE'
  1212. X#ifndef lint
  1213. Xstatic char *RCSid = "$Id: graphics.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $";
  1214. X#endif
  1215. X
  1216. X
  1217. X/* GNUPLOT - graphics.c */
  1218. X/*
  1219. X * Copyright (C) 1986 - 1993   Thomas Williams, Colin Kelley
  1220. X *
  1221. X * Permission to use, copy, and distribute this software and its
  1222. X * documentation for any purpose with or without fee is hereby granted, 
  1223. X * provided that the above copyright notice appear in all copies and 
  1224. X * that both that copyright notice and this permission notice appear 
  1225. X * in supporting documentation.
  1226. X *
  1227. X * Permission to modify the software is granted, but not the right to
  1228. X * distribute the modified code.  Modifications are to be distributed 
  1229. X * as patches to released version.
  1230. X *  
  1231. X * This software is provided "as is" without express or implied warranty.
  1232. X * 
  1233. X *
  1234. X * AUTHORS
  1235. X * 
  1236. X *   Original Software:
  1237. X *     Thomas Williams,  Colin Kelley.
  1238. X * 
  1239. X *   Gnuplot 2.0 additions:
  1240. X *       Russell Lang, Dave Kotz, John Campbell.
  1241. X *
  1242. X *   Gnuplot 3.0 additions:
  1243. X *       Gershon Elber and many others.
  1244. X *
  1245. X * There is a mailing list for gnuplot users. Note, however, that the
  1246. X * newsgroup 
  1247. X *    comp.graphics.gnuplot 
  1248. X * is identical to the mailing list (they
  1249. X * both carry the same set of messages). We prefer that you read the
  1250. X * messages through that newsgroup, to subscribing to the mailing list.
  1251. X * (If you can read that newsgroup, and are already on the mailing list,
  1252. X * please send a message info-gnuplot-request@dartmouth.edu, asking to be
  1253. X * removed from the mailing list.)
  1254. X *
  1255. X * The address for mailing to list members is
  1256. X *       info-gnuplot@dartmouth.edu
  1257. X * and for mailing administrative requests is 
  1258. X *       info-gnuplot-request@dartmouth.edu
  1259. X * The mailing list for bug reports is 
  1260. X *       bug-gnuplot@dartmouth.edu
  1261. X * The list of those interested in beta-test versions is
  1262. X *       info-gnuplot-beta@dartmouth.edu
  1263. X */
  1264. X
  1265. X#include <stdio.h>
  1266. X#include <math.h>
  1267. X#include <assert.h>
  1268. X#if !defined(u3b2)
  1269. X#include <time.h>
  1270. X#endif
  1271. X#include "plot.h"
  1272. X#include "setshow.h"
  1273. X
  1274. X#if defined(DJGPP)||defined(sun386)
  1275. X#define time_t unsigned long
  1276. X#endif
  1277. X
  1278. X#ifndef AMIGA_SC_6_1
  1279. Xextern char *strcpy(),*strncpy(),*strcat(),*ctime();
  1280. X#endif /* !AMIGA_SC_6_1 */
  1281. Xchar *tdate;
  1282. X#ifdef AMIGA_AC_5
  1283. Xtime_t dated;
  1284. X#else
  1285. X#if defined(apollo) || defined(sequent) || defined(u3b2) || defined(alliant) || defined(sun386)
  1286. X#include <sys/types.h> /* typedef long time_t; */
  1287. X#endif
  1288. Xtime_t dated; /* ,time(); */
  1289. X#include <time.h>
  1290. X#endif
  1291. X
  1292. Xvoid plot_impulses();
  1293. Xvoid plot_lines();
  1294. Xvoid plot_points();
  1295. Xvoid plot_dots();
  1296. Xvoid plot_bars();
  1297. Xvoid plot_boxes();
  1298. Xvoid edge_intersect();
  1299. XTBOOLEAN two_edge_intersect();
  1300. X
  1301. Xvoid plot_steps();            /* JG */
  1302. Xvoid edge_intersect_steps();         /* JG */
  1303. XTBOOLEAN two_edge_intersect_steps();    /* JG */
  1304. X
  1305. X/* for plotting error bars */
  1306. X#define ERRORBARTIC (t->h_tic/2) /* half the width of error bar tic mark */
  1307. X
  1308. X#ifndef max        /* Lattice C has max() in math.h, but shouldn't! */
  1309. X#define max(a,b) ((a > b) ? a : b)
  1310. X#endif
  1311. X
  1312. X#ifndef min
  1313. X#define min(a,b) ((a < b) ? a : b)
  1314. X#endif
  1315. X
  1316. X#define inrange(z,min,max) ((min<max) ? ((z>=min)&&(z<=max)) : ((z>=max)&&(z<=min)) )
  1317. X
  1318. X/* True if a and b have the same sign or zero (positive or negative) */
  1319. X#define samesign(a,b) ((a) * (b) >= 0)
  1320. X
  1321. X/* Define the boundary of the plot
  1322. X * These are computed at each call to do_plot, and are constant over
  1323. X * the period of one do_plot. They actually only change when the term
  1324. X * type changes and when the 'set size' factors change. 
  1325. X */
  1326. Xstatic int xleft, xright, ybot, ytop;
  1327. X
  1328. X/* Boundary and scale factors, in user coordinates */
  1329. X/* x_min, x_max, y_min, y_max are local to this file and
  1330. X * are not the same as variables of the same names in other files
  1331. X */
  1332. Xstatic double x_min, x_max, y_min, y_max;
  1333. Xstatic double xscale, yscale;
  1334. X
  1335. X/* And the functions to map from user to terminal coordinates */
  1336. X#define map_x(x) (int)(xleft+(x-x_min)*xscale+0.5) /* maps floating point x to screen */ 
  1337. X#define map_y(y) (int)(ybot+(y-y_min)*yscale+0.5)    /* same for y */
  1338. X
  1339. X/* (DFK) Watch for cancellation error near zero on axes labels */
  1340. X#define SIGNIF (0.01)        /* less than one hundredth of a tic mark */
  1341. X#define CheckZero(x,tic) (fabs(x) < ((tic) * SIGNIF) ? 0.0 : (x))
  1342. X#define NearlyEqual(x,y,tic) (fabs((x)-(y)) < ((tic) * SIGNIF))
  1343. X
  1344. X/* (DFK) For some reason, the Sun386i compiler screws up with the CheckLog 
  1345. X * macro, so I write it as a function on that machine.
  1346. X */
  1347. X#ifndef sun386
  1348. X/* (DFK) Use 10^x if logscale is in effect, else x */
  1349. X#define CheckLog(is_log, base_log, x) ((is_log) ? pow(base_log, (x)) : (x))
  1350. X#else
  1351. Xstatic double
  1352. XCheckLog(is_log, base_log, x)
  1353. X     TBOOLEAN is_log;
  1354. X     double base_log;
  1355. X     double x;
  1356. X{
  1357. X  if (is_log)
  1358. X    return(pow(base_log, x));
  1359. X  else
  1360. X    return(x);
  1361. X}
  1362. X#endif /* sun386 */
  1363. X
  1364. Xdouble
  1365. XLogScale(coord, is_log, log_base_log, what, axis)
  1366. X    double coord;            /* the value */
  1367. X    TBOOLEAN is_log;            /* is this axis in logscale? */
  1368. X        double log_base_log;        /* if so, the log of its base */
  1369. X    char *what;            /* what is the coord for? */
  1370. X    char *axis;            /* which axis is this for ("x" or "y")? */
  1371. X{
  1372. X    if (is_log) {
  1373. X       if (coord <= 0.0) {
  1374. X          char errbuf[100];        /* place to write error message */
  1375. X        (void) sprintf(errbuf,"%s has %s coord of %g; must be above 0 for log scale!",
  1376. X                what, axis, coord);
  1377. X          (*term_tbl[term].text)();
  1378. X          (void) fflush(outfile);
  1379. X          int_error(errbuf, NO_CARET);
  1380. X       } else
  1381. X        return(log(coord)/log_base_log);
  1382. X    }
  1383. X    return(coord);
  1384. X}
  1385. X
  1386. X/* borders of plotting area */
  1387. X/* computed once on every call to do_plot */
  1388. Xboundary(scaling)
  1389. X    TBOOLEAN scaling;        /* TRUE if terminal is doing the scaling */
  1390. X{
  1391. X    register struct termentry *t = &term_tbl[term];
  1392. X    /* luecken@udel.edu modifications 
  1393. X       sizes the plot according to the presence of labels, title,... */
  1394. X    if (strlen(ylabel) == 0)
  1395. X        xleft = (t->h_char)*8;
  1396. X    else
  1397. X        xleft = (t->h_char)*10;
  1398. X    xright = (scaling ? 1 : xsize) * (t->xmax) - (t->h_char)*2 - (t->h_tic);
  1399. X    if ((strlen(xlabel) != 0) || timedate)
  1400. X        if ((*t->text_angle)(1))
  1401. X            ybot = (t->v_char)*5/2 + 1;
  1402. X        else
  1403. X            ybot = (t->v_char)*7/2 + 1;    /* allow space for time at bottom */
  1404. X    else
  1405. X        ybot = (t->v_char)*3/2 + 1;
  1406. X    if ( (strlen(title) != 0) || timedate ||
  1407. X      ((strlen(ylabel) != 0) && ((*t->text_angle)(1) == FALSE)) )
  1408. X        ytop = (scaling ? 1 : ysize) * (t->ymax) - (t->v_char)*3/2 - 1;
  1409. X    else
  1410. X        ytop = (scaling ? 1 : ysize) * (t->ymax) - (t->v_char)/2 - 1;
  1411. X    (void)(*t->text_angle)(0);
  1412. X}
  1413. X
  1414. X
  1415. Xdouble dbl_raise(x,y)
  1416. Xdouble x;
  1417. Xint y;
  1418. X{
  1419. Xregister int i;
  1420. Xdouble val;
  1421. X
  1422. X    val = 1.0;
  1423. X    for (i=0; i < abs(y); i++)
  1424. X        val *= x;
  1425. X    if (y < 0 ) return (1.0/val);
  1426. X    return(val);
  1427. X}
  1428. X
  1429. X
  1430. Xdouble make_tics(tmin,tmax,logscale,base_log)
  1431. Xdouble tmin,tmax;
  1432. XTBOOLEAN logscale;
  1433. Xdouble base_log;
  1434. X{
  1435. Xregister double xr,xnorm,tics,tic,l10;
  1436. X
  1437. X    xr = fabs(tmin-tmax);
  1438. X    
  1439. X    l10 = log10(xr);
  1440. X    if (logscale) {
  1441. X        tic = dbl_raise(base_log,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
  1442. X        if (tic < 1.0)
  1443. X            tic = 1.0;
  1444. X    } else {
  1445. X        xnorm = pow(10.0,l10-(double)((l10 >= 0.0 ) ? (int)l10 : ((int)l10-1)));
  1446. X        if (xnorm <= 2)
  1447. X            tics = 0.2;
  1448. X        else if (xnorm <= 5)
  1449. X            tics = 0.5;
  1450. X        else tics = 1.0;    
  1451. X        tic = tics * dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
  1452. X    }
  1453. X    return(tic);
  1454. X}
  1455. X
  1456. X
  1457. Xdo_plot(plots, pcount, min_x, max_x, min_y, max_y)
  1458. Xstruct curve_points *plots;
  1459. Xint pcount;            /* count of plots in linked list */
  1460. Xdouble min_x, max_x;
  1461. Xdouble min_y, max_y;
  1462. X{
  1463. Xregister struct termentry *t = &term_tbl[term];
  1464. Xregister int curve, xaxis_y, yaxis_x;
  1465. Xregister struct curve_points *this_plot;
  1466. Xregister double ytic, xtic;
  1467. Xregister int xl, yl;
  1468. X            /* only a Pyramid would have this many registers! */
  1469. Xdouble xtemp, ytemp;
  1470. Xstruct text_label *this_label;
  1471. Xstruct arrow_def *this_arrow;
  1472. XTBOOLEAN scaling;
  1473. X
  1474. X
  1475. X/* store these in variables global to this file */
  1476. X/* otherwise, we have to pass them around a lot */
  1477. X     x_min = min_x;
  1478. X     x_max = max_x; 
  1479. X     y_min = min_y;
  1480. X     y_max = max_y;
  1481. X
  1482. X    if (polar) {
  1483. X        /* will possibly change x_min, x_max, y_min, y_max */
  1484. X        polar_xform(plots,pcount);
  1485. X    }
  1486. X
  1487. X    if (y_min == VERYLARGE || y_max == -VERYLARGE ||
  1488. X        x_min == VERYLARGE || x_max == -VERYLARGE)
  1489. X        int_error("all points undefined!", NO_CARET);
  1490. X
  1491. X/*    Apply the desired viewport offsets. */
  1492. X     if (y_min < y_max) {
  1493. X        y_min -= boff;
  1494. X        y_max += toff;
  1495. X    } else {
  1496. X        y_max -= boff;
  1497. X        y_min += toff;
  1498. X    }
  1499. X     if (x_min < x_max) {
  1500. X        x_min -= loff;
  1501. X        x_max += roff;
  1502. X    } else {
  1503. X        x_max -= loff;
  1504. X        x_min += roff;
  1505. X    }
  1506. X
  1507. X/* SETUP RANGES, SCALES AND TIC PLACES */
  1508. X    if (ytics && yticdef.type == TIC_COMPUTED) {
  1509. X       ytic = make_tics(y_min,y_max,is_log_y,base_log_y);
  1510. X    
  1511. X       if (autoscale_ly) {
  1512. X          if (y_min < y_max) {
  1513. X             y_min = ytic * floor(y_min/ytic);       
  1514. X             y_max = ytic * ceil(y_max/ytic);
  1515. X          }
  1516. X          else {            /* reverse axis */
  1517. X             y_min = ytic * ceil(y_min/ytic);       
  1518. X             y_max = ytic * floor(y_max/ytic);
  1519. X          }
  1520. X       }
  1521. X    }
  1522. X
  1523. X    if (xtics && xticdef.type == TIC_COMPUTED) {
  1524. X       xtic = make_tics(x_min,x_max,is_log_x,base_log_x);
  1525. X       
  1526. X       if (autoscale_lx) {
  1527. X          if (x_min < x_max) {
  1528. X             x_min = xtic * floor(x_min/xtic);    
  1529. X             x_max = xtic * ceil(x_max/xtic);
  1530. X          } else {
  1531. X             x_min = xtic * ceil(x_min/xtic);
  1532. X             x_max = xtic * floor(x_max/xtic);    
  1533. X          }
  1534. X       }
  1535. X    }
  1536. X
  1537. X/*    This used be x_max == x_min, but that caused an infinite loop once. */
  1538. X    if (fabs(x_max - x_min) < zero)
  1539. X        int_error("x_min should not equal x_max!",NO_CARET);
  1540. X    if (fabs(y_max - y_min) < zero)
  1541. X        int_error("y_min should not equal y_max!",NO_CARET);
  1542. X
  1543. X/* INITIALIZE TERMINAL */
  1544. X    if (!term_init) {
  1545. X        (*t->init)();
  1546. X        term_init = TRUE;
  1547. X    }
  1548. X    screen_ok = FALSE;
  1549. X    scaling = (*t->scale)(xsize, ysize);
  1550. X    (*t->graphics)();
  1551. X
  1552. X     /* now compute boundary for plot (xleft, xright, ytop, ybot) */
  1553. X     boundary(scaling);
  1554. X
  1555. X/* SCALE FACTORS */
  1556. X    yscale = (ytop - ybot)/(y_max - y_min);
  1557. X    xscale = (xright - xleft)/(x_max - x_min);
  1558. X    
  1559. X/* DRAW AXES */
  1560. X    (*t->linetype)(-1);    /* axis line type */
  1561. X    xaxis_y = map_y(0.0);
  1562. X    yaxis_x = map_x(0.0); 
  1563. X
  1564. X    if (xaxis_y < ybot)
  1565. X        xaxis_y = ybot;                /* save for impulse plotting */
  1566. X    else if (xaxis_y >= ytop)
  1567. X        xaxis_y = ytop ;
  1568. X    else if (xzeroaxis && !is_log_y) {
  1569. X        (*t->move)(xleft,xaxis_y);
  1570. X        (*t->vector)(xright,xaxis_y);
  1571. X    } else if (is_log_y){
  1572. X        xaxis_y = ybot;
  1573. X    }
  1574. X
  1575. X    if (yzeroaxis && !is_log_x && yaxis_x >= xleft && yaxis_x < xright ) {
  1576. X        (*t->move)(yaxis_x,ybot);
  1577. X        (*t->vector)(yaxis_x,ytop);
  1578. X    }
  1579. X
  1580. X/* DRAW TICS */
  1581. X    (*t->linetype)(-2); /* border linetype */
  1582. X
  1583. X    /* label y axis tics */
  1584. X     if (ytics) {
  1585. X        switch (yticdef.type) {
  1586. X           case TIC_COMPUTED: {
  1587. X               if (y_min < y_max)
  1588. X                draw_ytics(ytic * floor(y_min/ytic),
  1589. X                        ytic,
  1590. X                        ytic * ceil(y_max/ytic));
  1591. X              else
  1592. X                draw_ytics(ytic * floor(y_max/ytic),
  1593. X                        ytic,
  1594. X                        ytic * ceil(y_min/ytic));
  1595. X
  1596. X              break;
  1597. X           }
  1598. X            case TIC_MONTH:{
  1599. X            draw_month_ytics();
  1600. X            break;
  1601. X            }
  1602. X            case TIC_DAY: {
  1603. X            draw_day_ytics();
  1604. X            break;
  1605. X            }
  1606. X           case TIC_SERIES: {
  1607. X              draw_series_ytics(yticdef.def.series.start, 
  1608. X                            yticdef.def.series.incr, 
  1609. X                            yticdef.def.series.end);
  1610. X              break;
  1611. X           }
  1612. X           case TIC_USER: {
  1613. X              draw_set_ytics(yticdef.def.user);
  1614. X              break;
  1615. X           }
  1616. X           default: {
  1617. X              (*t->text)();
  1618. X                (void) fflush(outfile);
  1619. X              int_error("unknown tic type in yticdef in do_plot", NO_CARET);
  1620. X              break;        /* NOTREACHED */
  1621. X           }
  1622. X        }
  1623. X    }
  1624. X
  1625. X    /* label x axis tics */
  1626. X     if (xtics) {
  1627. X        switch (xticdef.type) {
  1628. X           case TIC_COMPUTED: {
  1629. X               if (x_min < x_max)
  1630. X                draw_xtics(xtic * floor(x_min/xtic),
  1631. X                        xtic,
  1632. X                        xtic * ceil(x_max/xtic));
  1633. X              else
  1634. X                draw_xtics(xtic * floor(x_max/xtic),
  1635. X                        xtic,
  1636. X                        xtic * ceil(x_min/xtic));
  1637. X
  1638. X              break;
  1639. X           }
  1640. X            case TIC_MONTH: {
  1641. X            draw_month_xtics();
  1642. X            break;
  1643. X            }
  1644. X            case TIC_DAY : {
  1645. X            draw_day_xtics();
  1646. X            break;
  1647. X            }
  1648. X           case TIC_SERIES: {
  1649. X              draw_series_xtics(xticdef.def.series.start, 
  1650. X                            xticdef.def.series.incr, 
  1651. X                            xticdef.def.series.end);
  1652. X              break;
  1653. X           }
  1654. X           case TIC_USER: {
  1655. X              draw_set_xtics(xticdef.def.user);
  1656. X              break;
  1657. X           }
  1658. X           default: {
  1659. X              (*t->text)();
  1660. X              (void) fflush(outfile);
  1661. X              int_error("unknown tic type in xticdef in do_plot", NO_CARET);
  1662. X              break;        /* NOTREACHED */
  1663. X           }
  1664. X        }
  1665. X    }
  1666. X
  1667. X/* DRAW PLOT BORDER */
  1668. X    (*t->linetype)(-2); /* border linetype */
  1669. X    if (draw_border) {
  1670. X        (*t->move)(xleft,ybot);
  1671. X        (*t->vector)(xright,ybot);
  1672. X        (*t->vector)(xright,ytop);
  1673. X        (*t->vector)(xleft,ytop);
  1674. X        (*t->vector)(xleft,ybot);
  1675. X    }
  1676. X
  1677. X/* PLACE YLABEL */
  1678. X    if (strlen(ylabel) > 0) {
  1679. X        int x, y;
  1680. X
  1681. X        x = ylabel_xoffset * t->h_char;
  1682. X        y = ylabel_yoffset * t->v_char;
  1683. X        if ((*t->text_angle)(1)) {
  1684. X            if ((*t->justify_text)(CENTRE)) {
  1685. X                (*t->put_text)(x+(t->v_char),
  1686. X                         y+(ytop+ybot)/2, ylabel);
  1687. X            }
  1688. X            else {
  1689. X                (*t->put_text)(x+(t->v_char),
  1690. X                           y+(ytop+ybot)/2-(t->h_char)*strlen(ylabel)/2, 
  1691. X                         ylabel);
  1692. X            }
  1693. X        }
  1694. X        else {
  1695. X            (void)(*t->justify_text)(LEFT);
  1696. X            (*t->put_text)(x,y+ytop+(t->v_char), ylabel);
  1697. X        }
  1698. X        (void)(*t->text_angle)(0);
  1699. X    }
  1700. X
  1701. X/* PLACE XLABEL */
  1702. X    if (strlen(xlabel) > 0) {
  1703. X        int x, y;
  1704. X
  1705. X        x = xlabel_xoffset * t->h_char;
  1706. X        y = xlabel_yoffset * t->v_char;
  1707. X
  1708. X            if ((*t->justify_text)(CENTRE)) 
  1709. X            (*t->put_text)(x+(xleft+xright)/2,
  1710. X                       y+ybot-2*(t->v_char), xlabel);
  1711. X            else
  1712. X            (*t->put_text)(x+(xleft+xright)/2 - strlen(xlabel)*(t->h_char)/2,
  1713. X                           y+ybot-2*(t->v_char), xlabel);
  1714. X    }
  1715. X
  1716. X/* PLACE TITLE */
  1717. X    if (strlen(title) > 0) {
  1718. X        int x, y;
  1719. X
  1720. X        x = title_xoffset * t->h_char;
  1721. X        y = title_yoffset * t->v_char;
  1722. X
  1723. X            if ((*t->justify_text)(CENTRE))
  1724. X            (*t->put_text)(x+(xleft+xright)/2,
  1725. X                       y+ytop+(t->v_char), title);
  1726. X            else
  1727. X            (*t->put_text)(x+(xleft+xright)/2 - strlen(title)*(t->h_char)/2,
  1728. X                       y+ytop+(t->v_char), title);
  1729. X    }
  1730. X
  1731. X
  1732. X/* PLACE TIMEDATE */
  1733. X    if (timedate) {
  1734. X        int x, y;
  1735. X
  1736. X        x = time_xoffset * t->h_char;
  1737. X        y = time_yoffset * t->v_char;
  1738. X        dated = time( (time_t *) 0);
  1739. X        tdate = ctime( &dated);
  1740. X        tdate[24]='\0';
  1741. X        (void)(*t->justify_text)(LEFT);
  1742. X        if ((*t->text_angle)(1)) {
  1743. X            (void)(*t->text_angle)(0);
  1744. X            (*t->put_text)(x, y+ytop+(t->v_char), tdate);
  1745. X        }
  1746. X        else {
  1747. X            (void)(*t->text_angle)(0);
  1748. X            (*t->put_text)(x,
  1749. X                         y+ybot-3*(t->v_char), tdate);
  1750. X        }
  1751. X    }
  1752. X
  1753. X/* PLACE LABELS */
  1754. X    for (this_label = first_label; this_label!=NULL;
  1755. X            this_label=this_label->next ) {
  1756. X         xtemp = LogScale(this_label->x, is_log_x, log_base_log_x, "label", "x");
  1757. X         ytemp = LogScale(this_label->y, is_log_y, log_base_log_y, "label", "y");
  1758. X        if ((*t->justify_text)(this_label->pos)) {
  1759. X            (*t->put_text)(map_x(xtemp),map_y(ytemp),this_label->text);
  1760. X        }
  1761. X        else {
  1762. X            switch(this_label->pos) {
  1763. X                case  LEFT:
  1764. X                    (*t->put_text)(map_x(xtemp),map_y(ytemp),
  1765. X                        this_label->text);
  1766. X                    break;
  1767. X                case CENTRE:
  1768. X                    (*t->put_text)(map_x(xtemp)-
  1769. X                        (t->h_char)*strlen(this_label->text)/2,
  1770. X                        map_y(ytemp), this_label->text);
  1771. X                    break;
  1772. X                case RIGHT:
  1773. X                    (*t->put_text)(map_x(xtemp)-
  1774. X                        (t->h_char)*strlen(this_label->text),
  1775. X                        map_y(ytemp), this_label->text);
  1776. X                    break;
  1777. X            }
  1778. X         }
  1779. X     }
  1780. X
  1781. X/* PLACE ARROWS */
  1782. X    (*t->linetype)(0);    /* arrow line type */
  1783. X    for (this_arrow = first_arrow; this_arrow!=NULL;
  1784. X        this_arrow = this_arrow->next ) {
  1785. X       int sx = map_x(LogScale(this_arrow->sx, is_log_x, log_base_log_x, "arrow", "x"));
  1786. X       int sy = map_y(LogScale(this_arrow->sy, is_log_y, log_base_log_y, "arrow", "y"));
  1787. X       int ex = map_x(LogScale(this_arrow->ex, is_log_x, log_base_log_x, "arrow", "x"));
  1788. X       int ey = map_y(LogScale(this_arrow->ey, is_log_y, log_base_log_y, "arrow", "y"));
  1789. X       
  1790. X       (*t->arrow)(sx, sy, ex, ey, this_arrow->head);
  1791. X    }
  1792. X
  1793. X
  1794. X/* DRAW CURVES */
  1795. X    if (key == -1) {
  1796. X        xl = xright  - (t->h_tic) - (t->h_char)*5;
  1797. X        yl = ytop - (t->v_tic) - (t->v_char);
  1798. X    }
  1799. X    if (key == 1) {
  1800. X        xl = map_x( LogScale(key_x, is_log_x, log_base_log_x, "key", "x") );
  1801. X        yl = map_y( LogScale(key_y, is_log_y, log_base_log_y, "key", "y") );
  1802. X    }
  1803. X
  1804. X    this_plot = plots;
  1805. X    for (curve = 0; curve < pcount; this_plot = this_plot->next_cp, curve++) {
  1806. X        int oldkey = key;
  1807. X
  1808. X        (*t->linetype)(this_plot->line_type);
  1809. X
  1810. X        if (this_plot->title && !*this_plot->title) {
  1811. X            key = 0;
  1812. X        } else {
  1813. X        if (key != 0 && this_plot->title) {
  1814. X            if ((*t->justify_text)(RIGHT)) {
  1815. X                (*t->put_text)(xl,
  1816. X                    yl,this_plot->title);
  1817. X            }
  1818. X            else {
  1819. X                if (inrange(xl-(t->h_char)*strlen(this_plot->title), 
  1820. X                         xleft, xright))
  1821. X                 (*t->put_text)(xl-(t->h_char)*strlen(this_plot->title),
  1822. X                             yl,this_plot->title);
  1823. X            }
  1824. X        }
  1825. X        }
  1826. X
  1827. X        switch(this_plot->plot_style) {
  1828. X            case IMPULSES: {
  1829. X               if (key != 0 && this_plot->title) {
  1830. X                  (*t->move)(xl+(t->h_char),yl);
  1831. X                  (*t->vector)(xl+4*(t->h_char),yl);
  1832. X               }
  1833. X               plot_impulses(this_plot, yaxis_x, xaxis_y);
  1834. X               break;
  1835. X            }
  1836. X            case LINES: {
  1837. X               if (key != 0 && this_plot->title) {
  1838. X                  (*t->move)(xl+(int)(t->h_char),yl);
  1839. X                  (*t->vector)(xl+(int)(4*(t->h_char)),yl);
  1840. X               }
  1841. X               plot_lines(this_plot);
  1842. X               break;
  1843. X            }
  1844. X/* JG */        case STEPS: {
  1845. X               if (key != 0 && this_plot->title) {
  1846. X                  (*t->move)(xl+(int)(t->h_char),yl);
  1847. X                  (*t->vector)(xl+(int)(4*(t->h_char)),yl);
  1848. X               }
  1849. X               plot_steps(this_plot);
  1850. X               break;
  1851. X            }
  1852. X            case POINTSTYLE: {
  1853. X               if (key != 0 && this_plot->title) {
  1854. X                  (*t->point)(xl+2*(t->h_char),yl,
  1855. X                            this_plot->point_type);
  1856. X               }
  1857. X               plot_points(this_plot);
  1858. X               break;
  1859. X            }
  1860. X            case LINESPOINTS: {
  1861. X               /* put lines */
  1862. X               if (key != 0 && this_plot->title) {
  1863. X                  (*t->move)(xl+(t->h_char),yl);
  1864. X                  (*t->vector)(xl+4*(t->h_char),yl);
  1865. X               }
  1866. X               plot_lines(this_plot);
  1867. X
  1868. X               /* put points */
  1869. X               if (key != 0 && this_plot->title) {
  1870. X                  (*t->point)(xl+2*(t->h_char),yl,
  1871. X                            this_plot->point_type);
  1872. X               }
  1873. X               plot_points(this_plot);
  1874. X               break;
  1875. X            }
  1876. X            case DOTS: {
  1877. X               if (key != 0 && this_plot->title) {
  1878. X                  (*t->point)(xl+2*(t->h_char),yl, -1);
  1879. X               }
  1880. X               plot_dots(this_plot);
  1881. X               break;
  1882. X            }
  1883. X            case ERRORBARS: {
  1884. X               if (key != 0 && this_plot->title) {
  1885. X                  (*t->point)(xl+2*(t->h_char),yl,
  1886. X                            this_plot->point_type);
  1887. X               }
  1888. X               plot_points(this_plot);
  1889. X
  1890. X               /* for functions, just like POINTSTYLE */
  1891. X               if (this_plot->plot_type == DATA) {
  1892. X                  if (key != 0 && this_plot->title) {
  1893. X                     (*t->move)(xl+(t->h_char),yl);
  1894. X                     (*t->vector)(xl+4*(t->h_char),yl);
  1895. X                     (*t->move)(xl+(t->h_char),yl+ERRORBARTIC);
  1896. X                     (*t->vector)(xl+(t->h_char),yl-ERRORBARTIC);
  1897. X                     (*t->move)(xl+4*(t->h_char),yl+ERRORBARTIC);
  1898. X                     (*t->vector)(xl+4*(t->h_char),yl-ERRORBARTIC);
  1899. X                  }
  1900. X                  plot_bars(this_plot);
  1901. X               }
  1902. X               break;
  1903. X            }
  1904. X            case BOXERROR: {
  1905. X               if (this_plot->plot_type == DATA) {
  1906. X                  if (key != 0 && this_plot->title) {
  1907. X                     (*t->move)(xl+(t->h_char),yl+ERRORBARTIC);
  1908. X                     (*t->vector)(xl+(t->h_char),yl-ERRORBARTIC);
  1909. X                     (*t->move)(xl+4*(t->h_char),yl+ERRORBARTIC);
  1910. X                     (*t->vector)(xl+4*(t->h_char),yl-ERRORBARTIC);
  1911. X                  }
  1912. X                  plot_bars(this_plot);
  1913. X               }
  1914. X            }
  1915. X            /* no break */
  1916. X            case BOXES: {
  1917. X               if (key != 0 && this_plot->title) {
  1918. X                  (*t->move)(xl+(t->h_char),yl);
  1919. X                  (*t->vector)(xl+4*(t->h_char),yl);
  1920. X               }
  1921. X               plot_boxes(this_plot,xaxis_y);
  1922. X               break;
  1923. X            }
  1924. X
  1925. X        }
  1926. X        if (key && this_plot->title) {
  1927. X            yl = yl - (t->v_char);
  1928. X        }
  1929. X        key = oldkey;
  1930. X    }
  1931. X    (*t->text)();
  1932. X    (void) fflush(outfile);
  1933. X}
  1934. X
  1935. X/* plot_impulses:
  1936. X * Plot the curves in IMPULSES style
  1937. X */
  1938. Xvoid
  1939. Xplot_impulses(plot, yaxis_x, xaxis_y)
  1940. X    struct curve_points *plot;
  1941. X    int yaxis_x, xaxis_y;
  1942. X{
  1943. X    int i;
  1944. X    int x,y;
  1945. X    struct termentry *t = &term_tbl[term];
  1946. X
  1947. X    for (i = 0; i < plot->p_count; i++) {
  1948. X       switch (plot->points[i].type) {
  1949. X          case INRANGE: {
  1950. X             x = map_x(plot->points[i].x);
  1951. X             y = map_y(plot->points[i].y);
  1952. X             break;
  1953. X          }
  1954. X          case OUTRANGE: {
  1955. X             if (!inrange(plot->points[i].x, x_min,x_max))
  1956. X               continue;
  1957. X             x = map_x(plot->points[i].x);
  1958. X             if ((y_min < y_max 
  1959. X                 && plot->points[i].y < y_min)
  1960. X                || (y_max < y_min 
  1961. X                    && plot->points[i].y > y_min))
  1962. X               y = map_y(y_min);
  1963. X             if ((y_min < y_max 
  1964. X                 && plot->points[i].y > y_max)
  1965. X                || (y_max<y_min 
  1966. X                    && plot->points[i].y < y_max))
  1967. X               y = map_y(y_max);
  1968. X             break;
  1969. X          }
  1970. X          default:        /* just a safety */
  1971. X          case UNDEFINED: {
  1972. X             continue;
  1973. X          }
  1974. X       }
  1975. X                    
  1976. X       if (polar)
  1977. X          (*t->move)(yaxis_x,xaxis_y);
  1978. X       else
  1979. X          (*t->move)(x,xaxis_y);
  1980. X       (*t->vector)(x,y);
  1981. X    }
  1982. X
  1983. X}
  1984. X
  1985. X/* plot_lines:
  1986. X * Plot the curves in LINES style
  1987. X */
  1988. Xvoid
  1989. Xplot_lines(plot)
  1990. X    struct curve_points *plot;
  1991. X{
  1992. X    int i;                /* point index */
  1993. X    int x,y;                /* point in terminal coordinates */
  1994. X    struct termentry *t = &term_tbl[term];
  1995. X    enum coord_type prev = UNDEFINED; /* type of previous point */
  1996. X    double ex, ey;            /* an edge point */
  1997. X    double lx[2], ly[2];        /* two edge points */
  1998. X
  1999. X    for (i = 0; i < plot->p_count; i++) {
  2000. X       switch (plot->points[i].type) {
  2001. X          case INRANGE: {
  2002. X             x = map_x(plot->points[i].x);
  2003. X             y = map_y(plot->points[i].y);
  2004. X
  2005. X             if (prev == INRANGE) {
  2006. X                (*t->vector)(x,y);
  2007. X             } else if (prev == OUTRANGE) {
  2008. X                /* from outrange to inrange */
  2009. X                if (!clip_lines1) {
  2010. X                    (*t->move)(x,y);
  2011. X                } else {
  2012. X                    edge_intersect(plot->points, i, &ex, &ey);
  2013. X                    (*t->move)(map_x(ex), map_y(ey));
  2014. X                    (*t->vector)(x,y);
  2015. X                }
  2016. X             } else {        /* prev == UNDEFINED */
  2017. X                (*t->move)(x,y);
  2018. X                (*t->vector)(x,y);
  2019. X             }
  2020. X                    
  2021. X             break;
  2022. X          }
  2023. X          case OUTRANGE: {
  2024. X             if (prev == INRANGE) {
  2025. X                /* from inrange to outrange */
  2026. X                if (clip_lines1) {
  2027. X                    edge_intersect(plot->points, i, &ex, &ey);
  2028. X                    (*t->vector)(map_x(ex), map_y(ey));
  2029. X                }
  2030. X             } else if (prev == OUTRANGE) {
  2031. X                /* from outrange to outrange */
  2032. X                if (clip_lines2) {
  2033. X                    if (two_edge_intersect(plot->points, i, lx, ly)) {
  2034. X                       (*t->move)(map_x(lx[0]), map_y(ly[0]));
  2035. X                       (*t->vector)(map_x(lx[1]), map_y(ly[1]));
  2036. X                    }
  2037. X                }
  2038. X             }
  2039. X             break;
  2040. X          }
  2041. X          default:        /* just a safety */
  2042. X          case UNDEFINED: {
  2043. X             break;
  2044. X          }
  2045. X       }
  2046. X       prev = plot->points[i].type;
  2047. X    }
  2048. X}
  2049. X
  2050. X/* XXX - JG  */
  2051. X/* plot_steps:                
  2052. X * Plot the curves in STEPS style
  2053. X */
  2054. Xvoid
  2055. Xplot_steps(plot)
  2056. Xstruct curve_points *plot;
  2057. X{
  2058. X    int i;                /* point index */
  2059. X    int x,y;                /* point in terminal coordinates */
  2060. X    struct termentry *t = &term_tbl[term];
  2061. X    enum coord_type prev = UNDEFINED;    /* type of previous point */
  2062. X    double ex, ey;            /* an edge point */
  2063. X    double lx[2], ly[2];        /* two edge points */
  2064. X    int xprev, yprev;            /* previous point coordinates */
  2065. X
  2066. X    for (i = 0; i < plot->p_count; i++) {
  2067. X       switch (plot->points[i].type) {
  2068. X          case INRANGE: {
  2069. X             x = map_x(plot->points[i].x);
  2070. X             y = map_y(plot->points[i].y);
  2071. X
  2072. X             if (prev == INRANGE) {
  2073. X                (*t->vector)(x,yprev);
  2074. X                (*t->vector)(x,y);
  2075. X             } else if (prev == OUTRANGE) {
  2076. X                /* from outrange to inrange */
  2077. X                if (!clip_lines1) {
  2078. X                    (*t->move)(x,y);
  2079. X                } else {        /* find edge intersection */
  2080. X                    edge_intersect_steps(plot->points, i, &ex, &ey);
  2081. X                    (*t->move)(map_x(ex), map_y(ey));
  2082. X                    (*t->vector)(x,map_y(ey));
  2083. X                    (*t->vector)(x,y);
  2084. X                }
  2085. X             } else {        /* prev == UNDEFINED */
  2086. X                (*t->move)(x,y);
  2087. X                (*t->vector)(x,y);
  2088. X             }
  2089. X             break;
  2090. X          }
  2091. X          case OUTRANGE: {
  2092. X             if (prev == INRANGE) {
  2093. X                /* from inrange to outrange */
  2094. X                if (clip_lines1) {
  2095. X                    edge_intersect_steps(plot->points, i, &ex, &ey);
  2096. X                    (*t->vector)(map_x(ex), yprev);
  2097. X                    (*t->vector)(map_x(ex), map_y(ey));
  2098. X                }
  2099. X             } else if (prev == OUTRANGE) {
  2100. X                /* from outrange to outrange */
  2101. X                if (clip_lines2) {
  2102. X                    if (two_edge_intersect_steps(plot->points, i, lx, ly)) {
  2103. X                       (*t->move)(map_x(lx[0]), map_y(ly[0]));
  2104. X                       (*t->vector)(map_x(lx[1]), map_y(ly[0]));
  2105. X                       (*t->vector)(map_x(lx[1]), map_y(ly[1]));
  2106. X                    }
  2107. X                }
  2108. X             }
  2109. X             break;
  2110. X          }
  2111. X          default:        /* just a safety */
  2112. X          case UNDEFINED: {
  2113. X             break;
  2114. X          }
  2115. X       }
  2116. X       prev  = plot->points[i].type;
  2117. X       xprev = x;
  2118. X       yprev = y;
  2119. X    }
  2120. X}
  2121. X
  2122. X/* plot_bars:
  2123. X * Plot the curves in ERRORBARS style
  2124. X *  we just plot the bars; the points are plotted in plot_points
  2125. X */
  2126. Xvoid
  2127. Xplot_bars(plot)
  2128. X    struct curve_points *plot;
  2129. X{
  2130. X    int i;                /* point index */
  2131. X    struct termentry *t = &term_tbl[term];
  2132. X    double x;                /* position of the bar */
  2133. X    double ylow, yhigh;        /* the ends of the bars */
  2134. X    unsigned int xM, ylowM, yhighM; /* the mapped version of above */
  2135. X    TBOOLEAN low_inrange, high_inrange;
  2136. X    int tic = ERRORBARTIC;
  2137. X    
  2138. X    for (i = 0; i < plot->p_count; i++) {
  2139. X       /* undefined points don't count */
  2140. X       if (plot->points[i].type == UNDEFINED)
  2141. X        continue;
  2142. X
  2143. X       /* check to see if in xrange */
  2144. X       x = plot->points[i].x;
  2145. X       if (! inrange(x, x_min, x_max))
  2146. X        continue;
  2147. X       xM = map_x(x);
  2148. X
  2149. X       /* find low and high points of bar, and check yrange */
  2150. X       yhigh = plot->points[i].yhigh;
  2151. X       ylow = plot->points[i].ylow;
  2152. X
  2153. X       high_inrange = inrange(yhigh, y_min,y_max);
  2154. X       low_inrange = inrange(ylow, y_min,y_max);
  2155. X
  2156. X       /* compute the plot position of yhigh */
  2157. X       if (high_inrange)
  2158. X        yhighM = map_y(yhigh);
  2159. X       else if (samesign(yhigh-y_max, y_max-y_min))
  2160. X        yhighM = map_y(y_max);
  2161. X       else
  2162. X        yhighM = map_y(y_min);
  2163. X       
  2164. X       /* compute the plot position of ylow */
  2165. X       if (low_inrange)
  2166. X        ylowM = map_y(ylow);
  2167. X       else if (samesign(ylow-y_max, y_max-y_min))
  2168. X        ylowM = map_y(y_max);
  2169. X       else
  2170. X        ylowM = map_y(y_min);
  2171. X
  2172. X       if (!high_inrange && !low_inrange && ylowM == yhighM)
  2173. X        /* both out of range on the same side */
  2174. X          continue;
  2175. X
  2176. X       /* by here everything has been mapped */
  2177. X       (*t->move)(xM, ylowM);
  2178. X       (*t->vector)(xM, yhighM); /* draw the main bar */
  2179. X       (*t->move)(xM-tic, ylowM); /* draw the bottom tic */
  2180. X       (*t->vector)(xM+tic, ylowM);
  2181. X       (*t->move)(xM-tic, yhighM); /* draw the top tic */
  2182. X       (*t->vector)(xM+tic, yhighM);
  2183. X    }
  2184. X}
  2185. X
  2186. X/* plot_boxes:
  2187. X * Plot the curves in BOXES style
  2188. X */
  2189. Xvoid
  2190. Xplot_boxes(plot,xaxis_y)
  2191. X    struct curve_points *plot;
  2192. X    int xaxis_y;
  2193. X{
  2194. X    int i;                /* point index */
  2195. X    int xl,xr,yt;            /* point in terminal coordinates */
  2196. X    double dxl,dxr,dyt;
  2197. X    struct termentry *t = &term_tbl[term];
  2198. X    enum coord_type prev = UNDEFINED; /* type of previous point */
  2199. X
  2200. X    for (i = 0; i < plot->p_count; i++) {
  2201. X       switch (plot->points[i].type) {
  2202. X          case OUTRANGE:
  2203. X          case INRANGE: {
  2204. X            if (plot->points[i].z<0.0) {
  2205. X               if (boxwidth<0.0) {
  2206. X                    /* calculate width */
  2207. X                    if (prev!=UNDEFINED)
  2208. X                        dxl = (plot->points[i-1].x - plot->points[i].x)/2.0;
  2209. X                    else
  2210. X                        dxl = 0.0;
  2211. X                    if (i < plot->p_count-1) {
  2212. X                        if (plot->points[i+1].type!=UNDEFINED)
  2213. X                            dxr = (plot->points[i+1].x - plot->points[i].x)/2.0;
  2214. X                        else
  2215. X                            dxr = -dxl;
  2216. X                    }
  2217. X                    else {
  2218. X                        dxr = -dxl;
  2219. X                    }
  2220. X                    if (prev==UNDEFINED)
  2221. X                        dxl = -dxr;
  2222. X                }
  2223. X                else {
  2224. X                    dxr = boxwidth/2.0;
  2225. X                    dxl = -dxr;
  2226. X                }
  2227. X            }
  2228. X            else {
  2229. X                dxr = plot->points[i].z/2.0;
  2230. X                dxl = -dxr;
  2231. X            }
  2232. X
  2233. X            dxl= plot->points[i].x+dxl;
  2234. X            dxr= plot->points[i].x+dxr;
  2235. X            dyt= plot->points[i].y;
  2236. X
  2237. X            /* clip to border */
  2238. X            if ((y_min < y_max  && dyt < y_min)
  2239. X                || (y_max < y_min  && dyt > y_min))
  2240. X               dyt = y_min;
  2241. X            if ((y_min < y_max  && dyt > y_max)
  2242. X                || (y_max<y_min  && dyt < y_max))
  2243. X               dyt = y_max;
  2244. X            if ((x_min < x_max  && dxr < x_min)
  2245. X                || (x_max < x_min  && dxr > x_min))
  2246. X               dxr = x_min;
  2247. X            if ((x_min < x_max  && dxr > x_max)
  2248. X                || (x_max<x_min  && dxr < x_max))
  2249. X               dxr = x_max;
  2250. X            if ((x_min < x_max  && dxl < x_min)
  2251. X                || (x_max < x_min  && dxl > x_min))
  2252. X               dxl = x_min;
  2253. X            if ((x_min < x_max  && dxl > x_max)
  2254. X                || (x_max<x_min  && dxl < x_max))
  2255. X               dxl = x_max;
  2256. X
  2257. X            xl= map_x(dxl);
  2258. X            xr= map_x(dxr);
  2259. X            yt = map_y(dyt);
  2260. X
  2261. X            (*t->move)(xl,xaxis_y);
  2262. X            (*t->vector)(xl,yt);
  2263. X            (*t->vector)(xr,yt);
  2264. X            (*t->vector)(xr,xaxis_y);
  2265. X            (*t->vector)(xl,xaxis_y);
  2266. X            break;
  2267. X          }
  2268. X          default:        /* just a safety */
  2269. X          case UNDEFINED: {
  2270. X             break;
  2271. X          }
  2272. X       }
  2273. X       prev = plot->points[i].type;
  2274. X    }
  2275. X}
  2276. X
  2277. X/* plot_points:
  2278. X * Plot the curves in POINTSTYLE style
  2279. X */
  2280. Xvoid
  2281. Xplot_points(plot)
  2282. X    struct curve_points *plot;
  2283. X{
  2284. X    int i;
  2285. X    int x,y;
  2286. X    struct termentry *t = &term_tbl[term];
  2287. X
  2288. X    for (i = 0; i < plot->p_count; i++) {
  2289. X       if (plot->points[i].type == INRANGE) {
  2290. X          x = map_x(plot->points[i].x);
  2291. X          y = map_y(plot->points[i].y);
  2292. X          /* do clipping if necessary */
  2293. X          if (!clip_points ||
  2294. X             (   x >= xleft + t->h_tic  && y >= ybot + t->v_tic 
  2295. X              && x <= xright - t->h_tic && y <= ytop - t->v_tic))
  2296. X            (*t->point)(x,y, plot->point_type);
  2297. X       }
  2298. X    }
  2299. X}
  2300. X
  2301. X/* plot_dots:
  2302. X * Plot the curves in DOTS style
  2303. X */
  2304. Xvoid
  2305. Xplot_dots(plot)
  2306. X    struct curve_points *plot;
  2307. X{
  2308. X    int i;
  2309. X    int x,y;
  2310. X    struct termentry *t = &term_tbl[term];
  2311. X
  2312. X    for (i = 0; i < plot->p_count; i++) {
  2313. X       if (plot->points[i].type == INRANGE) {
  2314. X          x = map_x(plot->points[i].x);
  2315. X          y = map_y(plot->points[i].y);
  2316. X          /* point type -1 is a dot */
  2317. X          (*t->point)(x,y, -1);
  2318. X       }
  2319. X    }
  2320. X}
  2321. X
  2322. X/* single edge intersection algorithm */
  2323. X/* Given two points, one inside and one outside the plot, return
  2324. X * the point where an edge of the plot intersects the line segment defined 
  2325. X * by the two points.
  2326. X */
  2327. Xvoid
  2328. Xedge_intersect(points, i, ex, ey)
  2329. X    struct coordinate GPHUGE *points; /* the points array */
  2330. X    int i;                /* line segment from point i-1 to point i */
  2331. X    double *ex, *ey;        /* the point where it crosses an edge */
  2332. X{
  2333. X    /* global x_min, x_max, y_min, x_max */
  2334. X    double ax = points[i-1].x;
  2335. X    double ay = points[i-1].y;
  2336. X    double bx = points[i].x;
  2337. X    double by = points[i].y;
  2338. X    double x, y;            /* possible intersection point */
  2339. X
  2340. X    if (by == ay) {
  2341. X       /* horizontal line */
  2342. X       /* assume inrange(by, y_min, y_max) */
  2343. X       *ey = by;        /* == ay */
  2344. X
  2345. X       if (inrange(x_max, ax, bx))
  2346. X        *ex = x_max;
  2347. X       else if (inrange(x_min, ax, bx))
  2348. X        *ex = x_min;
  2349. X       else {
  2350. X        (*term_tbl[term].text)();
  2351. X        (void) fflush(outfile);
  2352. X        int_error("error in edge_intersect", NO_CARET);
  2353. X       }
  2354. X       return;
  2355. X    } else if (bx == ax) {
  2356. X       /* vertical line */
  2357. X       /* assume inrange(bx, x_min, x_max) */
  2358. X       *ex = bx;        /* == ax */
  2359. X
  2360. X       if (inrange(y_max, ay, by))
  2361. X        *ey = y_max;
  2362. X       else if (inrange(y_min, ay, by))
  2363. X        *ey = y_min;
  2364. X       else {
  2365. X        (*term_tbl[term].text)();
  2366. X        (void) fflush(outfile);
  2367. X        int_error("error in edge_intersect", NO_CARET);
  2368. X       }
  2369. X       return;
  2370. X    }
  2371. X
  2372. X    /* slanted line of some kind */
  2373. X
  2374. X    /* does it intersect y_min edge */
  2375. X    if (inrange(y_min, ay, by) && y_min != ay && y_min != by) {
  2376. X       x = ax + (y_min-ay) * ((bx-ax) / (by-ay));
  2377. X       if (inrange(x, x_min, x_max)) {
  2378. X          *ex = x;
  2379. X          *ey = y_min;
  2380. X          return;            /* yes */
  2381. X       }
  2382. X    }
  2383. X    
  2384. X    /* does it intersect y_max edge */
  2385. X    if (inrange(y_max, ay, by) && y_max != ay && y_max != by) {
  2386. X       x = ax + (y_max-ay) * ((bx-ax) / (by-ay));
  2387. X       if (inrange(x, x_min, x_max)) {
  2388. X          *ex = x;
  2389. X          *ey = y_max;
  2390. X          return;            /* yes */
  2391. X       }
  2392. X    }
  2393. X
  2394. X    /* does it intersect x_min edge */
  2395. X    if (inrange(x_min, ax, bx) && x_min != ax && x_min != bx) {
  2396. X       y = ay + (x_min-ax) * ((by-ay) / (bx-ax));
  2397. X       if (inrange(y, y_min, y_max)) {
  2398. X          *ex = x_min;
  2399. X          *ey = y;
  2400. X          return;
  2401. X       }
  2402. X    }
  2403. X
  2404. X    /* does it intersect x_max edge */
  2405. X    if (inrange(x_max, ax, bx) && x_max != ax && x_max != bx) {
  2406. X       y = ay + (x_max-ax) * ((by-ay) / (bx-ax));
  2407. X       if (inrange(y, y_min, y_max)) {
  2408. X          *ex = x_max;
  2409. X          *ey = y;
  2410. X          return;
  2411. X       }
  2412. X    }
  2413. X
  2414. X    /* It is possible for one or two of the [ab][xy] values to be -VERYLARGE.
  2415. X    * If ax=bx=-VERYLARGE or ay=by=-VERYLARGE we have already returned 
  2416. X    * FALSE above. Otherwise we fall through all the tests above. 
  2417. X    * If two are -VERYLARGE, it is ax=ay=-VERYLARGE or bx=by=-VERYLARGE 
  2418. X    * since either a or b must be INRANGE. 
  2419. X    * Note that for ax=ay=-VERYLARGE or bx=by=-VERYLARGE we can do nothing.
  2420. X    * Handle them carefully here. As yet we have no way for them to be 
  2421. X    * +VERYLARGE.
  2422. X    */
  2423. X    if (ax == -VERYLARGE) {
  2424. X       if (ay != -VERYLARGE) {
  2425. X          *ex = min(x_min, x_max);
  2426. X          *ey = by;
  2427. X          return;
  2428. X       }
  2429. X    } else if (bx == -VERYLARGE) {
  2430. X       if (by != -VERYLARGE) {
  2431. X          *ex = min(x_min, x_max);
  2432. X          *ey = ay;
  2433. X          return;
  2434. X       }
  2435. X    } else if (ay == -VERYLARGE) {
  2436. X       /* note we know ax != -VERYLARGE */
  2437. X       *ex = bx;
  2438. X       *ey = min(y_min, y_max);
  2439. X       return;
  2440. X    } else if (by == -VERYLARGE) {
  2441. X       /* note we know bx != -VERYLARGE */
  2442. X       *ex = ax;
  2443. X       *ey = min(y_min, y_max);
  2444. X       return;
  2445. X    }
  2446. X
  2447. X    /* If we reach here, then either one point is (-VERYLARGE,-VERYLARGE), 
  2448. X    * or the inrange point is on the edge, and
  2449. X     * the line segment from the outrange point does not cross any 
  2450. X    * other edges to get there. In either case, we return the inrange 
  2451. X    * point as the 'edge' intersection point. This will basically draw
  2452. X    * line.
  2453. X    */
  2454. X    if (points[i].type == INRANGE) {
  2455. X       *ex = bx; 
  2456. X       *ey = by;
  2457. X    } else {
  2458. X       *ex = ax; 
  2459. X       *ey = ay;
  2460. X    }
  2461. X    return;
  2462. X}
  2463. X
  2464. X/* XXX - JG  */
  2465. X/* single edge intersection algorithm for "steps" curves */
  2466. X/* 
  2467. X * Given two points, one inside and one outside the plot, return
  2468. X * the point where an edge of the plot intersects the line segments
  2469. X * forming the step between the two points. 
  2470. X *
  2471. X * Recall that if P1 = (x1,y1) and P2 = (x2,y2), the step from  
  2472. X * P1 to P2 is drawn as two line segments: (x1,y1)->(x2,y1) and 
  2473. X * (x2,y1)->(x2,y2). 
  2474. X */
  2475. Xvoid
  2476. Xedge_intersect_steps(points, i, ex, ey)
  2477. X    struct coordinate *points; /* the points array */
  2478. X    int i;                /* line segment from point i-1 to point i */
  2479. X    double *ex, *ey;        /* the point where it crosses an edge */
  2480. X{
  2481. X    /* global x_min, x_max, y_min, x_max */
  2482. X    double ax = points[i-1].x;
  2483. X    double ay = points[i-1].y;
  2484. X    double bx = points[i].x;
  2485. X    double by = points[i].y;
  2486. X
  2487. X    if (points[i].type == INRANGE) {    /* from OUTRANGE to INRANG */
  2488. X        if (inrange(ay,y_min,y_max)) {
  2489. X        *ey = ay;
  2490. X        if (ax > x_max)
  2491. X            *ex = x_max;
  2492. X        else            /* x < x_min */
  2493. X            *ex = x_min;
  2494. X        } else {
  2495. X            *ex = bx;
  2496. X        if (ay > y_max)     
  2497. X            *ey = y_max;
  2498. X        else            /* y < y_min */
  2499. X            *ey = y_min;
  2500. X        }
  2501. X    } else {                /* from INRANGE to OUTRANGE */
  2502. X        if (inrange(bx,x_min,x_max)) {
  2503. X        *ex = bx;
  2504. X        if (by > y_max)
  2505. X            *ey = y_max;
  2506. X        else            /* y < y_min */
  2507. X            *ey = y_min;
  2508. X        } else {
  2509. X            *ey = ay;
  2510. X        if (bx > x_max)     
  2511. X            *ex = x_max;
  2512. X        else            /* x < x_min */
  2513. X            *ex = x_min;
  2514. X        }
  2515. X    }
  2516. X    return;
  2517. X}
  2518. X
  2519. X/* XXX - JG  */
  2520. X/* double edge intersection algorithm for "steps" plot */
  2521. X/* Given two points, both outside the plot, return the points where an 
  2522. X * edge of the plot intersects the line segments forming a step 
  2523. X * by the two points. There may be zero, one, two, or an infinite number
  2524. X * of intersection points. (One means an intersection at a corner, infinite
  2525. X * means overlaying the edge itself). We return FALSE when there is nothing
  2526. X * to draw (zero intersections), and TRUE when there is something to 
  2527. X * draw (the one-point case is a degenerate of the two-point case and we do 
  2528. X * not distinguish it - we draw it anyway).
  2529. X *
  2530. X * Recall that if P1 = (x1,y1) and P2 = (x2,y2), the step from  
  2531. X * P1 to P2 is drawn as two line segments: (x1,y1)->(x2,y1) and 
  2532. X * (x2,y1)->(x2,y2). 
  2533. X */
  2534. XTBOOLEAN                /* any intersection? */
  2535. Xtwo_edge_intersect_steps(points, i, lx, ly)
  2536. X    struct coordinate *points; /* the points array */
  2537. X    int i;                /* line segment from point i-1 to point i */
  2538. X    double *lx, *ly;        /* lx[2], ly[2]: points where it crosses edges */
  2539. X{
  2540. X    /* global x_min, x_max, y_min, x_max */
  2541. X    double ax = points[i-1].x;
  2542. X    double ay = points[i-1].y;
  2543. X    double bx = points[i].x;
  2544. X    double by = points[i].y;
  2545. X
  2546. X    if ( max(ax,bx) < x_min || min(ax,bx) > x_max || 
  2547. X         max(ay,by) < y_min || min(ay,by) > y_max ||
  2548. X         ( (ay  > y_max || ay < y_min)            &&
  2549. X           (bx  > x_max || bx < x_min)  ) ) {
  2550. X    return(FALSE);                
  2551. X    } else if (inrange(ay,y_min,y_max) && inrange(bx,x_min,x_max)) {    /* corner of step inside plotspace */
  2552. X        *ly++ = ay;
  2553. X    if (ax < x_min) 
  2554. X        *lx++ = x_min;
  2555. X    else 
  2556. X        *lx++ = x_max;
  2557. X
  2558. X    *lx++ = bx;
  2559. X    if (by < x_min) 
  2560. X        *ly++ = y_min;
  2561. X    else 
  2562. X        *ly++ = y_max;
  2563. X
  2564. X    return(TRUE);
  2565. X    } else if (inrange(ay,y_min,y_max)) {    /* cross plotspace in x-direction */
  2566. X    *lx++ = x_min;
  2567. X    *ly++ = ay;
  2568. X    *lx++ = x_max;
  2569. X    *ly++ = ay;
  2570. X    return(TRUE);
  2571. X    } else if (inrange(ax,x_min,x_max)) {    /* cross plotspace in y-direction */
  2572. X    *lx++ = bx;
  2573. X    *ly++ = y_min;
  2574. X    *lx++ = bx;
  2575. X    *ly++ = y_max;
  2576. X    return(TRUE);
  2577. X    } else
  2578. X    return(FALSE);
  2579. X}
  2580. X
  2581. X/* double edge intersection algorithm */
  2582. X/* Given two points, both outside the plot, return
  2583. X * the points where an edge of the plot intersects the line segment defined 
  2584. X * by the two points. There may be zero, one, two, or an infinite number
  2585. X * of intersection points. (One means an intersection at a corner, infinite
  2586. X * means overlaying the edge itself). We return FALSE when there is nothing
  2587. X * to draw (zero intersections), and TRUE when there is something to 
  2588. X * draw (the one-point case is a degenerate of the two-point case and we do 
  2589. X * not distinguish it - we draw it anyway).
  2590. X */
  2591. XTBOOLEAN                /* any intersection? */
  2592. Xtwo_edge_intersect(points, i, lx, ly)
  2593. X    struct coordinate GPHUGE *points; /* the points array */
  2594. X    int i;                /* line segment from point i-1 to point i */
  2595. X    double *lx, *ly;        /* lx[2], ly[2]: points where it crosses edges */
  2596. X{
  2597. X    /* global x_min, x_max, y_min, x_max */
  2598. X    double ax = points[i-1].x;
  2599. X    double ay = points[i-1].y;
  2600. X    double bx = points[i].x;
  2601. X    double by = points[i].y;
  2602. X    double x, y;            /* possible intersection point */
  2603. X    TBOOLEAN intersect = FALSE;
  2604. X
  2605. X    if (by == ay) {
  2606. X       /* horizontal line */
  2607. X       /* y coord must be in range, and line must span both x_min and x_max */
  2608. X       /* note that spanning x_min implies spanning x_max */
  2609. X       if (inrange(by, y_min, y_max) && inrange(x_min, ax, bx)) {
  2610. X          *lx++ = x_min;
  2611. X          *ly++ = by;
  2612. X          *lx++ = x_max;
  2613. X          *ly++ = by;
  2614. X          return(TRUE);
  2615. X       } else
  2616. X        return(FALSE);
  2617. X    } else if (bx == ax) {
  2618. X       /* vertical line */
  2619. X       /* x coord must be in range, and line must span both y_min and y_max */
  2620. X       /* note that spanning y_min implies spanning y_max */
  2621. X       if (inrange(bx, x_min, x_max) && inrange(y_min, ay, by)) {
  2622. X          *lx++ = bx;
  2623. X          *ly++ = y_min;
  2624. X          *lx++ = bx;
  2625. X          *ly++ = y_max;
  2626. X          return(TRUE);
  2627. X       } else
  2628. X        return(FALSE);
  2629. X    }
  2630. X
  2631. X    /* slanted line of some kind */
  2632. X    /* there can be only zero or two intersections below */
  2633. X
  2634. X    /* does it intersect y_min edge */
  2635. X    if (inrange(y_min, ay, by)) {
  2636. X       x = ax + (y_min-ay) * ((bx-ax) / (by-ay));
  2637. X       if (inrange(x, x_min, x_max)) {
  2638. X          *lx++ = x;
  2639. X          *ly++ = y_min;
  2640. X          intersect = TRUE;
  2641. X       }
  2642. X    }
  2643. X    
  2644. X    /* does it intersect y_max edge */
  2645. X    if (inrange(y_max, ay, by)) {
  2646. X       x = ax + (y_max-ay) * ((bx-ax) / (by-ay));
  2647. X       if (inrange(x, x_min, x_max)) {
  2648. X          *lx++ = x;
  2649. X          *ly++ = y_max;
  2650. X          intersect = TRUE;
  2651. X       }
  2652. X    }
  2653. X
  2654. X    /* does it intersect x_min edge */
  2655. X    if (inrange(x_min, ax, bx)) {
  2656. X       y = ay + (x_min-ax) * ((by-ay) / (bx-ax));
  2657. X       if (inrange(y, y_min, y_max)) {
  2658. X          *lx++ = x_min;
  2659. X          *ly++ = y;
  2660. X          intersect = TRUE;
  2661. X       }
  2662. X    }
  2663. X
  2664. X    /* does it intersect x_max edge */
  2665. X    if (inrange(x_max, ax, bx)) {
  2666. X       y = ay + (x_max-ax) * ((by-ay) / (bx-ax));
  2667. X       if (inrange(y, y_min, y_max)) {
  2668. X          *lx++ = x_max;
  2669. X          *ly++ = y;
  2670. X          intersect = TRUE;
  2671. X       }
  2672. X    }
  2673. X
  2674. X    if (intersect)
  2675. X     return(TRUE);
  2676. X
  2677. X    /* It is possible for one or more of the [ab][xy] values to be -VERYLARGE.
  2678. X    * If ax=bx=-VERYLARGE or ay=by=-VERYLARGE we have already returned
  2679. X    * FALSE above.
  2680. X    * Note that for ax=ay=-VERYLARGE or bx=by=-VERYLARGE we can do nothing.
  2681. X    * Otherwise we fall through all the tests above. 
  2682. X    * Handle them carefully here. As yet we have no way for them to be +VERYLARGE.
  2683. X    */
  2684. X    if (ax == -VERYLARGE) {
  2685. X       if (ay != -VERYLARGE
  2686. X          && inrange(by, y_min, y_max) && inrange(x_max, ax, bx)) {
  2687. X          *lx++ = x_min;
  2688. X          *ly = by;
  2689. X          *lx++ = x_max;
  2690. X          *ly = by;
  2691. X          intersect = TRUE;
  2692. X       }
  2693. X    } else if (bx == -VERYLARGE) {
  2694. X       if (by != -VERYLARGE
  2695. X          && inrange(ay, y_min, y_max) && inrange(x_max, ax, bx)) {
  2696. X          *lx++ = x_min;
  2697. X          *ly = ay;
  2698. X          *lx++ = x_max;
  2699. X          *ly = ay;
  2700. X          intersect = TRUE;
  2701. X       }
  2702. X    } else if (ay == -VERYLARGE) {
  2703. X       /* note we know ax != -VERYLARGE */
  2704. X       if (inrange(bx, x_min, x_max) && inrange(y_max, ay, by)) {
  2705. X          *lx++ = bx;
  2706. X          *ly = y_min;
  2707. X          *lx++ = bx;
  2708. X          *ly = y_max;
  2709. X          intersect = TRUE;
  2710. X       }
  2711. X    } else if (by == -VERYLARGE) {
  2712. X       /* note we know bx != -VERYLARGE */
  2713. X       if (inrange(ax, x_min, x_max) && inrange(y_max, ay, by)) {
  2714. X          *lx++ = ax;
  2715. X          *ly = y_min;
  2716. X          *lx++ = ax;
  2717. X          *ly = y_max;
  2718. X          intersect = TRUE;
  2719. X       }
  2720. X    }
  2721. X
  2722. X    return(intersect);
  2723. X}
  2724. X
  2725. X/* Polar transform of all curves */
  2726. X/* Original code by John Campbell (CAMPBELL@NAUVAX.bitnet) */
  2727. Xpolar_xform (plots, pcount)
  2728. X    struct curve_points *plots;
  2729. X    int pcount;            /* count of curves in plots array */
  2730. X{
  2731. X     struct curve_points *this_plot;
  2732. X     int curve;            /* loop var, for curves */
  2733. X     register int i, p_cnt;    /* loop/limit var, for points */
  2734. X     struct coordinate GPHUGE *pnts;    /* abbrev. for points array */
  2735. X    double x, y;            /* new cartesian value */
  2736. X    TBOOLEAN anydefined = FALSE;
  2737. X    double d2r;
  2738. X
  2739. X    if(angles_format == ANGLES_DEGREES){
  2740. X        d2r = DEG2RAD;
  2741. X    } else {
  2742. X        d2r = 1.0;
  2743. X    }
  2744. X
  2745. X/*
  2746. X    Cycle through all the plots converting polar to rectangular.
  2747. X     If autoscaling, adjust max and mins. Ignore previous values.
  2748. X    If not autoscaling, use the yrange for both x and y ranges.
  2749. X*/
  2750. X    if (autoscale_ly) {
  2751. X        x_min = VERYLARGE;
  2752. X        y_min = VERYLARGE;
  2753. X        x_max = -VERYLARGE;
  2754. X        y_max = -VERYLARGE;
  2755. X        autoscale_lx = TRUE;
  2756. X    } else {
  2757. X        x_min = y_min;
  2758. X        x_max = y_max;
  2759. X    }
  2760. X    
  2761. X    this_plot = plots;
  2762. X    for (curve = 0; curve < pcount; this_plot = this_plot->next_cp, curve++) {
  2763. X        p_cnt = this_plot->p_count;
  2764. X        pnts = &(this_plot->points[0]);
  2765. X
  2766. X    /*    Convert to cartesian all points in this curve. */
  2767. X        for (i = 0; i < p_cnt; i++) {
  2768. X            if (pnts[i].type != UNDEFINED) {
  2769. X                 anydefined = TRUE;
  2770. X                 /* modify points to reset origin and from degrees */
  2771. X                 pnts[i].y -= rmin;
  2772. X                 pnts[i].x *= d2r;
  2773. X                 /* convert to cartesian coordinates */
  2774. X                x = pnts[i].y*cos(pnts[i].x);
  2775. X                y = pnts[i].y*sin(pnts[i].x);
  2776. X                pnts[i].x = x;
  2777. X                pnts[i].y = y;
  2778. X                if (autoscale_ly) {
  2779. X                    if (x_min > x) x_min = x;
  2780. X                    if (x_max < x) x_max = x;
  2781. X                    if (y_min > y) y_min = y;
  2782. X                    if (y_max < y) y_max = y;
  2783. X                    pnts[i].type = INRANGE;
  2784. X                } else if(inrange(x, x_min, x_max) && inrange(y, y_min, y_max))
  2785. X                  pnts[i].type = INRANGE;
  2786. X                else
  2787. X                  pnts[i].type = OUTRANGE;
  2788. X            }
  2789. X        }    
  2790. X    }
  2791. X
  2792. X    if (autoscale_lx && anydefined && fabs(x_max - x_min) < zero) {
  2793. X        /* This happens at least for the plot of 1/cos(x) (vertical line). */
  2794. X        fprintf(stderr, "Warning: empty x range [%g:%g], ", x_min,x_max);
  2795. X        if (x_min == 0.0) {
  2796. X           x_min = -1; 
  2797. X           x_max = 1;
  2798. X        } else {
  2799. X           x_min *= 0.9;
  2800. X           x_max *= 1.1;
  2801. X        }
  2802. X        fprintf(stderr, "adjusting to [%g:%g]\n", x_min,x_max);
  2803. X    }
  2804. X    if (autoscale_ly && anydefined && fabs(y_max - y_min) < zero) {
  2805. X        /* This happens at least for the plot of 1/sin(x) (horiz. line). */
  2806. X        fprintf(stderr, "Warning: empty y range [%g:%g], ", y_min, y_max);
  2807. X        if (y_min == 0.0) {
  2808. X           y_min = -1;
  2809. X           y_max = 1;
  2810. X        } else {
  2811. X           y_min *= 0.9;
  2812. X           y_max *= 1.1;
  2813. X        }
  2814. X        fprintf(stderr, "adjusting to [%g:%g]\n", y_min, y_max);
  2815. X    }
  2816. X}
  2817. X
  2818. X/* DRAW_YTICS: draw a regular tic series, y axis */
  2819. Xdraw_ytics(start, incr, end)
  2820. X        double start, incr, end; /* tic series definition */
  2821. X        /* assume start < end, incr > 0 */
  2822. X{
  2823. X    double ticplace;
  2824. X    int ltic;            /* for mini log tics */
  2825. X    double lticplace;    /* for mini log tics */
  2826. X    double ticmin, ticmax;    /* for checking if tic is almost inrange */
  2827. X
  2828. X    if (end == VERYLARGE)            /* for user-def series */
  2829. X        end = max(y_min,y_max);
  2830. X
  2831. X    /* limit to right side of plot */
  2832. X    end = min(end, max(y_min,y_max));
  2833. X
  2834. X    /* to allow for rounding errors */
  2835. X    ticmin = min(y_min,y_max) - SIGNIF*incr;
  2836. X    ticmax = max(y_min,y_max) + SIGNIF*incr;
  2837. X    end = end + SIGNIF*incr; 
  2838. X
  2839. X    for (ticplace = start; ticplace <= end; ticplace +=incr) {
  2840. X        if ( inrange(ticplace,ticmin,ticmax) )
  2841. X            ytick(ticplace, yformat, incr, 1.0);
  2842. X        if (is_log_y && incr == 1.0) {
  2843. X            /* add mini-ticks to log scale ticmarks */
  2844. X            int lstart, linc;
  2845. X            if ((end - start) >= 10)
  2846. X            {
  2847. X            lstart = 10; /* No little ticks */
  2848. X            linc = 5;
  2849. X            }
  2850. X            else if((end - start) >= 5)
  2851. X            {
  2852. X            lstart = 2; /* 4 per decade */
  2853. X            linc = 3;
  2854. X            }
  2855. X            else
  2856. X            {
  2857. X            lstart = 2; /* 9 per decade */
  2858. X            linc = 1;
  2859. X            }
  2860. X            for (ltic = lstart; ltic < (int)base_log_y; ltic += linc) {
  2861. X                lticplace = ticplace+log((double)ltic)/log_base_log_y;
  2862. X                if ( inrange(lticplace,ticmin,ticmax) )
  2863. X                    ytick(lticplace, "\0", incr, 0.5);
  2864. X            }
  2865. X        }
  2866. X    }
  2867. X}
  2868. X
  2869. X/* DRAW_XTICS: draw a regular tic series, x axis */
  2870. Xdraw_xtics(start, incr, end)
  2871. X        double start, incr, end; /* tic series definition */
  2872. X        /* assume start < end, incr > 0 */
  2873. X{
  2874. X    double ticplace;
  2875. X    int ltic;            /* for mini log tics */
  2876. X    double lticplace;    /* for mini log tics */
  2877. X    double ticmin, ticmax;    /* for checking if tic is almost inrange */
  2878. X
  2879. X    if (end == VERYLARGE)            /* for user-def series */
  2880. X        end = max(x_min,x_max);
  2881. X
  2882. X    /* limit to right side of plot */
  2883. X    end = min(end, max(x_min,x_max));
  2884. X
  2885. X    /* to allow for rounding errors */
  2886. X    ticmin = min(x_min,x_max) - SIGNIF*incr;
  2887. X    ticmax = max(x_min,x_max) + SIGNIF*incr;
  2888. X    end = end + SIGNIF*incr; 
  2889. X
  2890. X    for (ticplace = start; ticplace <= end; ticplace +=incr) {
  2891. X        if ( inrange(ticplace,ticmin,ticmax) )
  2892. X            if(!polar || ticplace == start || ticplace == end) 
  2893. X                xtick(ticplace, xformat, incr, 1.0);
  2894. X        if (is_log_x && incr == 1.0) {
  2895. X            /* add mini-ticks to log scale ticmarks */
  2896. X            int lstart, linc;
  2897. X            if ((end - start) >= 10)
  2898. X            {
  2899. X            lstart = 10; /* No little ticks */
  2900. X            linc = 5;
  2901. X            }
  2902. X            else if((end - start) >= 5)
  2903. X            {
  2904. X            lstart = 2; /* 4 per decade */
  2905. X            linc = 3;
  2906. X            }
  2907. X            else
  2908. X            {
  2909. X            lstart = 2; /* 9 per decade */
  2910. X            linc = 1;
  2911. X            }
  2912. X            for (ltic = lstart; ltic < (int)base_log_x; ltic += linc) {
  2913. X                lticplace = ticplace+log((double)ltic)/log_base_log_x;
  2914. X                if ( inrange(lticplace,ticmin,ticmax) )
  2915. X                    xtick(lticplace, "\0", incr, 0.5);
  2916. X            }
  2917. X        }
  2918. X    }
  2919. X}
  2920. X
  2921. X/* DRAW_SERIES_YTICS: draw a user tic series, y axis */
  2922. Xdraw_series_ytics(start, incr, end)
  2923. X        double start, incr, end; /* tic series definition */
  2924. X        /* assume start < end, incr > 0 */
  2925. X{
  2926. X    double ticplace, place;
  2927. X    double ticmin, ticmax;    /* for checking if tic is almost inrange */
  2928. X    double spacing = is_log_y ? log(incr)/log_base_log_y : incr;
  2929. X
  2930. X    if (end == VERYLARGE)
  2931. X        end = max(CheckLog(is_log_y, base_log_y, y_min),
  2932. X              CheckLog(is_log_y, base_log_y, y_max));
  2933. X    else
  2934. X      /* limit to right side of plot */
  2935. X      end = min(end, max(CheckLog(is_log_y, base_log_y, y_min),
  2936. X                 CheckLog(is_log_y, base_log_y, y_max)));
  2937. X
  2938. X    /* to allow for rounding errors */
  2939. X    ticmin = min(y_min,y_max) - SIGNIF*incr;
  2940. X    ticmax = max(y_min,y_max) + SIGNIF*incr;
  2941. X    end = end + SIGNIF*incr; 
  2942. X
  2943. X    for (ticplace = start; ticplace <= end; ticplace +=incr) {
  2944. X        place = (is_log_y ? log(ticplace)/log_base_log_y : ticplace);
  2945. X        if ( inrange(place,ticmin,ticmax) )
  2946. X         ytick(place, yformat, spacing, 1.0);
  2947. X    }
  2948. X}
  2949. X
  2950. X
  2951. X/* DRAW_SERIES_XTICS: draw a user tic series, x axis */
  2952. Xdraw_series_xtics(start, incr, end)
  2953. X        double start, incr, end; /* tic series definition */
  2954. X        /* assume start < end, incr > 0 */
  2955. X{
  2956. X    double ticplace, place;
  2957. X    double ticmin, ticmax;    /* for checking if tic is almost inrange */
  2958. X    double spacing = is_log_x ? log(incr)/log_base_log_x : incr;
  2959. X
  2960. X    if (end == VERYLARGE)
  2961. X        end = max(CheckLog(is_log_x, base_log_x, x_min),
  2962. X              CheckLog(is_log_x, base_log_x, x_max));
  2963. X    else
  2964. X      /* limit to right side of plot */
  2965. X      end = min(end, max(CheckLog(is_log_x, base_log_x, x_min),
  2966. X                 CheckLog(is_log_x, base_log_x, x_max)));
  2967. X
  2968. X    /* to allow for rounding errors */
  2969. X    ticmin = min(x_min,x_max) - SIGNIF*incr;
  2970. X    ticmax = max(x_min,x_max) + SIGNIF*incr;
  2971. X    end = end + SIGNIF*incr; 
  2972. X
  2973. X    for (ticplace = start; ticplace <= end; ticplace +=incr) {
  2974. X        place = (is_log_x ? log(ticplace)/log_base_log_x : ticplace);
  2975. X        if ( inrange(place,ticmin,ticmax) )
  2976. X         xtick(place, xformat, spacing, 1.0);
  2977. X    }
  2978. X}
  2979. Xchar GPFAR * GPFAR month[]={
  2980. X    "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
  2981. X};
  2982. Xdraw_month_ytics()
  2983. X{ 
  2984. X    long l_tickplace,l_incr,l_end,m_calc;
  2985. X
  2986. X    l_tickplace = (long)y_min;
  2987. X    if((double)l_tickplace<y_min)l_tickplace++;
  2988. X    l_end=(double)y_max;
  2989. X    l_incr=(l_end-l_tickplace+1)/12;
  2990. X    if(l_incr<1)l_incr=1;
  2991. X    while(l_tickplace<=l_end)
  2992. X    {
  2993. X    m_calc = (l_tickplace-1)%12;
  2994. X    if(m_calc<0)m_calc += 12;
  2995. X    ytick((double)l_tickplace,month[m_calc],(double)l_incr,1.0);
  2996. X    l_tickplace += l_incr;
  2997. X    }
  2998. X}
  2999. Xdraw_month_xtics()
  3000. X{
  3001. X    long l_tickplace,l_incr,l_end,m_calc;
  3002. X
  3003. X    l_tickplace = (long)x_min;
  3004. X    if((double)l_tickplace<x_min)l_tickplace++;
  3005. X    l_end=(double)x_max;
  3006. X    l_incr=(l_end-l_tickplace+1)/12;
  3007. X    if(l_incr<1)l_incr=1;
  3008. X    while(l_tickplace<=l_end)
  3009. X    {
  3010. X    m_calc = (l_tickplace-1)%12;
  3011. X    if(m_calc<0)m_calc += 12;
  3012. X    xtick((double)l_tickplace,month[m_calc],(double)l_incr,1.0);
  3013. X    l_tickplace += l_incr;
  3014. X    }
  3015. X}
  3016. Xchar *day[]={
  3017. X    "Sun","Mon","Tue","Wed","Thu","Fri","Sat"
  3018. X};
  3019. Xdraw_day_ytics()
  3020. X{ 
  3021. X    long l_tickplace,l_incr,l_end,m_calc;
  3022. X
  3023. X    l_tickplace = (long)y_min;
  3024. X    if((double)l_tickplace<y_min)l_tickplace++;
  3025. X    l_end=(double)y_max;
  3026. X    l_incr=(l_end-l_tickplace+1)/14;
  3027. X    if(l_incr<1)l_incr=1;
  3028. X    while(l_tickplace<=l_end)
  3029. X    {
  3030. X    m_calc = l_tickplace%7;
  3031. X    if(m_calc<0)m_calc += 7;
  3032. X    ytick((double)l_tickplace,day[m_calc],(double)l_incr,1.0);
  3033. X    l_tickplace += l_incr;
  3034. X    }
  3035. X}
  3036. Xdraw_day_xtics()
  3037. X{ 
  3038. X    long l_tickplace,l_incr,l_end,m_calc;
  3039. X
  3040. X    l_tickplace = (long)x_min;
  3041. X    if((double)l_tickplace<x_min)l_tickplace++;
  3042. X    l_end=(double)x_max;
  3043. X    l_incr=(l_end-l_tickplace+1)/14;
  3044. X    if(l_incr<1)l_incr=1;
  3045. X    while(l_tickplace<=l_end)
  3046. X    {
  3047. X    m_calc = l_tickplace%7;
  3048. X    if(m_calc<0)m_calc += 7;
  3049. X    xtick((double)l_tickplace,day[m_calc],(double)l_incr,1.0);
  3050. X    l_tickplace += l_incr;
  3051. X    }
  3052. X}
  3053. X/* DRAW_SET_YTICS: draw a user tic set, y axis */
  3054. Xdraw_set_ytics(list)
  3055. X    struct ticmark *list;    /* list of tic marks */
  3056. X{
  3057. X    double ticplace;
  3058. X    double incr = (y_max - y_min) / 10;
  3059. X    /* global x_min, x_max, xscale, y_min, y_max, yscale */
  3060. X
  3061. X    while (list != NULL) {
  3062. X       ticplace = (is_log_y ? log(list->position)/log_base_log_y
  3063. X                : list->position);
  3064. X       if ( inrange(ticplace, y_min, y_max)         /* in range */
  3065. X          || NearlyEqual(ticplace, y_min, incr)    /* == y_min */
  3066. X          || NearlyEqual(ticplace, y_max, incr))    /* == y_max */
  3067. X        ytick(ticplace, list->label, incr, 1.0);
  3068. X
  3069. X       list = list->next;
  3070. X    }
  3071. X}
  3072. X
  3073. X/* DRAW_SET_XTICS: draw a user tic set, x axis */
  3074. Xdraw_set_xtics(list)
  3075. X    struct ticmark *list;    /* list of tic marks */
  3076. X{
  3077. X    double ticplace;
  3078. X    double incr = (x_max - x_min) / 10;
  3079. X    /* global x_min, x_max, xscale, y_min, y_max, yscale */
  3080. X
  3081. X    while (list != NULL) {
  3082. X       ticplace = (is_log_x ? log(list->position)/log_base_log_x
  3083. X                : list->position);
  3084. X       if ( inrange(ticplace, x_min, x_max)         /* in range */
  3085. X          || NearlyEqual(ticplace, x_min, incr)    /* == x_min */
  3086. X          || NearlyEqual(ticplace, x_max, incr))    /* == x_max */
  3087. X        xtick(ticplace, list->label, incr, 1.0);
  3088. X
  3089. X       list = list->next;
  3090. X    }
  3091. X}
  3092. X
  3093. X/* draw and label a y-axis ticmark */
  3094. Xytick(place, text, spacing, ticscale)
  3095. X        double place;                   /* where on axis to put it */
  3096. X        char *text;                     /* optional text label */
  3097. X        double spacing;         /* something to use with checkzero */
  3098. X        double ticscale;         /* scale factor for tic mark (0..1] */
  3099. X{
  3100. X    register struct termentry *t = &term_tbl[term];
  3101. X    char ticlabel[101];
  3102. X    int ticsize = (int)((t->h_tic) * ticscale);
  3103. X
  3104. X    place = CheckZero(place,spacing); /* to fix rounding error near zero */
  3105. X    if (grid) {
  3106. X           (*t->linetype)(-1);  /* axis line type */
  3107. X           /* do not put a rectangular grid on a polar plot */
  3108. X       if( !polar){
  3109. X         (*t->move)(xleft, map_y(place));
  3110. X         (*t->vector)(xright, map_y(place));
  3111. X           } else {   /* put a circular grid for polar -- not clipped! */
  3112. X             int i;
  3113. X        (*t->move)(map_x(ZERO), map_y(place));
  3114. X        for( i=0; i <= 360; i++)
  3115. X           (*t->vector)( map_x(place*sin( (double) DEG2RAD*i)),
  3116. X            map_y(place*cos( (double) DEG2RAD*i)) );
  3117. X        }
  3118. X       (*t->linetype)(-2); /* border linetype */
  3119. X    }
  3120. X    if (tic_in) {
  3121. X      /* if polar plot, put the tics along the axes */
  3122. X      if( polar){
  3123. X           (*t->move)(map_x(ZERO),map_y(place));
  3124. X           (*t->vector)(map_x(ZERO) + ticsize, map_y(place));
  3125. X           (*t->move)(map_x(ZERO), map_y(place));
  3126. X           (*t->vector)(map_x(ZERO) - ticsize, map_y(place));
  3127. X     } else {
  3128. X       (*t->move)(xleft, map_y(place));
  3129. X           (*t->vector)(xleft + ticsize, map_y(place));
  3130. X           (*t->move)(xright, map_y(place));
  3131. X           (*t->vector)(xright - ticsize, map_y(place));
  3132. X     }
  3133. X    } else {
  3134. X      if( polar){
  3135. X           (*t->move)(map_x(ZERO), map_y(place));
  3136. X           (*t->vector)(map_x(ZERO) - ticsize, map_y(place));
  3137. X     }else{
  3138. X           (*t->move)(xleft, map_y(place));
  3139. X           (*t->vector)(xleft - ticsize, map_y(place));
  3140. X     }
  3141. X    }
  3142. X
  3143. X    /* label the ticmark */
  3144. X    if (text == NULL) 
  3145. X     text = yformat;
  3146. X    
  3147. X    if( polar){
  3148. X      (void) sprintf(ticlabel, text,
  3149. X        CheckLog(is_log_y, base_log_y, fabs( place)+rmin));
  3150. X      if ((*t->justify_text)(RIGHT)) {
  3151. X       (*t->put_text)(map_x(ZERO)-(t->h_char),
  3152. X                   map_y(place), ticlabel);
  3153. X     } else {
  3154. X       (*t->put_text)(map_x(ZERO)-(t->h_char)*(strlen(ticlabel)+1),
  3155. X                   map_y(place), ticlabel);
  3156. X     }
  3157. X    } else {
  3158. X    
  3159. X      (void) sprintf(ticlabel, text, CheckLog(is_log_y, base_log_y, place));
  3160. X      if ((*t->justify_text)(RIGHT)) {
  3161. X       (*t->put_text)(xleft-(t->h_char),
  3162. X                   map_y(place), ticlabel);
  3163. X     } else {
  3164. X       (*t->put_text)(xleft-(t->h_char)*(strlen(ticlabel)+1),
  3165. X                   map_y(place), ticlabel);
  3166. X     }
  3167. X    }
  3168. X}
  3169. X
  3170. X/* draw and label an x-axis ticmark */
  3171. Xxtick(place, text, spacing, ticscale)
  3172. X        double place;                   /* where on axis to put it */
  3173. X        char *text;                     /* optional text label */
  3174. X        double spacing;         /* something to use with checkzero */
  3175. X        double ticscale;         /* scale factor for tic mark (0..1] */
  3176. X{
  3177. X    register struct termentry *t = &term_tbl[term];
  3178. X    char ticlabel[101];
  3179. X    int ticsize = (int)((t->v_tic) * ticscale);
  3180. X
  3181. X    place = CheckZero(place,spacing); /* to fix rounding error near zero */
  3182. X    if (grid) {
  3183. X           (*t->linetype)(-1);  /* axis line type */
  3184. X           if( !polar){  /* do not place a rectangular grid */
  3185. X         (*t->move)(map_x(place), ybot);
  3186. X         (*t->vector)(map_x(place), ytop);
  3187. X           } else { /* angular lines only for start and stop */
  3188. X         int i;
  3189. X         for( i=0; i < 360; i+=10){
  3190. X         (*t->move)(map_x(ZERO),map_y(ZERO) );
  3191. X         (*t->vector)(map_x(-place*cos((double) DEG2RAD*i)),
  3192. X             map_y(-place*sin( (double)DEG2RAD*i)));
  3193. X         if( i%90 == 0){
  3194. X             (void) sprintf(ticlabel, "%d", i);
  3195. X         (*t->put_text)(map_x(-1.05*place*cos((double) DEG2RAD*i))
  3196. X             +(t->h_char)*strlen(ticlabel)/2,
  3197. X             map_y(-1.05*place*sin( (double)DEG2RAD*i))
  3198. X                 , ticlabel);
  3199. X         }
  3200. X         }
  3201. X           }
  3202. X       (*t->linetype)(-2); /* border linetype */
  3203. X    }
  3204. X    if (tic_in) {
  3205. X      if( polar){
  3206. X           (*t->move)(map_x(place), map_y(ZERO));
  3207. X           (*t->vector)(map_x(place), map_y(ZERO) + ticsize);
  3208. X           (*t->move)(map_x(place), map_y(ZERO));
  3209. X           (*t->vector)(map_x(place), map_y(ZERO) - ticsize);
  3210. X     } else{
  3211. X           (*t->move)(map_x(place), ybot);
  3212. X           (*t->vector)(map_x(place), ybot + ticsize);
  3213. X           (*t->move)(map_x(place), ytop);
  3214. X           (*t->vector)(map_x(place), ytop - ticsize);
  3215. X     }
  3216. X    } else {
  3217. X      if( polar){
  3218. X           (*t->move)(map_x(place), map_y(ZERO));
  3219. X           (*t->vector)(map_x(place), map_y(ZERO) - ticsize);
  3220. X     }else{
  3221. X           (*t->move)(map_x(place), ybot);
  3222. X           (*t->vector)(map_x(place), ybot - ticsize);
  3223. X     }
  3224. X    }
  3225. X    
  3226. X    /* label the ticmark */
  3227. X    if (text == NULL)
  3228. X     text = xformat;
  3229. X
  3230. X    if(polar){
  3231. X      (void) sprintf(ticlabel, text, CheckLog(is_log_x, base_log_x, fabs(place)+rmin));
  3232. X      if ((*t->justify_text)(CENTRE)) {
  3233. X       (*t->put_text)(map_x(place),
  3234. X                   map_y(ZERO)-(t->v_char), ticlabel);
  3235. X     } else {
  3236. X       (*t->put_text)(map_x(place)-(t->h_char)*strlen(ticlabel)/2,
  3237. X                   map_y(ZERO)-(t->v_char), ticlabel);
  3238. X     }
  3239. X    }else{
  3240. X
  3241. X      (void) sprintf(ticlabel, text, CheckLog(is_log_x, base_log_x, place));
  3242. X      if ((*t->justify_text)(CENTRE)) {
  3243. X       (*t->put_text)(map_x(place),
  3244. X                   ybot-(t->v_char), ticlabel);
  3245. X     } else {
  3246. X       (*t->put_text)(map_x(place)-(t->h_char)*strlen(ticlabel)/2,
  3247. X                   ybot-(t->v_char), ticlabel);
  3248. X     }
  3249. X    }
  3250. X}
  3251. END_OF_FILE
  3252.   if test 55795 -ne `wc -c <'gnuplot/graphics.c'`; then
  3253.     echo shar: \"'gnuplot/graphics.c'\" unpacked with wrong size!
  3254.   fi
  3255.   # end of 'gnuplot/graphics.c'
  3256. fi
  3257. echo shar: End of archive 7 \(of 33\).
  3258. cp /dev/null ark7isdone
  3259. MISSING=""
  3260. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
  3261.     if test ! -f ark${I}isdone ; then
  3262.     MISSING="${MISSING} ${I}"
  3263.     fi
  3264. done
  3265. if test "${MISSING}" = "" ; then
  3266.     echo You have unpacked all 33 archives.
  3267.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3268. else
  3269.     echo You still must unpack the following archives:
  3270.     echo "        " ${MISSING}
  3271. fi
  3272. exit 0
  3273. exit 0 # Just in case...
  3274.