Program to render a point cloud like a relief map ("as is" and without warrantry.)

First of all, here is the TurboCNC G-code that was used to scan a 15 x 15 mm surface of an Italian 1 Euro coin at 0.1mm intervals and record the data in SURFSCAN.DAT.
  G00 X0 Y0 Z0                 ; get into position
  G32 X15 Y15 -Z1 I0.1 F10     ; scan 15 x 15 mm every 0.1 mm
This produced some 22500 lines of data that started like this:
  X  0.00000 Y  0.00000 Z -0.30875  
  X  0.00000 Y  0.10062 Z -0.30000  
  X  0.00000 Y  0.19906 Z -0.30000  
  X  0.00000 Y  0.29968 Z -0.30875  
  X  0.00000 Y  0.40031 Z -0.30875  
  ;  etc .... 
Here is the BASIC program that was used to render this data like a relief map. You would probably need to change it to run with your BASIC and tweak the constants to suit your system.
' ### INITIALISE ################################################

 ON KEY(1) GOSUB Bye             ' break out if F1 is pressed
 KEY(1) ON                       ' initialise F1 key
 SCREEN 7                        ' graphic screen with 16 colours
 WINDOW (0,0) - (150,150)        ' 15 x 15 mm grid, every 0.1 mm
 VIEW (70,40)-(219,159)          ' centre the image on screen
 OPEN "SURFSCAN.DAT" FOR INPUT AS #1 ' open data file

' ### MAIN LOOP #################################################

 WHILE NOT EOF(1)                ' continue till end of file
   LINE INPUT #1,I$              ' get line of data as string
                                      
   A = INSTR(I$,"X") + 1         ' find starts of X,Y,Z strings
   B = INSTR(I$,"Y") + 1
   C = INSTR(I$,"Z") + 1
                                      
   X = VAL(MID$(I$,A,8))         ' X, Y and Z strings to digits
   Y = VAL(MID$(I$,B,8))
   Z = VAL(MID$(I$,C,8))
   Height = ABS((INT(Z*80))+10)  ' cook Z's to integers 1 to 25
 
   SELECT CASE Height            ' choose suitable colours
     CASE 25,24   : Colour = 0   ' black
     CASE 22      : Colour = 1   ' blue
     CASE 21,20   : Colour = 9   ' light blue
     CASE 19,18   : Colour = 11  ' cyan
     CASE 17,16   : Colour = 10  ' light green
     CASE 15,14   : Colour = 2   ' green
     CASE 13      : Colour = 14  ' yellow
     CASE 12,11,10: Colour = 12  ' light red
     CASE 10,9,8,7: Colour = 4   ' red
     CASE 6       : Colour = 0   ' brown
     CASE 5       : Colour = 5   ' magenta
     CASE 3,2,1   : Colour = 0   ' black
   END SELECT
   PSET (X*10, Y*10), Colour     ' plot a pixel to screen
 WEND                            ' get the next line of data 

' ### END OF MAIN LOOP ##########################################
 Bye:
 END   
back to CNC