Skip to main content

Class: AstroMath

Defined in: src/sdk/astro/AstroMath.ts:45

A utility class for working with astronomical calculations.

Constructors

Constructor

new AstroMath(): AstroMath

Returns

AstroMath

Methods

getSolarZenithAngle()

static getSolarZenithAngle(location, time): number

Defined in: src/sdk/astro/AstroMath.ts:165

Gets the solar zenith angle, in radians, at a particular location on the surface of the earth and time. The zenith angle is defined as the angle between the center of the solar disk and the vertical axis. The calculated angle is the true (geometric) zenith angle and does not include effects of atmospheric refraction.

For times between the years 1800 and 2200, the value returned by this method is accurate to within 85 arcseconds (~4.12e-4 radians).

Parameters

ParameterTypeDescription
locationFloat64Array<ArrayBufferLike> | LatLonInterfaceThe location at which to get the solar zenith angle, in either geocentric latitude/longitude coordinates or cartesian coordinates. Cartesian coordinates should be expressed in units of great-arc radians, with the origin at the center of the Earth, the positive x axis passing through 0 degrees N, 0 degrees E, and the positive z axis passing through the north pole.
timenumberThe time at which to get the solar zenith angle, as a Javascript timestamp.

Returns

number

The solar zenith angle, in radians, at the specified location and time.


getSubSolarPoint()

Call Signature

static getSubSolarPoint(time, out): LatLonInterface

Defined in: src/sdk/astro/AstroMath.ts:120

Gets the subsolar point (the point on Earth's surface directly below the Sun) given a specific time.

For times between the years 1800 and 2200, the value returned by this method is accurate to within one arcminute for each of latitude and longitude (giving a total angular error less than 85 arcseconds). The error's upper bound gradually increases as the time moves farther away from the 1800-2200 range.

Parameters
ParameterTypeDescription
timenumberThe time for which to get the subsolar point, as a Javascript timestamp.
outLatLonInterfaceThe LatLonInterface to which to write the result.
Returns

LatLonInterface

The subsolar point at the specified time, as geocentric latitude and longitude coordinates.

Call Signature

static getSubSolarPoint(time, out): Float64Array

Defined in: src/sdk/astro/AstroMath.ts:133

Gets the subsolar point (the point on Earth's surface directly below the Sun) given a specific time.

For times between the years 1800 and 2200, the value returned by this method is accurate to within 85 arcseconds of total angular error. The error's upper bound gradually increases as the time moves farther away from the 1800-2200 range.

Parameters
ParameterTypeDescription
timenumberThe time for which to get the subsolar point, as a Javascript timestamp.
outFloat64ArrayThe Float64Array to which to write the result.
Returns

Float64Array

The subsolar point at the specified time, as its cartesian representation assuming a spherical model of the earth, in units of great-arc radians. By convention, the origin is at the center of the Earth, the positive x axis passes through 0 degrees N, 0 degrees E, and the positive z axis passes through the north pole.


getSunriseAndSunsetTimes()

static getSunriseAndSunsetTimes(location, time, out, horizon): Float64Array

Defined in: src/sdk/astro/AstroMath.ts:223

Gets the times of sunrise and sunset across a certain horizon for a particular location on the surface of the earth. The sunrise and sunset times are chosen to be the pair associated with the solar transit (also known as local solar noon) closest to a specified time.

The sunrise and sunset times calculated by this method are accurate to within one minute. The transit time is accurate to within a few seconds.

Parameters

ParameterTypeDefault valueDescription
locationFloat64Array<ArrayBufferLike> | LatLonInterfaceundefinedThe location for which to get sunrise and sunset times, in either geocentric latitude/longitude coordinates or cartesian coordinates. Cartesian coordinates should be expressed in units of great-arc radians, with the origin at the center of the Earth, the positive x axis passing through 0 degrees N, 0 degrees E, and the positive z axis passing through the north pole.
timenumberundefinedA time used to specify which pair of sunrise/sunset times to calculate, as a Javascript timestamp. The calculated sunrise and sunset times will be the ones immediately before and after, respectively, the time of solar transit (also known as local solar noon) closest to the specified time.
outFloat64ArrayundefinedThe array to which to write the results.
horizonSunriseSunsetHorizonSunriseSunsetHorizon.DaylightThe horizon to use. Defaults to SunriseSunsetHorizon.Daylight.

Returns

Float64Array

The times of sunrise and sunset across the specified horizon associated with the solar transit closest to the specified time for the specified location, as a 3-tuple of Javascript timestamps [transit, sunrise, sunset] that are rounded to the nearest second. If the specified location is invalid, then [NaN, NaN, NaN] is returned. If the sun does not cross the horizon in the 24-hour period centered around the transit time, then the transit time is still returned, but NaN is returned for sunrise and sunset.

See

isSunAboveHorizon()


isSunAboveHorizon()

static isSunAboveHorizon(location, time, horizon): boolean

Defined in: src/sdk/astro/AstroMath.ts:190

Checks whether the sun is above a certain horizon at a particular location on the surface of the earth and time.

Parameters

ParameterTypeDefault valueDescription
locationFloat64Array<ArrayBufferLike> | LatLonInterfaceundefinedThe location to check, in either geocentric latitude/longitude coordinates or cartesian coordinates. Cartesian coordinates should be expressed in units of great-arc radians, with the origin at the center of the Earth, the positive x axis passing through 0 degrees N, 0 degrees E, and the positive z axis passing through the north pole.
timenumberundefinedThe time to check, as a Javascript timestamp.
horizonSunriseSunsetHorizonSunriseSunsetHorizon.DaylightThe horizon to use. Defaults to SunriseSunsetHorizon.Daylight.

Returns

boolean

Whether the sun is above the specified horizon at the specified location and time.

See