1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include "../mwcs.h"
# MW_V2TRAN -- Optimized 2D coordinate transformation for an array of points.
procedure mw_v2tran$t (a_ct, x1,y1, x2,y2, npts)
pointer a_ct #I pointer to CTRAN descriptor
PIXEL x1[ARB],y1[ARB] #I coordinates in input system
PIXEL x2[ARB],y2[ARB] #O coordinates in output system
int npts
int i
pointer ct, ltm, ltv
PIXEL p1[2], p2[2]
errchk mw_ctran$t
begin
# Get real or double version of descriptor.
ct = CT_$T(a_ct)
ltm = CT_LTM(ct)
ltv = CT_LTV(ct)
if (CT_TYPE(ct) == LNR) {
# Simple linear, nonrotated transformation.
do i = 1, npts {
x2[i] = Mem$t[ltm ] * x1[i] + Mem$t[ltv ]
y2[i] = Mem$t[ltm+3] * y1[i] + Mem$t[ltv+1]
}
} else if (CT_TYPE(ct) == LRO) {
# Linear, rotated transformation.
do i = 1, npts {
p1[1] = x1[i]; p1[2] = y1[i]
x2[i] = Mem$t[ltm ] * p1[1] + Mem$t[ltm+1] * p2[1] +
Mem$t[ltv ]
y2[i] = Mem$t[ltm+2] * p1[1] + Mem$t[ltm+3] * p2[1] +
Mem$t[ltv+1]
}
} else {
# General case involving one or more functional terms.
do i = 1, npts {
p1[1] = x1[i]; p1[2] = y1[i]
call mw_ctran$t (a_ct, p1, p2, 2)
x2[i] = p2[1]; y2[i] = p2[2]
}
}
end
|