1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ; |
---|
5 | ; NAME: check_inside.pro |
---|
6 | ; |
---|
7 | ; PURPOSE: Find in which grid cell stands a given longitude/latitude position |
---|
8 | ; |
---|
9 | ; CATEGORY : Subroutine |
---|
10 | ; |
---|
11 | ; CALLING SEQUENCE : pro check_inside, xx,yy,zz, x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,result |
---|
12 | ; |
---|
13 | ; INPUTS : |
---|
14 | ; xx,yy,zz : cartesian coordinates of P the point that has to be located |
---|
15 | ; in grid. |
---|
16 | ; x1,y1,z1 : coordinates of A point of grid (See |
---|
17 | ; documentation) |
---|
18 | ; x2,y2,z2 : coordinates of B point of grid (See |
---|
19 | ; documentation) |
---|
20 | ; x3,y3,z3 : coordinates of C point of grid (See |
---|
21 | ; documentation) |
---|
22 | ; x4,y4,z4 : coordinates of D point of grid (See |
---|
23 | ; documentation) |
---|
24 | ; OUTPUTS : |
---|
25 | ; result : location of the P point in grid |
---|
26 | ; COMMON BLOCKS: |
---|
27 | ; None |
---|
28 | ; |
---|
29 | ; SIDE EFFECTS: |
---|
30 | ; |
---|
31 | ; RESTRICTIONS: |
---|
32 | ; |
---|
33 | ; EXAMPLE: |
---|
34 | ; |
---|
35 | ; MODIFICATION HISTORY: 08/2002 Robinson Hordoir |
---|
36 | ; |
---|
37 | ;------------------------------------------------------------ |
---|
38 | ;------------------------------------------------------------ |
---|
39 | ;------------------------------------------------------------ |
---|
40 | |
---|
41 | pro check_inside, xx,yy,zz, x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,result |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | ABx=x2-x1 |
---|
46 | ABy=y2-y1 |
---|
47 | |
---|
48 | BPx=xx-x2 |
---|
49 | BPy=yy-y2 |
---|
50 | BPz=zz-z2 |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | AB_Vect_BP=ABx*BPy-BPx*ABy |
---|
55 | BP=sqrt(BPx*BPx+BPy*BPy+BPz*BPz) |
---|
56 | |
---|
57 | |
---|
58 | BCx=x3-x2 |
---|
59 | BCy=y3-y2 |
---|
60 | |
---|
61 | CPx=xx-x3 |
---|
62 | CPy=yy-y3 |
---|
63 | CPz=zz-z3 |
---|
64 | |
---|
65 | |
---|
66 | BC_Vect_CP=BCx*CPy-BCy*CPx |
---|
67 | CP=sqrt(CPx*CPx+CPy*CPy+CPz*CPz) |
---|
68 | |
---|
69 | CDx=x4-x3 |
---|
70 | CDy=y4-y3 |
---|
71 | |
---|
72 | DPx=xx-x4 |
---|
73 | DPy=yy-y4 |
---|
74 | DPz=zz-z4 |
---|
75 | |
---|
76 | |
---|
77 | CD_Vect_DP=CDx*DPy-CDy*DPx |
---|
78 | DP=sqrt(DPx*DPx+DPy*DPy+DPz*DPz) |
---|
79 | |
---|
80 | DAx=x1-x4 |
---|
81 | DAy=y1-y4 |
---|
82 | |
---|
83 | APx=xx-x1 |
---|
84 | APy=yy-y1 |
---|
85 | APz=zz-z1 |
---|
86 | |
---|
87 | DA_Vect_AP=DAx*APy-DAy*APx |
---|
88 | AP=sqrt(APx*APx+APy*APy+APz*APz) |
---|
89 | |
---|
90 | Dist=AP+BP+CP+DP |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | result= where( ( (AB_Vect_BP LE 0.) AND (BC_Vect_CP LE 0.) AND (CD_Vect_DP LE 0.) AND (DA_Vect_AP LE 0.) ) OR $ |
---|
95 | ( (AB_Vect_BP GE 0.) AND (BC_Vect_CP GE 0.) AND (CD_Vect_DP GE 0.) AND (DA_Vect_AP GE 0.) ) ) |
---|
96 | |
---|
97 | |
---|
98 | |
---|
99 | Dist_result=Dist(result) |
---|
100 | |
---|
101 | min_dist=where(Dist_result EQ min(Dist_result)) |
---|
102 | |
---|
103 | result=result(min_dist) |
---|
104 | |
---|
105 | |
---|
106 | end |
---|