home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / sources / 3095 < prev    next >
Encoding:
Text File  |  1993-01-25  |  17.4 KB  |  573 lines

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!mcsun!sun4nl!fwi.uva.nl!gene.fwi.uva.nl!bosman
  3. From: bosman@fwi.uva.nl (Cor Bosman)
  4. Subject: Bouncing Splines. Module for XLOCK
  5. Message-ID: <1993Jan25.123937.8069@fwi.uva.nl>
  6. Sender: news@fwi.uva.nl
  7. Nntp-Posting-Host: ram.fwi.uva.nl
  8. Organization: FWI, University of Amsterdam
  9. Date: Mon, 25 Jan 1993 12:39:37 GMT
  10. Lines: 561
  11.  
  12.  
  13. #! /bin/sh
  14. # This is a shell archive.  Remove anything before this line, then unpack
  15. # it by saving it into a file and typing "sh file".  To overwrite existing
  16. # files, type "sh file -c".  You can also feed this as standard input via
  17. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  18. # will see the following message at the end:
  19. #        "End of shell archive."
  20. # Contents:  README spline.patch spline.c
  21. # Wrapped by bosman@fwi.uva.nl on Mon Jan 25 13:36:34 1993
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'README' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'README'\"
  25. else
  26. echo shar: Extracting \"'README'\" \(349 characters\)
  27. sed "s/^X//" >'README' <<'END_OF_FILE'
  28. X    Bouncing Splines. Module for XLock, the Xwindow System lockscreen.
  29. X
  30. X    spline.patch:  patchfile with necessary changes to original Xlock.
  31. X    spline.c    :  bouncing splines code.
  32. X
  33. X
  34. XAdded option to xlock:  -points <x>  to choose the number of points
  35. Xthrough which the curve will be drawn.
  36. X
  37. XUse -batchcount <x> to set the length of the tail.
  38. X
  39. END_OF_FILE
  40. if test 349 -ne `wc -c <'README'`; then
  41.     echo shar: \"'README'\" unpacked with wrong size!
  42. fi
  43. # end of 'README'
  44. fi
  45. if test -f 'spline.patch' -a "${1}" != "-c" ; then 
  46.   echo shar: Will not clobber existing file \"'spline.patch'\"
  47. else
  48. echo shar: Extracting \"'spline.patch'\" \(6993 characters\)
  49. sed "s/^X//" >'spline.patch' <<'END_OF_FILE'
  50. X-----------
  51. Xdiff -c3 xlock/Imakefile spline/Imakefile
  52. X*** xlock/Imakefile    Sat Sep 28 03:10:41 1991
  53. X--- spline/Imakefile    Fri Jan 22 16:30:47 1993
  54. X***************
  55. X*** 8,17 ****
  56. X    SYS_LIBRARIES = -lm
  57. X             SRCS = xlock.c hsbramp.c usleep.c resource.c \
  58. X          hopalong.c qix.c life.c image.c blank.c \
  59. X!         swarm.c rotor.c pyro.c flame.c worm.c
  60. X             OBJS = xlock.o hsbramp.o usleep.o resource.o \
  61. X          hopalong.o qix.o life.o image.o blank.o \
  62. X!         swarm.o rotor.o pyro.o flame.o worm.o
  63. X  
  64. X  ComplexProgramTarget(xlock)
  65. X  InstallAppDefaults(XLock)
  66. X--- 8,17 ----
  67. X    SYS_LIBRARIES = -lm
  68. X             SRCS = xlock.c hsbramp.c usleep.c resource.c \
  69. X          hopalong.c qix.c life.c image.c blank.c \
  70. X!         swarm.c rotor.c pyro.c flame.c worm.c spline.c
  71. X             OBJS = xlock.o hsbramp.o usleep.o resource.o \
  72. X          hopalong.o qix.o life.o image.o blank.o \
  73. X!         swarm.o rotor.o pyro.o flame.o worm.o spline.o
  74. X  
  75. X  ComplexProgramTarget(xlock)
  76. X  InstallAppDefaults(XLock)
  77. Xdiff -c3 xlock/Makefile spline/Makefile
  78. X*** xlock/Makefile    Sat Sep 28 03:08:58 1991
  79. X--- spline/Makefile    Fri Jan 22 16:31:13 1993
  80. X***************
  81. X*** 3,9 ****
  82. X  
  83. X  C_SRCS=xlock.c hsbramp.c usleep.c resource.c \
  84. X      hopalong.c qix.c life.c image.c blank.c \
  85. X!     swarm.c rotor.c pyro.c flame.c worm.c
  86. X  HDRS=xlock.h
  87. X  IMAGES=lifeicon.bit sunlogo.bit
  88. X  SRCS=${C_SRCS} ${HDRS} ${IMAGES} xlock.man XLock.ad
  89. X--- 3,9 ----
  90. X  
  91. X  C_SRCS=xlock.c hsbramp.c usleep.c resource.c \
  92. X      hopalong.c qix.c life.c image.c blank.c \
  93. X!     swarm.c rotor.c pyro.c flame.c worm.c spline.c
  94. X  HDRS=xlock.h
  95. X  IMAGES=lifeicon.bit sunlogo.bit
  96. X  SRCS=${C_SRCS} ${HDRS} ${IMAGES} xlock.man XLock.ad
  97. Xdiff -c3 xlock/XLock.ad spline/XLock.ad
  98. X*** xlock/XLock.ad    Sat Sep 28 03:10:01 1991
  99. X--- spline/XLock.ad    Fri Jan 22 16:30:06 1993
  100. X***************
  101. X*** 45,50 ****
  102. X--- 45,54 ----
  103. X  XLock.worm.delay: 10000
  104. X  XLock.worm.batchcount: 20
  105. X  XLock.worm.saturation: 1
  106. X+ XLock.spline.delay: 0
  107. X+ XLock.spline.batchcount: 15
  108. X+ XLock.spline.saturation: 1
  109. X+ XLock.spline.points: 5
  110. X  XLock.blank.delay: 5000000
  111. X  XLock.blank.batchcount: 1
  112. X  XLock.blank.saturation: 1
  113. Xdiff -c3 xlock/resource.c spline/resource.c
  114. X*** xlock/resource.c    Sat Sep 28 02:58:54 1991
  115. X--- spline/resource.c    Fri Jan 22 16:35:59 1993
  116. X***************
  117. X*** 9,14 ****
  118. X--- 9,15 ----
  119. X   * See xlock.c for copying information.
  120. X   *
  121. X   * Revision History:
  122. X+  * 22-Jan-93: Added spline mode and points option.
  123. X   * 25-Sep-91: added worm mode.
  124. X   * 24-Jun-91: changed name to username.
  125. X   * 06-Jun-91: Added flame mode.
  126. X***************
  127. X*** 66,71 ****
  128. X--- 67,75 ----
  129. X  extern void initworm();
  130. X  extern void drawworm();
  131. X  
  132. X+ extern void initspline();
  133. X+ extern void drawspline();
  134. X+ 
  135. X  typedef struct {
  136. X      char       *cmdline_arg;
  137. X      void        (*lp_init) ();
  138. X***************
  139. X*** 88,93 ****
  140. X--- 92,98 ----
  141. X      {"pyro", initpyro, drawpyro, 15000, 40, 1.0, "Fireworks"},
  142. X      {"flame", initflame, drawflame, 10000, 20, 1.0, "Cosmic Flame Fractals"},
  143. X      {"worm", initworm, drawworm, 10000, 20, 1.0, "Wiggly Worms"},
  144. X+     {"spline", initspline, drawspline, 2000, 5, 1.0, "Bouncing Spline"},
  145. X      {"blank", initblank, drawblank, 5000000, 1, 1.0, "Blank screen"},
  146. X      {randomstring, NULL, NULL, 0, 0, 0.0, "Random mode"},
  147. X  };
  148. X***************
  149. X*** 103,109 ****
  150. X  #define DEF_FILESEARCHPATH "/usr/lib/X11/%T/%N%S"
  151. X  #endif
  152. X  #define DEF_DISPLAY    ":0"
  153. X! #define DEF_MODE    "life"
  154. X  #define DEF_FONT    "-b&h-lucida-medium-r-normal-sans-24-*-*-*-*-*-iso8859-1"
  155. X  #define DEF_BG        "White"
  156. X  #define DEF_FG        "Black"
  157. X--- 108,114 ----
  158. X  #define DEF_FILESEARCHPATH "/usr/lib/X11/%T/%N%S"
  159. X  #endif
  160. X  #define DEF_DISPLAY    ":0"
  161. X! #define DEF_MODE    "spline"
  162. X  #define DEF_FONT    "-b&h-lucida-medium-r-normal-sans-24-*-*-*-*-*-iso8859-1"
  163. X  #define DEF_BG        "White"
  164. X  #define DEF_FG        "Black"
  165. X***************
  166. X*** 114,119 ****
  167. X--- 119,125 ----
  168. X  #define DEF_INVALID    "Invalid login."
  169. X  #define DEF_TIMEOUT    "30"    /* secs till password entry times out */
  170. X  #define DEF_BC        "100"    /* vectors (or whatever) per batch */
  171. X+ #define DEF_PT          "5"     /* number of spline points */
  172. X  #define DEF_DELAY    "200000"/* microseconds between batches */
  173. X  #define DEF_NICE    "10"    /* xlock process nicelevel */
  174. X  #define DEF_SAT        "1.0"    /* color ramp saturation 0->1 */
  175. X***************
  176. X*** 162,167 ****
  177. X--- 168,174 ----
  178. X      {"-delay", ".delay", XrmoptionSepArg, (caddr_t) NULL},
  179. X      {"-batchcount", ".batchcount", XrmoptionSepArg, (caddr_t) NULL},
  180. X      {"-saturation", ".saturation", XrmoptionSepArg, (caddr_t) NULL},
  181. X+     {"-points", ".points", XrmoptionSepArg, (caddr_t) NULL},
  182. X  };
  183. X  #define modeEntries (sizeof modeTable / sizeof modeTable[0])
  184. X  
  185. X***************
  186. X*** 200,205 ****
  187. X--- 207,213 ----
  188. X      {"-/+v", "turn on/off verbose mode"},
  189. X      {"-delay usecs", "microsecond delay between screen updates"},
  190. X      {"-batchcount num", "number of things per batch"},
  191. X+     {"-points num", "number of spline points"},
  192. X      {"-nice level", "nice level for xlock process"},
  193. X      {"-timeout seconds", "number of seconds before password times out"},
  194. X      {"-saturation value", "saturation of color ramp"},
  195. X***************
  196. X*** 228,233 ****
  197. X--- 236,242 ----
  198. X  int         nicelevel;
  199. X  int         delay;
  200. X  int         batchcount;
  201. X+ int         points;
  202. X  int         timeout;
  203. X  Bool        mono;
  204. X  Bool        nolock;
  205. X***************
  206. X*** 279,284 ****
  207. X--- 288,294 ----
  208. X      {(caddr_t *) &delay, "delay", "Delay", DEF_DELAY, t_Int},
  209. X      {(caddr_t *) &batchcount, "batchcount", "BatchCount", DEF_BC, t_Int},
  210. X      {(caddr_t *) &saturation, "saturation", "Saturation", DEF_SAT, t_Float},
  211. X+     {(caddr_t *) &points, "points", "Points", DEF_PT, t_Int},
  212. X  };
  213. X  #define NMODEARGS (sizeof modevars / sizeof modevars[0])
  214. X  
  215. XOnly in spline: spline.c
  216. Xdiff -c3 xlock/xlock.h spline/xlock.h
  217. X*** xlock/xlock.h    Sat Sep 28 03:05:30 1991
  218. X--- spline/xlock.h    Fri Jan 22 16:36:55 1993
  219. X***************
  220. X*** 39,44 ****
  221. X--- 39,45 ----
  222. X  extern int  nicelevel;
  223. X  extern int  delay;
  224. X  extern int  batchcount;
  225. X+ extern int  points;
  226. X  extern int  reinittime;
  227. X  extern int  timeout;
  228. X  extern Bool usefirst;
  229. Xdiff -c3 xlock/xlock.man spline/xlock.man
  230. X*** xlock/xlock.man    Sat Sep 28 02:58:22 1991
  231. X--- spline/xlock.man    Fri Jan 22 16:42:32 1993
  232. X***************
  233. X*** 52,57 ****
  234. X--- 52,60 ----
  235. X  .BI \-batchcount " num"
  236. X  ]
  237. X  [
  238. X+ .BI \-points " num"
  239. X+ ]
  240. X+ [
  241. X  .BI \-nice " level"
  242. X  ]
  243. X  [
  244. X***************
  245. X*** 163,168 ****
  246. X--- 166,174 ----
  247. X  .B worm
  248. X  Worm mode shows wiggly worms...
  249. X  .TP 8
  250. X+ .B spline
  251. X+ Spline mode shows pretty bouncing splines.
  252. X+ .TP 8
  253. X  .B blank
  254. X  Blank mode shows nothing but a black screen.
  255. X  .TP 8
  256. X***************
  257. X*** 198,204 ****
  258. X--- 204,216 ----
  259. X  In pyro mode it is the maximum number flying rockets at one time.
  260. X  In flame mode it is the number of levels to recurse (larger = more complex).
  261. X  In worm mode it is the number of worms.
  262. X+ In spline mode it is the number of splines.
  263. X  In blank mode it means nothing.
  264. X+ .TP 5
  265. X+ .B \-points " num"
  266. X+ The
  267. X+ .I points
  268. X+ option sets the number of points used for the spline outline.
  269. X  .TP 5
  270. X  .B \-nice " nicelevel"
  271. X  The
  272. END_OF_FILE
  273. if test 6993 -ne `wc -c <'spline.patch'`; then
  274.     echo shar: \"'spline.patch'\" unpacked with wrong size!
  275. fi
  276. # end of 'spline.patch'
  277. fi
  278. if test -f 'spline.c' -a "${1}" != "-c" ; then 
  279.   echo shar: Will not clobber existing file \"'spline.c'\"
  280. else
  281. echo shar: Extracting \"'spline.c'\" \(7673 characters\)
  282. sed "s/^X//" >'spline.c' <<'END_OF_FILE'
  283. X#ifndef lint
  284. Xstatic char sccsid[] = "@(#)spline.c   93/01/20 XLOCK";
  285. X#endif
  286. X
  287. X/*  spline.c - Bouncing Spline for xlock, the X Window System lockscreen
  288. X *
  289. X *  Copyright (c) 1993 by Cor Bosman. (bosman@fwi.uva.nl)
  290. X *
  291. X *  See xlock.c for copying information.
  292. X *
  293. X *  21-Jan-93: Converted kurvp1 and kurvp2 to C from pascal.
  294. X *  20-Jan-93: Written.
  295. X */
  296. X
  297. X#include "xlock.h"
  298. X#include <stdio.h>
  299. X#include <math.h>
  300. X
  301. X#define CURVEPOINTS 200  /* number of points on the curve */
  302. X#define SIGMA 1.0
  303. X#define MAXLINES 1000
  304. X
  305. Xtypedef struct {
  306. X    XPoint points[CURVEPOINTS+1];
  307. X} curve;
  308. X
  309. Xtypedef struct {
  310. X    int npoints;
  311. X    int nlines;  
  312. X    int pix;
  313. X    double *x;
  314. X    double *y;
  315. X    int *dx;
  316. X    int *dy;
  317. X    int head;
  318. X    int tail;
  319. X    int width;
  320. X    int height;
  321. X    long startTime;
  322. X    curve *curves;
  323. X    double *xp;
  324. X    double *yp;
  325. X} splinestruct;
  326. X
  327. Xstatic splinestruct splines[MAXSCREENS];
  328. X
  329. Xvoid
  330. Xinitspline(win)
  331. XWindow win;
  332. X{
  333. X  int i;
  334. X
  335. X  XWindowAttributes xgwa;
  336. X  splinestruct *sp = &splines[screen];
  337. X
  338. X  sp->startTime = seconds();
  339. X  if(points < 2) points=2;
  340. X  else if(points > 20) points=20;
  341. X  sp->npoints = points;
  342. X  if(batchcount > MAXLINES) batchcount = MAXLINES;
  343. X  sp->nlines = batchcount+1;
  344. X
  345. X  if(!sp->curves) {
  346. X    sp->x = (double *) malloc(sizeof(double) * sp->npoints);
  347. X    sp->y = (double *) malloc(sizeof(double) * sp->npoints);
  348. X    sp->dx = (int *) malloc(sizeof(int) * sp->npoints);
  349. X    sp->dy = (int *) malloc(sizeof(int) * sp->npoints);
  350. X    sp->xp = (double *) malloc(sizeof(double) * sp->npoints);
  351. X    sp->yp = (double *) malloc(sizeof(double) * sp->npoints);
  352. X    sp->curves = (curve *) malloc(sizeof(curve) * sp->nlines);
  353. X  }
  354. X  memset(sp->curves, 0, sp->nlines * sizeof(curve));
  355. X  
  356. X  XGetWindowAttributes(dsp, win, &xgwa);
  357. X  sp->width = xgwa.width;
  358. X  sp->height = xgwa.height;
  359. X
  360. X  if(sp->width < 100) sp->nlines = 2;
  361. X
  362. X  srand(time(NULL));
  363. X  for(i=0; i<sp->npoints; i++) {
  364. X    sp->x[i] = (double)(rand() % sp->width);
  365. X    sp->y[i] = (double)(rand() % sp->height);
  366. X    sp->dx[i] = ((rand()%21)-10);
  367. X    while(sp->dx[i] == 0) sp->dx[i] = ((rand()%21)-10);
  368. X    sp->dy[i] = ((rand()%21)-10);
  369. X    while(sp->dy[i] == 0) sp->dy[i] = ((rand()%21)-10);
  370. X  }  
  371. X  sp->head = 0;
  372. X  sp->tail = 1;
  373. X  XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp,screen));
  374. X  XFillRectangle(dsp, win, Scr[screen].gc, 0, 0, sp->width, sp->height);
  375. X}
  376. X
  377. Xvoid
  378. Xdrawspline(win) 
  379. XWindow win;
  380. X{
  381. X  double s;
  382. X  splinestruct *sp = &splines[screen];
  383. X  int i;
  384. X  
  385. X  for(i=0; i<sp->npoints; i++) {
  386. X    sp->x[i] += sp->dx[i];
  387. X    sp->y[i] += sp->dy[i];
  388. X    if((sp->x[i]<0) || (sp->x[i]>sp->width)) sp->dx[i] = -sp->dx[i];
  389. X    if((sp->y[i]<0) || (sp->y[i]>sp->height)) sp->dy[i] = -sp->dy[i];
  390. X  }
  391. X  kurvp1(sp->npoints, sp->x, sp->y, SIGMA, sp->xp, sp->yp, &s);
  392. X  for(i=0; i<CURVEPOINTS; i++) {
  393. X    kurvp2((double)i/CURVEPOINTS,s,SIGMA,sp->npoints,sp->x,sp->y,sp->xp,sp->yp,
  394. X       &(sp->curves[sp->head].points[i].x),&(sp->curves[sp->head].points[i].y));
  395. X  }
  396. X
  397. X  XSetForeground(dsp, Scr[screen].gc, Scr[screen].pixels[sp->pix]);
  398. X
  399. X  sp->curves[sp->head].points[CURVEPOINTS].x = sp->curves[sp->head].points[0].x;
  400. X  sp->curves[sp->head].points[CURVEPOINTS].y = sp->curves[sp->head].points[0].y;
  401. X
  402. X  XDrawLines(dsp, win, Scr[screen].gc, sp->curves[sp->head].points, CURVEPOINTS+1, CoordModeOrigin);
  403. X
  404. X  sp->head++;  if(sp->head >= sp->nlines) sp->head = 0;
  405. X
  406. X  sp->curves[sp->tail].points[CURVEPOINTS].x = sp->curves[sp->tail].points[0].x;
  407. X  sp->curves[sp->tail].points[CURVEPOINTS].y = sp->curves[sp->tail].points[0].y;
  408. X
  409. X  XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
  410. X  XDrawLines(dsp,win,Scr[screen].gc,sp->curves[sp->tail].points,CURVEPOINTS+1,CoordModeOrigin);
  411. X  sp->tail++;  if(sp->tail >= sp->nlines) sp->tail = 0;
  412. X
  413. X  if(++sp->pix >= Scr[screen].npixels) sp->pix = 0;
  414. X}  
  415. X
  416. X
  417. X/* kurvp1 and kurvp2 create the kurve through a number of points */
  418. Xkurvp1(n, x, y, sigma, xp, yp, s) 
  419. Xint n;
  420. Xdouble *x, *y, sigma, *xp, *yp, *s;
  421. X/*
  422. X *  Adapted from A.K. Cline, Comm. ACM 4 (1972) 220
  423. X */
  424. X{
  425. X    int nm1,np1,i,ip1,ibak;
  426. X    double delx1,delx2,dels1,dx1,dy1,dely1,dely2,dels2,dx2,dy2, sigmap,exps,sinhs,sinhin,diag1,diag2,diagin,spdig1,spdiag,dels;
  427. X    double temp[CURVEPOINTS*2];
  428. X
  429. X    nm1 = n-2; np1=n;
  430. X    delx1 = x[1]-x[0];
  431. X    dely1 = y[1]-y[0];
  432. X    dels1 = sqrt(pow(delx1, 2.0)+pow(dely1, 2.0));
  433. X    dx1 = delx1/dels1; dy1 = dely1/dels1;
  434. X    xp[0] = dx1; yp[0] = dy1;
  435. X    temp[0] = dels1;
  436. X    *s = dels1;
  437. X    
  438. X    for(i=1; i<n; i++) {
  439. X      if(i == n-1) ip1 = 0;
  440. X      else ip1 = i+1;
  441. X      delx2 = x[ip1]-x[i]; dely2=y[ip1]-y[i];
  442. X      dels2 = sqrt(pow(delx2, 2.0) + pow(dely2, 2.0));
  443. X      dx2 = delx2/dels2;
  444. X      dy2 = dely2/dels2;
  445. X      xp[i] = dx2-dx1;  yp[i]=dy2-dy1;
  446. X      temp[i] = dels2;
  447. X      delx1 = delx2;  dely1=dely2;  dels1=dels2;
  448. X      dx1 = dx2; dy1 = dy2;
  449. X      (*s)=(*s)+dels1;
  450. X    }
  451. X
  452. X    xp[0] = xp[0]-dx1;  yp[0]=yp[0]-dy1;
  453. X    sigmap = fabs(sigma)*(n/(*s));
  454. X   
  455. X    dels = sigmap*temp[n-1];  exps = exp(dels);
  456. X    sinhs = 0.5*(exps-(1.0/exps));
  457. X    sinhin = 1.0/(temp[n-1]*sinhs);
  458. X    diag1 = sinhin*(dels*0.5*(exps+(1.0/exps))-sinhs);
  459. X    diagin = 1.0/diag1;
  460. X    spdig1 = sinhin*(sinhs-dels);
  461. X    spdiag = 0;
  462. X    
  463. X    for(i=0; i<n; i++) {
  464. X      dels = sigmap*temp[i];
  465. X      exps = exp(dels);
  466. X      sinhs = 0.5*(exps-(1.0/exps));
  467. X      sinhin = 1.0/(temp[i]*sinhs);
  468. X      diag2 = sinhin*(dels*(0.5*(exps+(1.0/exps)))-sinhs);
  469. X      
  470. X      if(i == 0) {
  471. X        diagin = 1.0/(diag1+diag2);
  472. X        xp[0] = diagin*xp[0];
  473. X        yp[0] = diagin*yp[0];
  474. X        temp[n] = 0;
  475. X        temp[np1] = -diagin*spdig1;
  476. X        spdiag = sinhin*(sinhs-dels);
  477. X        temp[0] = diagin*spdiag;
  478. X        diag1 = diag2;
  479. X      }
  480. X      if((i<n-1) && (i>0)) {
  481. X        diagin = 1.0/(diag1+diag2-(spdiag*temp[i-1]));
  482. X        xp[i] = diagin*(xp[i]-(spdiag*xp[i-1]));
  483. X        yp[i] = diagin*(yp[i]-(spdiag*yp[i-1]));
  484. X        temp[n+i] = -diagin*temp[nm1+i+1]*spdiag;
  485. X        spdiag = sinhin*(sinhs-dels);
  486. X        temp[i] = diagin*spdiag;
  487. X        diag1 = diag2;
  488. X      }
  489. X    }
  490. X
  491. X    temp[nm1] = temp[n+nm1]-temp[nm1];
  492. X    
  493. X    if(n!=2) {
  494. X      for(i=2; i<n; i++) {
  495. X        ibak = np1-i-1;
  496. X        xp[ibak] = xp[ibak]-temp[ibak]*xp[ibak+1];
  497. X        yp[ibak] = yp[ibak]-temp[ibak]*yp[ibak+1];
  498. X        temp[ibak] = temp[ibak+n] - temp[ibak]*temp[ibak+1];
  499. X      }
  500. X    }
  501. X    xp[n-1] = (xp[n-1]-(spdig1*xp[0])-(spdiag*xp[nm1]))/
  502. X              (diag1+diag2+(spdig1*temp[0])+(spdiag*temp[nm1]));
  503. X    yp[n-1] = (yp[n-1]-(spdig1*yp[0])-(spdiag*yp[nm1]))/
  504. X              (diag1+diag2+(spdig1*temp[0])+(spdiag*temp[nm1]));
  505. X   
  506. X    for(i=0; i<=nm1; i++) {
  507. X      xp[i] = xp[i] + (temp[i]*xp[n-1]);
  508. X      yp[i] = yp[i] + (temp[i]*yp[n-1]);
  509. X    }
  510. X}
  511. X
  512. Xkurvp2(t, s, sigma, n, x, y, xp, yp, xs, ys)
  513. Xdouble t, s, sigma;
  514. Xint n;
  515. Xdouble *x, *y, *xp, *yp;
  516. Xshort *xs, *ys;
  517. X/*
  518. X *  Adapted from A.K. Cline, Comm. ACM 4 (1974) 220
  519. X */
  520. X{
  521. X  int flag, i, im1;
  522. X  double sigmap, tn, delx, dely, dels, del1, del2, sum, sumdels, savesum, exps, exps1, sinhs, sinhd1, sinhd2;
  523. X
  524. X
  525. X  sigmap=fabs(sigma)*(n/s);
  526. X  tn=fabs(t*s); i=1; sum=0;
  527. X  do {
  528. X    delx=x[i]-x[i-1];
  529. X    dely=y[i]-y[i-1];
  530. X    dels=sqrt((delx*delx)+(dely*dely));
  531. X    sumdels=sum+dels;
  532. X    flag=(sumdels>=tn);
  533. X    savesum=sum;
  534. X    sum=sumdels;
  535. X    i++;
  536. X  } while(!(flag || (i==n))); 
  537. X  if(flag) {
  538. X    sum=savesum;
  539. X    i--;
  540. X    im1=i-1;
  541. X  } else {
  542. X    i=0;
  543. X    im1=n-1;
  544. X    dels=s-sum;
  545. X  }
  546. X  del1=tn-sum; del2=dels-del1;
  547. X  exps1=exp(sigmap*del1);
  548. X  sinhd1=0.5*(exps1-1.0/exps1);
  549. X  exps=exp(sigmap*del2);
  550. X  sinhd2=0.5*(exps-1.0/exps);
  551. X  exps=exps1*exps;
  552. X  sinhs=0.5*(exps-1.0/exps);
  553. X  *xs=(short)((xp[i]*sinhd1+xp[im1]*sinhd2)/sinhs +
  554. X         ((x[i]-xp[i])*del1+(x[im1]-xp[im1])*del2)/dels);
  555. X  *ys=(short)((yp[i]*sinhd1+yp[im1]*sinhd2)/sinhs +
  556. X         ((y[i]-yp[i])*del1+(y[im1]-yp[im1])*del2)/dels);
  557. X}
  558. X
  559. END_OF_FILE
  560. if test 7673 -ne `wc -c <'spline.c'`; then
  561.     echo shar: \"'spline.c'\" unpacked with wrong size!
  562. fi
  563. # end of 'spline.c'
  564. fi
  565. echo shar: End of shell archive.
  566. exit 0
  567. -- 
  568. |bosman@fwi.uva.nl_   //     | Honest Officer , had I known my health      |
  569. |-----------------\\ //AMIGA | stood in jeopardy I would never had lit one.|
  570. |  PE no.1         \\/       |             -MAXIM (of the Hells Angels)-   |
  571. |__________ Quickly Scotty,beam me up.There is no ox..y..ge..._____________|
  572.