Please enable JavaScript to view this site.

 

Navigation: Macros > Macro Language > Built-in Functions > All Functions

PlanetAtExtremalDistanceFromSun

Scroll Prev Up Next More

int = PlanetAtExtremalDistanceFromSun(nDate, nSunSourceIndex, nPlanetID)

 

This macro function calculates the time, on nDate, when the planet of planetary index nPlanetID is closest to, or furthest away from, the Sun.

 

The allowed values for nPlanetID range from n_MERCURY to n_PLUTO.

The sign of the result is positive if the planet is closest, and negative if the planet is furthest away on nDate. If the date nDate does not correspond to either case, then the function returns 0.

The absolute value of the result is the time of the day expressed in one millionth of a day (less than 1/10th of a second).

 

The macro code below checks if any of the planets, including Pluto, are closest to the Sun, or furthest from the Sun, on the date of the incoming macro token.

for nPlanetID = n_MERCURY to n_PLUTO step 1
    sBuffer = ''
    nCurResIdx = PlanetAtExtremalDistanceFromSun(n_TokenDate, 1, nPlanetID)
    if nCurResIdx > 0
       sBuffer = PlanetName(nPlanetID) + ' is at aphelion'
    endif
    if nCurResIdx < 0
       sBuffer = PlanetName(nPlanetID) + ' is at perihelion'
    endif
    // add the time it occurs in parentheses
    if nCurResIdx <> 0
       sBuffer = sBuffer + FormatTime('" ("hh:nn")"', Abs(nCurResIdx), true)
    endif
endfor

See also: PlanetAtExtremalDistance and planetary macro functions.

 


Topic 180005, last updated on 11-Sep-2020