[142] | 1 | ;+ |
---|
[2] | 2 | ; |
---|
[142] | 3 | ; @file_comments |
---|
[231] | 4 | ; project linearly a segment, a vector whose boundaries are [a,b] on |
---|
[142] | 5 | ; a vector whose boundaries are [c,d] |
---|
[2] | 6 | ; |
---|
[142] | 7 | ; @categories |
---|
[157] | 8 | ; Calculation |
---|
[2] | 9 | ; |
---|
[163] | 10 | ; @param VECTEUR {type=vector} |
---|
[142] | 11 | ; A vector whose the first element must be the smallest one and the last must be the biggest one. |
---|
[2] | 12 | ; |
---|
[231] | 13 | ; @param BORNES |
---|
[142] | 14 | ; New boundaries of the vector. |
---|
[2] | 15 | ; |
---|
[142] | 16 | ; @keyword MP |
---|
[231] | 17 | ; Activate this keyword to the function send back this a vector of 2 |
---|
| 18 | ; elements which are the m and p of the linear projection y=mx+p used |
---|
[142] | 19 | ; to pass from the [a,b] segment to the [c,d] segment. |
---|
[2] | 20 | ; |
---|
[231] | 21 | ; @returns |
---|
[163] | 22 | ; A vector whose new boundaries are specified by BORNES. |
---|
[2] | 23 | ; |
---|
[142] | 24 | ; @examples |
---|
[231] | 25 | ; |
---|
| 26 | ; IDL> a=indgen(9) |
---|
| 27 | ; IDL> print, a |
---|
[2] | 28 | ; 0 1 2 3 4 5 6 7 8 |
---|
[231] | 29 | ; IDL> print, projsegment(a,[0,80]) |
---|
[2] | 30 | ; 0 10 20 30 40 50 60 70 80 |
---|
[231] | 31 | ; IDL> print, projsegment(a,[0,-80]) |
---|
[2] | 32 | ; 0 -10 -20 -30 -40 -50 -60 -70 -80 |
---|
[231] | 33 | ; IDL> print, projsegment(a,[-80,0]) |
---|
[2] | 34 | ; -80 -70 -60 -50 -40 -30 -20 -10 0 |
---|
| 35 | ; |
---|
[142] | 36 | ; @history |
---|
[157] | 37 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[2] | 38 | ; 24/6/1999 |
---|
[142] | 39 | ; |
---|
| 40 | ; @version |
---|
| 41 | ; $Id$ |
---|
| 42 | ; |
---|
| 43 | ;- |
---|
[327] | 44 | FUNCTION projsegment, vecteur, bornes, MP=mp |
---|
[114] | 45 | ; |
---|
| 46 | compile_opt idl2, strictarrsubs |
---|
| 47 | ; |
---|
[2] | 48 | a1 = float(vecteur[0]) |
---|
| 49 | b1 = float(vecteur[n_elements(vecteur)-1]) |
---|
| 50 | a2 = float(bornes[0]) |
---|
| 51 | b2 =float( bornes[1]) |
---|
| 52 | if a1 EQ b1 then return, -1 |
---|
| 53 | m = (b2-a2)/(b1-a1) |
---|
| 54 | p = a2-m*a1 |
---|
| 55 | ;-------------------------------------------------------------- |
---|
| 56 | if keyword_set(mp) then return, [m, p] ELSE return, m*vecteur+p |
---|
| 57 | ;-------------------------------------------------------------- |
---|
| 58 | end |
---|