@@ -3105,67 +3105,57 @@ Vec3d StelCore::getMouseJ2000Pos() const
31053105 return mousePosition;
31063106}
31073107
3108- Vec3d StelCore::calculateParallaxDiff (double JD) {
3109- StelCore *core = StelApp::getInstance ().getCore ();
3110- Vec3d diffPos (0 ., 0 ., 0 .);
3111-
3112- static SolarSystem *ssystem=GETSTELMODULE (SolarSystem);
3113- const PlanetP earth = ssystem->getEarth ();
3114- // diff between earth's solar system bayrcentric location at STAR_CATALOG_JDEPOCH and current solar system bayrcentric location
3115- Vec3d earthPosCatalog = earth->getBarycentricEclipticPos (STAR_CATALOG_JDEPOCH);
3116- Vec3d PosNow = core->getCurrentPlanet ()->getBarycentricEclipticPos (JD);
3108+ Vec3d StelCore::calculateParallaxDiff (double JD) const {
3109+ // ICRS coordinates are barycentric (Gaia gives barycentric RA/DEC coordinates)
3110+ // diff between solar system bayrcentric location at STAR_CATALOG_JDEPOCH and current solar system bayrcentric location
3111+ Vec3d PosNow = getCurrentPlanet ()->getBarycentricEclipticPos (JD);
31173112 // Transform from heliocentric ecliptic to equatorial coordinates
3118- earthPosCatalog = matVsop87ToJ2000.upper3x3 () * earthPosCatalog;
3119- PosNow = matVsop87ToJ2000.upper3x3 () * PosNow;
3120- diffPos = earthPosCatalog - PosNow;
3121-
3122- return diffPos;
3113+ PosNow = matVsop87ToJ2000.upper3x3 () * -1 . * PosNow; // need to times -1 because technically it is doing (0,0,0) - PosNow
3114+ return PosNow;
31233115}
31243116
3125- const Vec3d StelCore::getParallaxDiff (double JD) {
3126- StelCore *core = StelApp::getInstance ().getCore ();
3127- if (fuzzyEquals (JD, cachedParallaxJD, JD_SECOND) && (core->getCurrentPlanet () == cachedParallaxPlanet))
3117+ Vec3d StelCore::getParallaxDiff (double JD) const {
3118+ if (fuzzyEquals (JD, cachedParallaxJD, JD_SECOND) && (getCurrentPlanet () == cachedParallaxPlanet))
31283119 {
31293120 return cachedParallaxDiff;
31303121 }
3131- cachedParallaxDiff = StelCore:: calculateParallaxDiff (JD);
3132- cachedParallaxJD = JD;
3133- cachedParallaxPlanet = core-> getCurrentPlanet ();
3122+ cachedParallaxDiff = calculateParallaxDiff (JD); // set the cache to the new value
3123+ cachedParallaxJD = JD; // set the cache to the new value
3124+ cachedParallaxPlanet = getCurrentPlanet ();
31343125 return cachedParallaxDiff;
31353126}
31363127
3137- Vec3d StelCore::calculateAberrationVec (double JD) {
3138- StelCore *core = StelApp::getInstance ().getCore ();
3128+ Vec3d StelCore::calculateAberrationVec (double JD) const {
31393129 // Solar system barycentric velocity
3140- Vec3d vel = core->getCurrentPlanet ()->getBarycentricEclipticVelocity ();
3130+ Q_UNUSED (JD);
3131+ Vec3d vel = getCurrentPlanet ()->getBarycentricEclipticVelocity ();
31413132 vel = StelCore::matVsop87ToJ2000 * vel * (AU/(86400.0 *SPEED_OF_LIGHT));
31423133 return vel;
31433134}
31443135
3145- const Vec3d StelCore::getAberrationVec (double JD) {
3146- StelCore *core = StelApp::getInstance ().getCore ();
3136+ Vec3d StelCore::getAberrationVec (double JD) const {
31473137 // need to recompute the aberration vector if the JD has changed or the planet has changed
3148- if (fuzzyEquals (JD, cachedAberrationJD, JD_SECOND) && (core-> getCurrentPlanet () == cachedAberrationPlanet))
3138+ if (fuzzyEquals (JD, cachedAberrationJD, JD_SECOND) && (getCurrentPlanet () == cachedAberrationPlanet))
31493139 {
3150- return core-> getAberrationFactor () * cachedAberrationVec;
3140+ return getAberrationFactor () * cachedAberrationVec;
31513141 }
3152- cachedAberrationVec = StelCore::calculateAberrationVec (JD);
3153- cachedAberrationJD = JD;
3154- cachedAberrationPlanet = core-> getCurrentPlanet ();
3155- return core-> getAberrationFactor () * cachedAberrationVec;
3142+ cachedAberrationVec = StelCore::calculateAberrationVec (JD); // set the cache to the new value
3143+ cachedAberrationJD = JD; // set the cache to the new value
3144+ cachedAberrationPlanet = getCurrentPlanet ();
3145+ return getAberrationFactor () * cachedAberrationVec;
31563146}
31573147
31583148QByteArray StelCore::getAberrationShader () const
31593149{
31603150 return 1 +R"(
3161- uniform vec3 STELCORE_currentPlanetHeliocentricEclipticVelocity ;
3151+ uniform vec3 STELCORE_currentPlanetBarycentricEclipticVelocity ;
31623152// objectDir points to the object as viewed from its comoving frame.
31633153// Return value represents the apparent direction to this object from a frame
31643154// that moves with respect to the object at slightly relativistic speeds (v<0.1c).
31653155// Relative error in aberration angle is about 0.5v/c.
31663156vec3 applyAberrationToObject(vec3 objectDir)
31673157{
3168- vec3 velocity = STELCORE_currentPlanetHeliocentricEclipticVelocity ;
3158+ vec3 velocity = STELCORE_currentPlanetBarycentricEclipticVelocity ;
31693159 return normalize(objectDir + velocity);
31703160}
31713161// viewDir is the direction where the object appears to be when viewed from a
@@ -3174,7 +3164,7 @@ vec3 applyAberrationToObject(vec3 objectDir)
31743164// Relative error in aberration angle is about 0.5v/c.
31753165vec3 applyAberrationToViewDir(vec3 viewDir)
31763166{
3177- vec3 velocity = STELCORE_currentPlanetHeliocentricEclipticVelocity ;
3167+ vec3 velocity = STELCORE_currentPlanetBarycentricEclipticVelocity ;
31783168 return normalize(viewDir - velocity);
31793169}
31803170)" ;
@@ -3185,14 +3175,11 @@ void StelCore::setAberrationUniforms(QOpenGLShaderProgram& program) const
31853175 Vec3d velocity;
31863176 if (getUseAberration ())
31873177 {
3188- const auto p = getCurrentPlanet ();
3189- const auto hev = p->getHeliocentricEclipticVelocity ();
3190- velocity = StelCore::matVsop87ToJ2000 * hev;
3191- velocity *= getAberrationFactor () * (AU/(86400.0 *SPEED_OF_LIGHT));
3178+ velocity = cachedAberrationVec;
31923179 }
31933180 else
31943181 {
31953182 velocity = Vec3d (0 ,0 ,0 );
31963183 }
3197- program.setUniformValue (" STELCORE_currentPlanetHeliocentricEclipticVelocity " , velocity.toQVector ());
3184+ program.setUniformValue (" STELCORE_currentPlanetBarycentricEclipticVelocity " , velocity.toQVector ());
31983185}
0 commit comments