source: trunk/SRC/ToBeReviewed/PLOTS/DIVERS/projsegment.pro @ 142

Last change on this file since 142 was 142, checked in by navarro, 18 years ago

english and nicer header (2a)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; project linearly a segment, a vector whose boundaries are [a,b] on
8; a vector whose boundaries are [c,d]
9;
10; @categories
11; calculation
12;
13; @param VECTEUR
14; A vector whose the first element must be the smallest one and the last must be the biggest one.
15;
16; @param BORNES
17; New boundaries of the vector.
18;
19; @keyword MP
20; Activate this keyword to the function send back this a vector of 2
21; elements which are the m and p of the linear projection y=mx+p used
22; to pass from the [a,b] segment to the [c,d] segment.
23;
24; @returns
25; A vector whose new boudaries are specified by BORNES.
26;
27; @examples
28;   
29;   IDL> a=indgen(9)
30;   IDL> print, a
31;          0       1       2       3       4       5       6       7       8
32;   IDL> print, projsegment(a,[0,80])
33;          0      10      20      30      40      50      60      70      80
34;   IDL> print, projsegment(a,[0,-80]) 
35;          0     -10     -20     -30     -40     -50     -60     -70     -80
36;   IDL> print, projsegment(a,[-80,0])   
37;        -80     -70     -60     -50     -40     -30     -20     -10      0
38;
39; @history
40; Sebastien Masson (smasson@lodyc.jussieu.fr)
41;                       24/6/1999
42;
43; @version
44; $Id$
45;
46;-
47;------------------------------------------------------------
48;------------------------------------------------------------
49;------------------------------------------------------------
50FUNCTION projsegment, vecteur, bornes, MP = mp
51;--------------------------------------------------------------
52;
53  compile_opt idl2, strictarrsubs
54;
55   a1 = float(vecteur[0])
56   b1 = float(vecteur[n_elements(vecteur)-1])
57   a2 = float(bornes[0])
58   b2 =float( bornes[1])
59   if a1 EQ b1 then return, -1
60   m = (b2-a2)/(b1-a1)
61   p = a2-m*a1
62;--------------------------------------------------------------
63   if keyword_set(mp) then return, [m, p] ELSE return, m*vecteur+p
64;--------------------------------------------------------------
65end
Note: See TracBrowser for help on using the repository browser.