summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tksao/frame/fitsimage.C12
-rw-r--r--tksao/util/util.C25
-rw-r--r--tksao/util/util.h2
3 files changed, 27 insertions, 12 deletions
diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C
index b78fd22..e6dc425 100644
--- a/tksao/frame/fitsimage.C
+++ b/tksao/frame/fitsimage.C
@@ -3149,7 +3149,7 @@ Vector FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys,
Vector out = wcsTran(ast_[ss], in, 1);
if (astOK && checkWCS(out))
- return wcsIsASkyFrame(ast_[ss]) ? radToDeg(out) : out;
+ return wcsIsASkyFrame(ast_[ss]) ? zero360(radToDeg(out)) : out;
else
return Vector();
}
@@ -3166,7 +3166,7 @@ Vector FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys,
Vector out = wcsTran(in, 1);
if (astOK && checkWCS(out))
- return hasWCSCel(sys) ? radToDeg(out) : out;
+ return hasWCSCel(sys) ? zero360(radToDeg(out)) : out;
else
return Vector();
}
@@ -3196,7 +3196,7 @@ char* FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys,
switch (format) {
case Coord::DEGREES:
- out = radToDeg(out);
+ out = zero360(radToDeg(out));
str << setprecision(context_->parent_->precDeg_)
<< out[0] << ' ' << out[1] << ' '
<< (hasWCSEqu(sys) ? coord.skyFrameStr(sky) : "") << ends;
@@ -3259,7 +3259,7 @@ char* FitsImage::pix2wcs(const Vector& in, Coord::CoordSystem sys,
switch (format) {
case Coord::DEGREES:
- out = radToDeg(out);
+ out = zero360(radToDeg(out));
str << setprecision(context_->parent_->precDeg_)
<< out[0] << ' ' << out[1] << ' '
<< (hasWCSEqu(sys) ? coord.skyFrameStr(sky) : "") << ends;
@@ -3314,7 +3314,7 @@ Vector3d FitsImage::pix2wcs(const Vector3d& in, Coord::CoordSystem sys,
Vector3d out = wcsTran(in, 1);
if (astOK && checkWCS(out))
- return hasWCSCel(sys) ? radToDeg(out) : out;
+ return hasWCSCel(sys) ? zero360(radToDeg(out)) : out;
else
return Vector3d();
}
@@ -3342,7 +3342,7 @@ char* FitsImage::pix2wcs(const Vector3d& in, Coord::CoordSystem sys,
switch (format) {
case Coord::DEGREES:
- out = radToDeg(out);
+ out = zero360(radToDeg(out));
str << setprecision(context_->parent_->precDeg_)
<< out[0] << ' ' << out[1] << ' ' << out[2]
<< ' ' << (hasWCSEqu(sys) ? coord.skyFrameStr(sky) : "") << ends;
diff --git a/tksao/util/util.C b/tksao/util/util.C
index 4770774..4bb2811 100644
--- a/tksao/util/util.C
+++ b/tksao/util/util.C
@@ -159,6 +159,22 @@ double zero360(double aa)
return rr;
}
+Vector zero360(const Vector& vv)
+{
+ Vector out = vv;
+ // we want the first coord to be 0-360
+ out[0] = zero360(out[0]);
+ return out;
+}
+
+Vector3d zero360(const Vector3d& vv)
+{
+ Vector out = vv;
+ // we want the first coord to be 0-360
+ out[0] = zero360(out[0]);
+ return out;
+}
+
double m180To180(double aa)
{
if (isnan(aa) || isinf(aa) || (aa == -DBL_MAX) || (aa == DBL_MAX))
@@ -173,15 +189,13 @@ double m180To180(double aa)
double radToDeg(double aa)
{
- double dd = 180.*aa/M_PI;
- return zero360(dd);
+ return 180.*aa/M_PI;
}
Vector radToDeg(const Vector& vv)
{
Vector out = vv;
- // we want the first coord to be 0-360
- out[0] = radToDeg(out[0]);
+ out[0] *= 180./M_PI;
out[1] *= 180./M_PI;
return out;
}
@@ -189,8 +203,7 @@ Vector radToDeg(const Vector& vv)
Vector3d radToDeg(const Vector3d& vv)
{
Vector3d out = vv;
- // we want the first coord to be 0-360
- out[0] = radToDeg(out[0]);
+ out[0] *= 180./M_PI;
out[1] *= 180./M_PI;
return out;
}
diff --git a/tksao/util/util.h b/tksao/util/util.h
index 5af2ee4..90e5d2d 100644
--- a/tksao/util/util.h
+++ b/tksao/util/util.h
@@ -94,10 +94,12 @@ extern double degToRad(double);
extern double radToDeg(double);
extern Vector zeroTWOPI(const Vector&);
+extern Vector zero360(const Vector&);
extern Vector degToRad(const Vector&);
extern Vector radToDeg(const Vector&);
extern Vector3d zeroTWOPI(const Vector3d&);
+extern Vector3d zero360(const Vector3d&);
extern Vector3d degToRad(const Vector3d&);
extern Vector3d radToDeg(const Vector3d&);