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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// Copyright (C) 1999-2018
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"
#include "context.h"
#include "framebase.h"
#include "fitsimage.h"
double Base::mapAngleFromRef(double angle, Coord::CoordSystem sys,
Coord::SkyFrame sky)
{
double rr = angle;
FitsImage* ptr = currentContext->cfits;
if (!ptr)
return 0;
switch (sys) {
case Coord::IMAGE:
case Coord::PHYSICAL:
case Coord::DETECTOR:
case Coord::AMPLIFIER:
break;
default:
if (hasWCSCel(sys))
rr += ptr->getWCSRotation(sys,sky);
else {
Coord::Orientation oo = keyContext->fits->getWCSOrientation(sys, sky);
if (oo==Coord::XX) {
rr = -(angle + ptr->getWCSRotation(sys,sky) + M_PI);
}
}
break;
}
return zeroTWOPI(rr);
}
double Base::mapAngleToRef(double angle, Coord::CoordSystem sys,
Coord::SkyFrame sky)
{
double rr = angle;
FitsImage* ptr = currentContext->cfits;
if (!ptr)
return 0;
switch (sys) {
case Coord::IMAGE:
case Coord::PHYSICAL:
case Coord::DETECTOR:
case Coord::AMPLIFIER:
break;
default:
if (hasWCSCel(sys))
rr -= ptr->getWCSRotation(sys,sky);
else {
Coord::Orientation oo = keyContext->fits->getWCSOrientation(sys, sky);
if (oo==Coord::XX) {
rr = -(angle + ptr->getWCSRotation(sys,sky) + M_PI);
}
}
break;
}
return zeroTWOPI(rr);
}
Vector FrameBase::mapFromRef(const Vector& vv, Coord::InternalSystem sys)
{
switch (sys) {
case Coord::REF:
return vv;
case Coord::USER:
return vv * refToUser;
case Coord::WIDGET:
return vv * refToWidget;
case Coord::CANVAS:
return vv * refToCanvas;
case Coord::WINDOW:
return vv * refToWindow;
case Coord::PANNER:
return vv * refToPanner;
case Coord::MAGNIFIER:
return vv * refToMagnifier;
case Coord::PS:
// should not happen
return Vector();
}
}
Vector FrameBase::mapToRef(const Vector& vv, Coord::InternalSystem sys)
{
switch (sys) {
case Coord::REF:
return vv;
case Coord::USER:
return vv * userToRef;
case Coord::WIDGET:
return vv * widgetToRef;
case Coord::CANVAS:
return vv * canvasToRef;
case Coord::WINDOW:
return vv * windowToRef;
case Coord::PANNER:
return vv * pannerToRef;
case Coord::MAGNIFIER:
return vv * magnifierToRef;
case Coord::PS:
// should not happen
return Vector();
}
}
|