Giter VIP home page Giter VIP logo

Comments (1)

bjorgan avatar bjorgan commented on August 16, 2024

Headache outline:

The nice thing so far has been that predict_sun() and predict_moon() uses no special sun or moon structs, but the same struct predict_observation as the rest of the library. This makes some things more smooth for e.g. flyby. However, we apparently need new fields which don't exist within struct predict_observation.

We've also had only one function (predict_observe_moon(), predict_observe_sun()), but the needed properties are not dependent on an observer. Consistency requires a new function, e.g. predict_sun().

Some solution proposals:

Solution 1:

Add new structs, split into observation-independent and observation-dependent, in the same style as struct predict_orbit and struct predict_observation. For sun, it will be struct predict_sun and struct predict_observation, for moon it will be struct predict_moon and struct predict_observation.

struct predict_sun {
/* observation-independent properties we are missing for the sun, longitude, latitude, declination, ... */
};
predict_sun(predict_sun *sun, predict_julian_date_t time);
predict_observe_sun(const predict_observer_t *observer, const struct predict_sun *sun, struct predict_observation *obs);

struct predict_moon {
/* observation-independent properties we are missing for the moon, longitude, latitude, declination, ... */
};
void predict_moon(predict_moon *moon, predict_julian_date_t time);
void predict_observe_moon(const predict_observer_t *observer, const struct predict_moon *moon, struct predict_observation *obs);

Solution 2:

Unify moon and sun structs, since the fields are probably going to be the same anyway. Possible namings: celestial_body, celestial_object, astronomical_body, astronomical_object...

struct predict_celestial{
/* observation-independent properties we are missing */
};
void predict_sun(predict_celestial *orbit, predict_julian_date_t time);
void predict_observe_sun(const predict_observer *observer, struct predict_observation *obs, predict_julian_date_t time);
void predict_moon(predict_celestial *orbit, predict_julian_date_t time);
void predict_observe_moon(const predict_observer *observer, struct predict_observation *obs, predict_julian_date_t time);

Solution 3:

Instead of predict_sun and predict_moon, unify to a common function.

enum predict_celestial_body {
    PREDICT_MOON,
    PREDICT_SUN
};

predict_celestial_body(enum predict_celestial_body body, predict_celestial *orbit, predict_julian_date_t time);
predict_observe_celestial_body(const predict_observer_t *observer, const predict_celestial *orbit, struct predict_observation obs);

Could also be extended to other planets. :-)

Solution 4:

Reuse struct predict_orbit. It makes sense in some ways, since a lot of these fields are going to be the same and predict_observe_orbit can be reused also for the moon and sun, but it will also have some additional weirdness in that functions defined for satellites are suddenly going to work also on moon and sun and result in very undefined behavior. What is the doppler shift from the sun? :^) Some properties like "eclipsed" also do not make much sense.

Solution 5:

Don't provide the missing properties at all and say that they are not available in the API. :-P

Is there any cleaner solution (except for solution 5)?

from libpredict.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.