Fixed #131 - Added phase_fraction in C, C#.

The C and C# Illumination functions now return
a `phase_fraction` result to complement `phase_angle`.
This makes them consistent with the Python and JavaScript
versions.
This commit is contained in:
Don Cross
2021-11-05 20:27:58 -04:00
parent 3f788aaaee
commit 45ea0ea113
7 changed files with 15 additions and 0 deletions

View File

@@ -466,6 +466,7 @@ static astro_illum_t IllumError(astro_status_t status)
result.time = TimeError();
result.mag = NAN;
result.phase_angle = NAN;
result.phase_fraction = NAN;
result.helio_dist = NAN;
result.ring_tilt = NAN;
@@ -5364,6 +5365,7 @@ astro_illum_t Astronomy_Illumination(astro_body_t body, astro_time_t time)
illum.time = time;
illum.mag = mag;
illum.phase_angle = phase.angle;
illum.phase_fraction = (1.0 + cos(DEG2RAD * phase.angle)) / 2.0;
illum.helio_dist = helio_dist;
illum.ring_tilt = ring_tilt;

View File

@@ -1358,6 +1358,9 @@ namespace CosineKitty
/// <summary>The angle in degrees between the Sun and the Earth, as seen from the body. Indicates the body's phase as seen from the Earth.</summary>
public readonly double phase_angle;
/// <summary>A value in the range [0.0, 1.0] indicating what fraction of the body's apparent disc is illuminated, as seen from the Earth.</summary>
public readonly double phase_fraction;
/// <summary>The distance between the Sun and the body at the observation time.</summary>
public readonly double helio_dist;
@@ -1369,6 +1372,7 @@ namespace CosineKitty
this.time = time;
this.mag = mag;
this.phase_angle = phase_angle;
this.phase_fraction = (1.0 + Math.Cos(Astronomy.DEG2RAD * phase_angle)) / 2.0;
this.helio_dist = helio_dist;
this.ring_tilt = ring_tilt;
}

View File

@@ -3252,6 +3252,7 @@ Returned by the functions [`Astronomy_Illumination`](#Astronomy_Illumination) an
| [`astro_time_t`](#astro_time_t) | `time` | The date and time of the observation. |
| `double` | `mag` | The visual magnitude of the body. Smaller values are brighter. |
| `double` | `phase_angle` | The angle in degrees between the Sun and the Earth, as seen from the body. Indicates the body's phase as seen from the Earth. |
| `double` | `phase_fraction` | A value in the range [0.0, 1.0] indicating what fraction of the body's apparent disc is illuminated, as seen from the Earth. |
| `double` | `helio_dist` | The distance between the Sun and the body at the observation time. |
| `double` | `ring_tilt` | For Saturn, the tilt angle in degrees of its rings as seen from Earth. For all other bodies, 0. |

View File

@@ -466,6 +466,7 @@ static astro_illum_t IllumError(astro_status_t status)
result.time = TimeError();
result.mag = NAN;
result.phase_angle = NAN;
result.phase_fraction = NAN;
result.helio_dist = NAN;
result.ring_tilt = NAN;
@@ -6590,6 +6591,7 @@ astro_illum_t Astronomy_Illumination(astro_body_t body, astro_time_t time)
illum.time = time;
illum.mag = mag;
illum.phase_angle = phase.angle;
illum.phase_fraction = (1.0 + cos(DEG2RAD * phase.angle)) / 2.0;
illum.helio_dist = helio_dist;
illum.ring_tilt = ring_tilt;

View File

@@ -573,6 +573,7 @@ typedef struct
astro_time_t time; /**< The date and time of the observation. */
double mag; /**< The visual magnitude of the body. Smaller values are brighter. */
double phase_angle; /**< The angle in degrees between the Sun and the Earth, as seen from the body. Indicates the body's phase as seen from the Earth. */
double phase_fraction; /**< A value in the range [0.0, 1.0] indicating what fraction of the body's apparent disc is illuminated, as seen from the Earth. */
double helio_dist; /**< The distance between the Sun and the body at the observation time. */
double ring_tilt; /**< For Saturn, the tilt angle in degrees of its rings as seen from Earth. For all other bodies, 0. */
}

View File

@@ -2181,6 +2181,7 @@ to report the visual magnitude and illuminated fraction of a celestial body at a
| [`AstroTime`](#AstroTime) | `time` | The date and time of the observation. |
| `double` | `mag` | The visual magnitude of the body. Smaller values are brighter. |
| `double` | `phase_angle` | The angle in degrees between the Sun and the Earth, as seen from the body. Indicates the body's phase as seen from the Earth. |
| `double` | `phase_fraction` | A value in the range [0.0, 1.0] indicating what fraction of the body's apparent disc is illuminated, as seen from the Earth. |
| `double` | `helio_dist` | The distance between the Sun and the body at the observation time. |
| `double` | `ring_tilt` | For Saturn, the tilt angle in degrees of its rings as seen from Earth. For all other bodies, 0. |

View File

@@ -1358,6 +1358,9 @@ namespace CosineKitty
/// <summary>The angle in degrees between the Sun and the Earth, as seen from the body. Indicates the body's phase as seen from the Earth.</summary>
public readonly double phase_angle;
/// <summary>A value in the range [0.0, 1.0] indicating what fraction of the body's apparent disc is illuminated, as seen from the Earth.</summary>
public readonly double phase_fraction;
/// <summary>The distance between the Sun and the body at the observation time.</summary>
public readonly double helio_dist;
@@ -1369,6 +1372,7 @@ namespace CosineKitty
this.time = time;
this.mag = mag;
this.phase_angle = phase_angle;
this.phase_fraction = (1.0 + Math.Cos(Astronomy.DEG2RAD * phase_angle)) / 2.0;
this.helio_dist = helio_dist;
this.ring_tilt = ring_tilt;
}