FUNCTION FRDT2D
*-- Author :    Stephen J. Maxfield   22/04/94
      FUNCTION FRDT2D(TS, V0, V1, S1)
*                                                                                                             
*     The time-to-distance function.                                                                          
*     TS is time in ticks scaled by average drift velocity in cm/tick                                         
*     V0, V1 (corrected) velocities at wire and 1st knot point                                                
*     S1 distance in cm (corrected) to 1st knot point                                                         
*                                                                                                             
*     Return drift distance in cm.                                                                            
*                                                                                                             
      IF( TS .LT. 0. ) THEN                                             
                                                                        
       DRIFT = V0*TS                                                    
                                                                        
      ELSE                                                              
                                                                        
*      Time taken to arrive at first knot point...                                                            
       TAU    =   S1 / (V1-V0)                                          
       T1     =   TAU * ALOG( V1 / V0 )                                 
                                                                        
       TS = ABS(TS)                                                     
       IF(TS .LE. T1) THEN                                              
        DRIFT = V0*TAU*(EXP(TS/TAU) - 1.0)                              
       ELSE                                                             
        DRIFT = S1 + V1*(TS - T1)                                       
       ENDIF                                                            
                                                                        
      ENDIF                                                             
                                                                        
      FRDT2D = DRIFT                                                    
      RETURN                                                            
      END                                                               
*