;+ ; ; @file_comments ; project linearly a segment, a vector whose boundaries are [a,b] on ; a vector whose boundaries are [c,d] ; ; @categories ; Calculation ; ; @param VECTEUR {type=vector} ; A vector whose the first element must be the smallest one and the last must be the biggest one. ; ; @param BORNES ; New boundaries of the vector. ; ; @keyword MP ; Activate this keyword to the function send back this a vector of 2 ; elements which are the m and p of the linear projection y=mx+p used ; to pass from the [a,b] segment to the [c,d] segment. ; ; @returns ; A vector whose new boundaries are specified by BORNES. ; ; @examples ; ; IDL> a=indgen(9) ; IDL> print, a ; 0 1 2 3 4 5 6 7 8 ; IDL> print, projsegment(a,[0,80]) ; 0 10 20 30 40 50 60 70 80 ; IDL> print, projsegment(a,[0,-80]) ; 0 -10 -20 -30 -40 -50 -60 -70 -80 ; IDL> print, projsegment(a,[-80,0]) ; -80 -70 -60 -50 -40 -30 -20 -10 0 ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; 24/6/1999 ; ; @version ; $Id$ ; ;- ; FUNCTION projsegment, vecteur, bornes, MP = mp ; compile_opt idl2, strictarrsubs ; a1 = float(vecteur[0]) b1 = float(vecteur[n_elements(vecteur)-1]) a2 = float(bornes[0]) b2 =float( bornes[1]) if a1 EQ b1 then return, -1 m = (b2-a2)/(b1-a1) p = a2-m*a1 ;-------------------------------------------------------------- if keyword_set(mp) then return, [m, p] ELSE return, m*vecteur+p ;-------------------------------------------------------------- end