Find next Mars/Jupiter/Saturn retrograde

This Stellarium script will find the next time Mars, Jupiter, and Saturn all retrograde at the same time.

// ******************************************************************************************
// Stellarium script to quickly determine when Mars is retrograding between Jupiter and
// Saturn, while they, themselves, are retrograding. It is brain-dead boring tedium,
// watching the screen for long periods to 'notice' this event. Stellarium's scripting
// takes the tedium out of the effort.
//
// Created by David O'Neil, Aug, 2019. Released to the public domain, for anyone interested.
// Just leave this 'created by' (or 'originally created by') verbage in the derived work.
//
// To use:
//   * set the date via Stellarium's user interface
//   * set the 'daysToAdvance' variable to whatever day step you want. Too big of a step may
//     cause you to miss the retrograde event.
//   * You might want to change the 'core.wait(0.03);' line to another number, based on your
//     computer's capabilities. You will know quickly enough, because no matter what start
//     date you set, the script will never advance more than one step because Stellarium is
//     retrieving the old values in it's 'getObjectInfo' routines.
// ******************************************************************************************


//Setup and global variables:
core.selectObjectByName("Mars", false);
//core.selectObjectByName("Saturn", false);
StelMovementMgr.setFlagTracking(true);

daysToAdvance = -5;   //Can be positive or negative. Change to your purposes.

daysToAdvanceString = "";  //Stellarium doesn't re-zero things on subsequent runs.
if (daysToAdvance > 0) daysToAdvanceString = "+";
//else daysToAdvanceString = "-";   //not needed. Script core keeps as '-5'
daysToAdvanceString = daysToAdvanceString + daysToAdvance + " days";

//core.debug(daysToAdvanceString);

saturnRA = core.getObjectInfo("Saturn").ra;
jupiterRA = core.getObjectInfo("Jupiter").ra;
marsRA = core.getObjectInfo("Mars").ra;

if (daysToAdvance > 0) {
   saturnDirection = 1.0;
   jupiterDirection = 1.0;
   marsDirection = 1.0;
   }
else {
   saturnDirection = -1.0;
   jupiterDirection = -1.0;
   marsDirection = -1.0;
   }

core.setGuiVisible (false);

findNextPushingPillarsEvent();

// ******************************************************************************************
//That is the end of this script.
// ******************************************************************************************


//The following are the functions used in this script:

function findNextPushingPillarsEvent() {
   if (daysToAdvance > 0) moveForward();
   else moveBackward();
   }


function moveForward() {
   allThreeMovingBackWithMarsBetween = false;
   marsIsGreatestDiff = false;

   while (!allThreeMovingBackWithMarsBetween) {
      core.setDate(daysToAdvanceString);
      core.wait(0.03);

      newSaturnRA = core.getObjectInfo("Saturn").ra;
      saturnDirection = newSaturnRA - saturnRA;
      if (saturnDirection < -350) {
         saturnDirection = 360 - saturnDirection;
         }

      newJupiterRA = core.getObjectInfo("Jupiter").ra;
      jupiterDirection = newJupiterRA - jupiterRA;
      if (jupiterDirection < -350) {
         jupiterDirection = 360 - jupiterDirection;
         }

      newMarsRA = core.getObjectInfo("Mars").ra;
      marsDirection = newMarsRA - marsRA;
      if (marsDirection < -350) {
         marsDirection = 360 - marsDirection;
         }

      saturnRA = newSaturnRA;
      jupiterRA = newJupiterRA;
      marsRA = newMarsRA;
      //core.debug("S: " + saturnDirection);
      //core.debug("J: " + jupiterDirection);
      //core.debug("M: " + marsDirection);
      if (marsDirection < 0.0 && saturnDirection < 0.0 && jupiterDirection < 0.0) {
         allThreeMovingBackWithMarsBetween = true;
         }
      if (allThreeMovingBackWithMarsBetween) {
         jupSatDiff = Math.abs(newSaturnRA - newJupiterRA);
         if (jupSatDiff > 180) jupSatDiff = 360 - jupSatDiff;
         //core.debug(jupSatDiff);
         marsSatDiff = Math.abs(newSaturnRA - newMarsRA);
         if (marsSatDiff > 180) marsSatDiff = 360 - marsSatDiff;
         //core.debug(marsSatDiff);
         marsJupDiff = Math.abs(newJupiterRA - newMarsRA);
         if (marsJupDiff > 180) marsJupDiff = 360 - marsJupDiff;
         //core.debug(marsJupDiff);
         
         if ((marsJupDiff > jupSatDiff) || (marsSatDiff > jupSatDiff)) {
            //core.debug("Entered!");
            marsIsGreatestDiff = true;
            allThreeMovingBackWithMarsBetween = false;
            }
         }
      }
   }
   

function moveBackward() {
   allThreeMovingForwardWithMarsBetween = false;
   marsIsGreatestDiff = false;

   while (!allThreeMovingForwardWithMarsBetween) {
      core.setDate(daysToAdvanceString);
      core.wait(0.03);

      newSaturnRA = core.getObjectInfo("Saturn").ra;
      saturnDirection = newSaturnRA - saturnRA;
      if (saturnDirection > 350) {
         saturnDirection = 360 - saturnDirection;
         }

      newJupiterRA = core.getObjectInfo("Jupiter").ra;
      jupiterDirection = newJupiterRA - jupiterRA;
      if (jupiterDirection > 350) {
         jupiterDirection = 360 - jupiterDirection;
         }
         
      newMarsRA = core.getObjectInfo("Mars").ra;
      marsDirection = newMarsRA - marsRA;
      if (marsDirection > 350) {
         marsDirection = 360 - marsDirection;
         }
         
      saturnRA = newSaturnRA;
      jupiterRA = newJupiterRA;
      marsRA = newMarsRA;

      // core.debug("saturnRA: " + saturnRA);
      // core.debug("newSaturnRA: " + newSaturnRA);
      //core.debug("saturnDirection: " + saturnDirection);
      
      if (marsDirection > 0.0 && saturnDirection > 0.0 && jupiterDirection > 0.0) {
         allThreeMovingForwardWithMarsBetween = true;
         }
      if (allThreeMovingForwardWithMarsBetween) {
         jupSatDiff = Math.abs(newSaturnRA - newJupiterRA);
         if (jupSatDiff > 180) jupSatDiff = 360 - jupSatDiff;
         //core.debug(jupSatDiff);
         marsSatDiff = Math.abs(newSaturnRA - newMarsRA);
         if (marsSatDiff > 180) marsSatDiff = 360 - marsSatDiff;
         //core.debug(marsSatDiff);
         marsJupDiff = Math.abs(newJupiterRA - newMarsRA);
         if (marsJupDiff > 180) marsJupDiff = 360 - marsJupDiff;
         //core.debug(marsJupDiff);
         
         if ((marsJupDiff > jupSatDiff) || (marsSatDiff > jupSatDiff)) {
            //core.debug("Entered!");
            marsIsGreatestDiff = true;
            allThreeMovingForwardWithMarsBetween = false;
            }
         }
      }
   }

Archives by Subject:

Tag cloud:

C++ Code Constellations Leo Cemetery Prostitution Radiation Supernova Astrology Chinese Medicine Acupuncture Undo/Redo Microsoft Word Website stuff PHP Cultural Interactions Software by others

Archives by Month: