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

Last change on this file since 231 was 231, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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