; docformat = 'rst' ;+ ;This function takes the linear interpolation along line (x1, y1) to ;(x2, y2) at point x. ; ; :Examples: ; result = linterp(x1, y1, x2, y2, x) ;- ;+ ; :Params: ; x1 : in, required, type=double ; X-coordinate of the first point on the line. Must be a scalar. ; y1 : in, required, type=double or array of double ; Y-coordinate(s) of the first point on the line. May be a scalar or ; an array as long as it agrees dimensionally with y2. ; x2 : in, required, type = double ; X-coordinate of the second point on the line. Must be a scalar. ; y2 : in, required, type=double or array of double ; Y-coordinate(s) of the second point on the line. May be a scalar or ; an array as long as it agrees dimensionally with y1. ; x : in, required, type=double or array of double ; X-coordinate of where the linear interpolation is calculated. May be ; an array, if y1 and y2 are scalar. ; ; :Returns: ; Returns the linear interpolation between the points (x1, y1) and ; (x2, y2). ;- function linterp,x1,y1,x2,y2,x if (n_elements(x1) ne 1) or (n_elements(x2) ne 1) then begin doc_library, 'linterp' return, -1 endif t=(x-x1)/(x2-x1) return,y1*(1-t)+y2*t end