summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-09-28 22:15:03 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-09-29 02:20:27 (GMT)
commit5a978fde16329dd13d41b376b3f5042861642bfc (patch)
tree1d46dfb1baa8abb3c57805d13a30dc91f4e493de
parentb85333ab7c877f4dba627caf307a1f872240d39b (diff)
Revert "Experiment: Make Azimuth CachingDms"
This reverts commit d7bef9ce3d44067054d33793fd280f9f2d03cf84. The reason I'm reverting this is because it requires a lot more work than just what was done in the commit. The commit still produced lots and lots of bad cache uses.
-rw-r--r--kstars/auxiliary/cachingdms.h14
-rw-r--r--kstars/projections/projector.cpp31
-rw-r--r--kstars/skyobjects/skypoint.cpp12
-rw-r--r--kstars/skyobjects/skypoint.h6
4 files changed, 25 insertions, 38 deletions
diff --git a/kstars/auxiliary/cachingdms.h b/kstars/auxiliary/cachingdms.h
index 490ede2..4cc4c55 100644
--- a/kstars/auxiliary/cachingdms.h
+++ b/kstars/auxiliary/cachingdms.h
@@ -152,20 +152,6 @@ public:
void setUsing_acos( const double & cosine );
/**
- * @short Sets angle and trigonometric values
- */
- inline void setTrigonometric( double angleDegrees, double sine, double cosine ) {
- D = angleDegrees;
- m_sin = sine;
- m_cos = cosine;
-#ifdef COUNT_DMS_SINCOS_CALLS
- if(!m_cacheUsed)
- ++cachingdms_bad_uses;
- m_cacheUsed = false;
-#endif
- }
-
- /**
* @short Get the sine and cosine together
* @note Re-implements dms::SinCos()
* @note This just uses the cached values assuming that they are good
diff --git a/kstars/projections/projector.cpp b/kstars/projections/projector.cpp
index 68d29e1..f8e053d 100644
--- a/kstars/projections/projector.cpp
+++ b/kstars/projections/projector.cpp
@@ -24,7 +24,6 @@
#include "ksutils.h"
#include "kstarsdata.h"
#include "skycomponents/skylabeler.h"
-#include "auxiliary/cachingdms.h"
namespace {
void toXYZ(const SkyPoint* p, double *x, double *y, double *z) {
@@ -449,22 +448,22 @@ SkyPoint Projector::fromScreen(const QPointF& p, dms* LST, const dms* lat) const
Vector2f Projector::toScreenVec(const SkyPoint* o, bool oRefract, bool* onVisibleHemisphere) const
{
- CachingDms Y, dX;
+ double Y, dX;
double sindX, cosdX, sinY, cosY;
oRefract &= m_vp.useRefraction;
if ( m_vp.useAltAz ) {
if ( oRefract )
- Y = SkyPoint::refract( o->alt() ); //account for atmospheric refraction
+ Y = SkyPoint::refract( o->alt() ).radians(); //account for atmospheric refraction
else
- Y = o->alt();
- dX = m_vp.focus->az() - o->az(); // CachingDms - operator
+ Y = o->alt().radians();
+ dX = m_vp.focus->az().radians() - o->az().radians();
} else {
- dX = o->ra() - m_vp.focus->ra(); // CachingDms - operator
- Y = o->dec();
+ dX = o->ra().radians() - m_vp.focus->ra().radians();
+ Y = o->dec().radians();
}
- if( !( std::isfinite( Y.Degrees() ) && std::isfinite( dX.Degrees() ) ) ) {
+ if( !( std::isfinite( Y ) && std::isfinite( dX ) ) ) {
qDebug() << "Assert in Projector::toScreenVec failed!";
qDebug() << "using AltAz?" << m_vp.useAltAz << " Refract? " << oRefract;
const SkyObject *obj;
@@ -472,18 +471,22 @@ Vector2f Projector::toScreenVec(const SkyPoint* o, bool oRefract, bool* onVisibl
if ( (obj = dynamic_cast<const SkyObject *>(o) ) ) {
qDebug() << "Point is object with name = " << obj->name() << " longname = " << obj->longname();
}
- qDebug() << "dX = " << dX.Degrees() << " and isfinite(dX) is" << std::isfinite(dX.Degrees());
- qDebug() << "Y = " << Y.Degrees() << " and isfinite(Y) is" << std::isfinite(Y.Degrees());
+ qDebug() << "dX = " << dX << " and isfinite(dX) is" << std::isfinite(dX);
+ qDebug() << "Y = " << Y << " and isfinite(Y) is" << std::isfinite(Y);
return Vector2f(0,0);
//Q_ASSERT( false );
}
-// dX = KSUtils::reduceAngle(dX, -dms::PI, dms::PI);
- dX.reduceToRange( dms::MINUSPI_TO_PI );
+ dX = KSUtils::reduceAngle(dX, -dms::PI, dms::PI);
//Convert dX, Y coords to screen pixel coords, using GNU extension if available
- dX.SinCos( sindX, cosdX );
- Y.SinCos( sinY, cosY );
+ #if ( __GLIBC__ >= 2 && __GLIBC_MINOR__ >=1 )
+ sincos( dX, &sindX, &cosdX );
+ sincos( Y, &sinY, &cosY );
+ #else
+ sindX = sin(dX); cosdX = cos(dX);
+ sinY = sin(Y); cosY = cos(Y);
+ #endif
//c is the cosine of the angular distance from the center
double c = m_sinY0*sinY + m_cosY0*cosY*cosdX;
diff --git a/kstars/skyobjects/skypoint.cpp b/kstars/skyobjects/skypoint.cpp
index 4f75cde..6f9ae9a 100644
--- a/kstars/skyobjects/skypoint.cpp
+++ b/kstars/skyobjects/skypoint.cpp
@@ -72,7 +72,7 @@ void SkyPoint::EquatorialToHorizontal( const CachingDms *LST, const CachingDms *
std::clock_t start = std::clock();
#endif
//Uncomment for spherical trig version
- double AltRad;
+ double AltRad, AzRad;
double sindec, cosdec, sinlat, coslat, sinHA, cosHA;
double sinAlt, cosAlt;
@@ -89,14 +89,14 @@ void SkyPoint::EquatorialToHorizontal( const CachingDms *LST, const CachingDms *
cosAlt = sqrt( 1 - sinAlt * sinAlt ); // Avoid trigonometric function. Return value of asin is always in [-pi/2, pi/2] and in this domain cosine is always non-negative, so we can use this.
double arg = ( sindec - sinlat*sinAlt )/( coslat*cosAlt );
- if ( arg <= -1.0 ) Az.setTrigonometric( 180., 0., -1. );
- else if ( arg >= 1.0 ) Az.setTrigonometric( 0., 0., 1. );
- else Az.setUsing_acos( arg );
+ if ( arg <= -1.0 ) AzRad = dms::PI;
+ else if ( arg >= 1.0 ) AzRad = 0.0;
+ else AzRad = acos( arg );
- if ( sinHA > 0.0 ) Az.setTrigonometric( 360. - Az.Degrees(), -Az.sin(), Az.cos() ); // resolve acos() ambiguity
+ if ( sinHA > 0.0 ) AzRad = 2.0*dms::PI - AzRad; // resolve acos() ambiguity
Alt.setRadians( AltRad );
-
+ Az.setRadians( AzRad );
#ifdef PROFILE_COORDINATE_CONVERSION
std::clock_t stop = std::clock();
cpuTime_EqToHz += double( stop - start )/double( CLOCKS_PER_SEC ); // Accumulate time in seconds
diff --git a/kstars/skyobjects/skypoint.h b/kstars/skyobjects/skypoint.h
index 586b1a8..e9e4b63 100644
--- a/kstars/skyobjects/skypoint.h
+++ b/kstars/skyobjects/skypoint.h
@@ -171,8 +171,6 @@ public:
*/
inline void setAz( dms az ) { Az = az; }
- inline void setAz( const CachingDms &az ) { Az = az; }
-
/** Overloaded member function, provided for convenience.
*It behaves essentially like the above function.
*@param az Azimuth, expressed as a double.
@@ -196,7 +194,7 @@ public:
inline const CachingDms& dec() const { return Dec; }
/** @return a pointer to the current Azimuth. */
- inline const CachingDms& az() const { return Az; }
+ inline const dms& az() const { return Az; }
/** @return a pointer to the current Altitude. */
inline const dms& alt() const { return Alt; }
@@ -577,7 +575,7 @@ protected:
private:
CachingDms RA0, Dec0; //catalog coordinates
CachingDms RA, Dec; //current true sky coordinates
- CachingDms Az; dms Alt; // Altitude is dms because it undergoes refraction
+ dms Alt, Az;
static KSSun *m_Sun;
protected:
double lastPrecessJD; // JD at which the last coordinate update (see updateCoords) for this SkyPoint was done