Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
wx_gam.cc File Reference
#include <stdlib.h>
#include "wx_image.h"

Go to the source code of this file.

Defines

#define BUTTW   80
#define BUTTW2   100
#define BUTTH   19
#define LINESTR   "Lines"
#define CURVSTR   "Spline"
#define HSVSTR   "HSV Mode"
#define RGBSTR   "RGB Mode"
#define NUMHANDS   4
#define NOHUE   -1

Functions

static float splint (int xa[], int ya[], float y2a[], int n, float x)
static void spline (int *, int *, int, float *)

Variables

byte gamcr [256]
byte fsgamcr [256]
XPoint ghand [NUMHANDS]
XPoint defgam [NUMHANDS]
static int firsttime = 1

Define Documentation

#define BUTTH   19

Definition at line 39 of file wx_gam.cc.

#define BUTTW   80

Definition at line 37 of file wx_gam.cc.

#define BUTTW2   100

Definition at line 38 of file wx_gam.cc.

#define CURVSTR   "Spline"

Definition at line 42 of file wx_gam.cc.

#define HSVSTR   "HSV Mode"

Definition at line 43 of file wx_gam.cc.

#define LINESTR   "Lines"

Definition at line 41 of file wx_gam.cc.

#define NOHUE   -1

Definition at line 200 of file wx_gam.cc.

#define NUMHANDS   4

Definition at line 49 of file wx_gam.cc.

#define RGBSTR   "RGB Mode"

Definition at line 44 of file wx_gam.cc.


Function Documentation

static void spline ( int x,
int y,
int  n,
float *  y2 
) [static]

Definition at line 143 of file wx_gam.cc.

{
  /* given arrays of data points x[0..n-1] and y[0..n-1], computes the
     values of the second derivative at each of the data points
     y2[0..n-1] for use in the splint function */

  int i,k;
  float p,qn,sig,un,u[NUMHANDS];

  y2[0] = u[0] = 0.0;

  for (i=1; i<n-1; i++) {
    sig = ((float) x[i]-x[i-1]) / ((float) x[i+1] - x[i-1]);
    p = sig * y2[i-1] + 2.0;
    y2[i] = (sig-1.0) / p;
    u[i] = (((float) y[i+1]-y[i]) / (x[i+1]-x[i])) - 
           (((float) y[i]-y[i-1]) / (x[i]-x[i-1]));
    u[i] = (6.0 * u[i]/(x[i+1]-x[i-1]) - sig*u[i-1]) / p;
  }
  qn = un = 0.0;

  y2[n-1] = (un-qn*u[n-2]) / (qn*y2[n-2]+1.0);
  for (k=n-2; k>=0; k--) {
    y2[k] = y2[k]*y2[k+1]+u[k];
  }
}
static float splint ( int  xa[],
int  ya[],
float  y2a[],
int  n,
float  x 
) [static]

Definition at line 173 of file wx_gam.cc.

{
  int klo,khi,k;
  float h,b,a;

  klo = 0;
  khi = n-1;
  while (khi-klo > 1) {
    k = (khi+klo) >> 1;
    if (xa[k] > x) khi = k;
    else klo = k;
  }
  h = xa[khi] - xa[klo];
  if (h==0.0) fprintf(stderr, "bad xvalues in splint\n");
  a = (xa[khi]-x)/h;
  b = (x-xa[klo])/h;
  return (a*ya[klo] + b*ya[khi] + ((a*a*a-a)*y2a[klo] +(b*b*b-b)*y2a[khi]) 
         * (h*h) / 6.0);
}

Variable Documentation

XPoint defgam[NUMHANDS]

Definition at line 52 of file wx_gam.cc.

int firsttime = 1 [static]

Definition at line 53 of file wx_gam.cc.

byte fsgamcr[256]

Definition at line 47 of file wx_gam.cc.

byte gamcr[256]

Definition at line 46 of file wx_gam.cc.

XPoint ghand[NUMHANDS]

Definition at line 50 of file wx_gam.cc.