Astrex.Common (Astrex v0.4.1)

View Source

Common utilities to facilitate the astronomical calculations

  • unit conversions: hours, degrees, angles
  • normalizations within 360°, 2PI, 24 hours
  • conversion from hour:minutes:seconds to hours and back
  • conversion from degree:minutes:seconds to degrees and back

Summary

Functions

formats an angle from degrees to a string "dd:mm:ss"

converts an angle expressed in degrees to an angle expressed in hours

Converts a "dd:mm:ss" string to degrees Receives the angle in d° m' s" as a binary string Returns the angle in DEGREES (float)

Converts a "hh:mm:ss" string to hours receives a binary string returns HOURS in float format

converts an angle expressed in hours to an angle expressed in degrees

formats an hour from hours to a string "hh:mm:ss"

converts an angle expressed in hours to an angle expressed in radians

Converts all values of a map from radians to degrees.

Converts all values of a map from degrees to radians.

returns the current time

Normalizes an angle into the range 0-2 pi Receives the angle in RADIANS Returns the normalized angle in RADIANS

Normalizes an hour angle into the range 0-24 hours Receives the angle in HOURS Returns the normalized angle in HOURS

Normalizes an angle into the range 0°-360° Receives the angle in DEGREES Returns the normalized angle in DEGREES

converts an angle expressed in radians to an angle expressed in hours

Functions

deg2dms(d)

formats an angle from degrees to a string "dd:mm:ss"

Examples

iex> Astrex.Common.hours2hms(174.1234)
"174:07:24"

deg2hours(deg)

@spec deg2hours(float()) :: float()

converts an angle expressed in degrees to an angle expressed in hours

dms2deg(angle)

@spec dms2deg(binary()) :: float()

Converts a "dd:mm:ss" string to degrees Receives the angle in d° m' s" as a binary string Returns the angle in DEGREES (float)

hms2hours(angle)

@spec hms2hours(binary()) :: float()

Converts a "hh:mm:ss" string to hours receives a binary string returns HOURS in float format

Examples

iex> Astrex.Common.hms2hours("12:33:31")
12.558611111111112

hours2deg(hours)

@spec hours2deg(float()) :: float()

converts an angle expressed in hours to an angle expressed in degrees

hours2hms(h)

formats an hour from hours to a string "hh:mm:ss"

Examples

iex> Astrex.Common.hours2hms(12.5587)
"12:33:31"

hours2rad(hours)

@spec hours2rad(float()) :: float()

converts an angle expressed in hours to an angle expressed in radians

map2deg(map)

Converts all values of a map from radians to degrees.

map2rad(map)

Converts all values of a map from degrees to radians.

ndt_now()

returns the current time:

  • system time if production
  • mock time is testing

norm_2pi(a)

@spec norm_2pi(float()) :: float()

Normalizes an angle into the range 0-2 pi Receives the angle in RADIANS Returns the normalized angle in RADIANS

norm_24h(a)

@spec norm_24h(float()) :: float()

Normalizes an hour angle into the range 0-24 hours Receives the angle in HOURS Returns the normalized angle in HOURS

norm_360(a)

@spec norm_360(float()) :: float()

Normalizes an angle into the range 0°-360° Receives the angle in DEGREES Returns the normalized angle in DEGREES

rad2hours(rad)

@spec rad2hours(float()) :: float()

converts an angle expressed in radians to an angle expressed in hours