INTERPOLATE

Developer(s): Nick Hampshire
Date: 198x
Type: Program
Platform(s): TS 2068

Interpolates a graph from the data you supply.

Appears on

Capital Area Timex Sinclair User Group’s Library Tape.

Gallery

INTERPOLATE

Source Code

    1 REM interpolate
    2 PRINT "Here is a program that sets up  an interpolated graph of infor- mation that you supply in the   data statement of line 180.     Press any key for a demo.       Taken from Hampshire's ""Color   Graphics""." 
    3 IF INKEY$="" THEN GO TO 3
    4 CLS 
   60 INK 0: PAPER 7: BORDER 3
   90 GO SUB 1000
  110 DIM x(12): DIM y(12)
  120 FOR i=1 TO 12
  130 READ x(i): READ y(i)
  160 NEXT i
  180 DATA 1,266,2,241,3,247,4,245,5,239,6,228,7,225,8,230,9,240,10,246,11,240,12,0
  200 LET dn=1: LET dx=12: LET sp=1
  220 LET xl=240: LET xr=15: LET yt=100: LET yb=30
  310 PLOT xr-5,yb-5
  320 DRAW (xl-xr+10),0
  330 DRAW 0,(yt-yb+10)
  340 DRAW -(xl-xr+10),0
  350 DRAW 0,-(yt-yb+10)
  355 LET xi=(xl-xr)/(dx-dn)
  360 FOR x=xr TO xl STEP xi
  365 PLOT x,yb-6: PLOT x,yb-7
  370 NEXT x
  380 PRINT AT 2,7;"Interpolated Graph"
  410 LET y1=-1000000
  420 LET y2=1000000
  430 LET x1=y1: LET x2=y2
  440 FOR i=dn TO dx STEP sp
  450 IF y1<y(i) THEN LET y1=y(i)
  460 IF y2>y(i) THEN LET y2=y(i)
  470 IF x1<x(i) THEN LET x1=x(i)
  480 IF x2>x(i) THEN LET x2=x(i)
  490 NEXT i
  510 LET a=(x1-x2)/(xl-xr)
  520 LET b=(y1-y2)/(yt-yb)
  610 FOR i=dn TO dx STEP sp
  620 LET x=(xr+(x(i)-x2)/a)
  630 LET y=((y(i)-y2)/b+yb)
  640 PLOT x,y
  650 LET q=i+sp
  660 IF q>dx THEN STOP 
  670 FOR j=x(i) TO x(q) STEP .03
  680 LET y3=((y(q)-y(i))/(x(q)-x(i)))*(j-x(i))+y(i)
  690 LET x=INT (xr+(j-x2)/a)
  700 LET y=INT ((y3-y2)/b+yb)
  710 PLOT x,y
  730 NEXT j: NEXT i
 1000 REM border
 1010 PLOT 0,0
 1020 DRAW 255,0
 1030 DRAW 0,175
 1040 DRAW -255,0
 1050 DRAW 0,-175
 1060 RETURN 
Scroll to Top