; docformat = 'rst' ; ; NAME: ; INTERPOLFUNC ; PURPOSE: ; Interpolate a function between two points ; ;+ ; :Description: ; Interpolate a function between two points ; ; :Categories: ; Maths, Interpolation ; ; :Params: ; FCN: in, required, type=string ; Name of the function to be used ; PARAM: in, required ; Parameters of the function ; A: in, required, type=fltarr(2) ; Cartesian coordinates of the first point of segment [A-B] ; B: in, required, type=fltarr(2) ; Cartesian coordinates of the second point of segment [A-B] ; N: in, required, type=integer ; Number of points to generate between A and B (included) ; ; :Author: ; B.Carry (IMCCE) ; ; :History: ; Change History:: ; Original Version written in June 2013, B. Carry (IMCCE) ; 2013 Sep. - B.Carry (IMCCE) - Header cleaned ;- function interpolFunc, FCN, PARAM, A, B, N ;-------------------------------------------------------------------------------- ;--I-- Initialization And Input Verification ----------------------------------- ;--I.1-- Check Presence of Arguments if N_params() LT 5 then begin message, /IOERROR, 'Syntax - XY = INTERPOLFUNC(FCN, PARAM, A, B, N)' return, -1 endif ;--I.1-- Null Segments if (A(0) eq B(0) and A(1) eq B(1)) then begin flag = -1 return, [0,0] endif ;-------------------------------------------------------------------------------- ;--II-- Change of Reference Frame ---------------------------------------------- ;--II.1-- Translate the System so A is at the Origin inB = B - A ;--II.2-- Length of Segment A-B distAB = sqrt( inB(0)*inB(0) + inB(1)*inB(1)) ;-------------------------------------------------------------------------------- ;--III-- Interpolation between the Two Extrema --------------------------------- ;--III.1-- Generate Abscissa between Rotated A and B X = A(0) + distAB * findgen(N)/float(N-1) ;--III.2-- Evaluate the Function yOut = call_function(fcn, x, param ) ;--III.3-- Export the Solutions ; outXY(--,*,*) = Solution number ; outXY(*,--,*) = [0/1]XY ; outXY(*,*,--) = Solution number outXY = transpose([ [[x], [reform(yOut(0,*))]], [[x], [reform(yOut(1,*))]] ], [2,1,0]) ; ;-Solutions / XY / Points return, outXY end