Commit 5a978fde authored by Akarsh Simha's avatar Akarsh Simha
Browse files

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.
parent b85333ab
......@@ -151,20 +151,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()
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment