View Source Astrex.Common (Astrex v0.3.4)

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

Link to this section 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

Link to this section Functions

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

examples

Examples

iex> Astrex.Common.hours2hms(174.1234)
"174:07:24"
@spec deg2hours(float()) :: float()

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

@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)

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

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

examples

Examples

iex> Astrex.Common.hms2hours("12:33:31")
12.558611111111112
@spec hours2deg(float()) :: float()

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

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

examples

Examples

iex> Astrex.Common.hours2hms(12.5587)
"12:33:31"
@spec hours2rad(float()) :: float()

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:

  • system time if production
  • mock time is testing
@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

@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

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

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

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

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