Skip to content

Commit

Permalink
Merge pull request #36 from la1k/issue33
Browse files Browse the repository at this point in the history
Add visibility status to struct predict_observation.

Closes #33.
  • Loading branch information
ryeng committed Oct 5, 2015
2 parents 4bd29bd + a41ccb8 commit 07e03ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/predict/predict.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ struct predict_observation {
double range_x, range_y, range_z;
///Range velocity (km/s)
double range_rate;
///Visibility status, whether satellite can be seen by optical means.
///The satellite is defined to be visible if:
// - The satellite is in sunlight
// - The satellite is above the horizon
// - The sky is dark enough (sun elevation is below a fixed threshold)
bool visible;
};

/**
Expand Down
10 changes: 10 additions & 0 deletions src/observer.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ void predict_destroy_observer(predict_observer_t *obs)
}
}


#define VISIBILITY_SUN_ELE_UPPER_THRESH -12.0
#define VISIBILITY_ORBIT_ELE_LOWER_THRESH 0.0
/**
* \brief Calculates range, azimuth, elevation and relative velocity.
*
Expand All @@ -43,6 +46,13 @@ void predict_observe_orbit(const predict_observer_t *observer, const predict_orb

observer_calculate(observer, julTime, orbit->position, orbit->velocity, obs);

// Calculate visibility status of the orbit: Orbit is visible if sun elevation is low enough and the orbit is above the horizon, but still in sunlight.
obs->visible = false;
struct predict_observation sun_obs;
predict_observe_sun(observer, orbit->time, &sun_obs);
if (!(orbit->eclipsed) && (sun_obs.elevation*180.0/M_PI < VISIBILITY_SUN_ELE_UPPER_THRESH) && (obs->elevation*180.0/M_PI > VISIBILITY_ORBIT_ELE_LOWER_THRESH)) {
obs->visible = true;
}
}

void observer_calculate(const predict_observer_t *observer, double time, const double pos[3], const double vel[3], struct predict_observation *result)
Expand Down

0 comments on commit 07e03ef

Please sign in to comment.