Loading...
Searching...
No Matches
util.c File Reference

Various commonly used routines used throughout the SuperNOVAS library. More...

## Functions

double | d_light (const double *pos_src, const double *pos_body)
| Returns the difference in light-time, for a star, between the barycenter of the solar system and the observer (or the geocenter) (Usage A).
PROTECTED void | novas_debug (enum novas_debug_mode mode)
| Enables or disables reporting errors and traces to the standard error stream.
double | novas_equ_sep (double ra1, double dec1, double ra2, double dec2)
| Returns the angular separation of two equatorial locations on a sphere.
enum novas_debug_mode | novas_get_debug_mode ()
| Returns the current, thread-local, mode for reporting errors encountered (and traces).
double | novas_norm_ang (double angle)
| Returns the normalized angle in the [0:2π) range.
int | novas_print_dms (double degrees, enum novas_separator_type sep, int decimals, char *restrict buf, int len)
| Prints an angle in degrees as [-]ddd:mm:ss[.S...] into the specified buffer, with up to nanosecond precision.
int | novas_print_hms (double hours, enum novas_separator_type sep, int decimals, char *restrict buf, int len)
| Prints a time in hours as hh:mm:ss[.S...] into the specified buffer, with up to nanosecond precision.
double | novas_sep (double lon1, double lat1, double lon2, double lat2)
| Returns the angular separation of two locations on a sphere.
double | novas_vlen (const double *restrict v)
| (for internal use only) Calculates the length of a 3-vector
int | radec2vector (double ra, double dec, double dist, double *restrict pos)
| Converts equatorial spherical coordinates to a vector (equatorial rectangular coordinates).
int | spin (double angle, const double *in, double *out)
| Transforms a vector from one coordinate system to another with same origin and axes rotated about the z-axis.
short | vector2radec (const double *restrict pos, double *restrict ra, double *restrict dec)
| Converts an vector in equatorial rectangular coordinates to equatorial spherical coordinates.

## Variables

int | novas_inv_max_iter = 100
| Maximum number of iterations for convergent inverse calculations.

## Detailed Description

Various commonly used routines used throughout the SuperNOVAS library.

Date
  Created on Mar 6, 2025

Author
  G. Kaplan and Attila Kovacs

## Function Documentation

## d_light()

double d_light | ( | const double * | pos_src,
|  | const double * | pos_body )

Returns the difference in light-time, for a star, between the barycenter of the solar system and the observer (or the geocenter) (Usage A).

Alternatively (Usage B), this function returns the light-time from the observer (or the geocenter) to a point on a light ray that is closest to a specific solar system body. For this purpose, 'pos_src' is the position vector toward observed object, with respect to origin at observer (or the geocenter); 'pos_body' is the position vector of solar system body, with respect to origin at observer (or the geocenter), components in AU; and the returned value is the light time to point on line defined by 'pos' that is closest to solar system body (positive if light passes body before hitting observer, i.e., if 'pos_body' is within 90 degrees of 'pos_src').

NOTES:

1. This function is called by novas_geom_posvel(), novas_sky_pos(), or place()

Parameters

  pos_src | Position vector towards observed object, with respect to the SSB (Usage A), or relative to the observer / geocenter (Usage B).
  pos_body | [AU] Position of observer relative to SSB (Usage A), or position of intermediate solar-system body with respect to the observer / geocenter (Usage B).

Returns
  [day] Difference in light time to observer, either relative to SSB (Usage A) or relative intermediate solar-system body (Usage B); or else NAN if either of the input arguments is NULL.

See also
  novas_sky_pos(), novas_geom_posvel()

References novas_vlen().

## novas_vlen()

double novas_vlen | ( | const double *restrict | v | ) |

(for internal use only) Calculates the length of a 3-vector

Parameters

  v | Pointer to a 3-component (x, y, z) vector. The argument cannot be NULL

Returns
  the length of the vector

Since
  1.0

Author
  Attila Kovacs

See also
  novas_vdot(), novas_vdist()

## Variable Documentation

## novas_inv_max_iter

int novas_inv_max_iter = 100

Maximum number of iterations for convergent inverse calculations.

Most iterative inverse functions should normally converge in a handful of iterations. In some pathological cases more iterations may be required. This variable sets an absolute maximum for the number of iterations in order to avoid runaway (zombie) behaviour. If inverse functions fail to converge, they will return a value indicating an error, and errno should be set to ECANCELED.

Since
  1.1