1 // eclipsefinder.h by Christophe Teyssier <chris@teyssier.org> 2 // adapted form wineclipses.h by Kendrix <kendrix@wanadoo.fr> 3 // 4 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net> 5 // 6 // Compute Solar Eclipses for our Solar System planets 7 // 8 // This program is free software; you can redistribute it and/or 9 // modify it under the terms of the GNU General Public License 10 // as published by the Free Software Foundation; either version 2 11 // of the License, or (at your option) any later version. 12 13 #ifndef _ECLIPSEFINDER_H_ 14 #define _ECLIPSEFINDER_H_ 15 16 #include <vector> 17 18 #include "celestiacore.h" 19 20 class Eclipse 21 { 22 public: 23 Eclipse(int Y, int M, int D); 24 Eclipse(double JD); 25 26 enum Type { 27 Solar = 0, 28 Moon = 1 29 }; 30 31 public: 32 Body* body; 33 std::string planete; 34 std::string sattelite; 35 astro::Date* date; 36 double startTime; 37 double endTime; 38 }; 39 40 class EclipseFinder 41 { 42 public: EclipseFinder(CelestiaCore * core,const std::string & strPlaneteToFindOn_,Eclipse::Type type_,double from,double to)43 EclipseFinder(CelestiaCore* core, 44 const std::string& strPlaneteToFindOn_, 45 Eclipse::Type type_, 46 double from, 47 double to ) 48 :appCore(core), 49 strPlaneteToFindOn(strPlaneteToFindOn_), 50 type(type_), 51 JDfrom(from), 52 JDto(to), 53 toProcess(true) {}; 54 getEclipses()55 const std::vector<Eclipse>& getEclipses() { if (toProcess) CalculateEclipses(); return Eclipses_; }; 56 57 private: 58 CelestiaCore* appCore; 59 std::vector<Eclipse> Eclipses_; 60 61 std::string strPlaneteToFindOn; 62 Eclipse::Type type; 63 double JDfrom, JDto; 64 65 bool toProcess; 66 67 int CalculateEclipses(); 68 bool testEclipse(const Body& receiver, const Body& caster, double now) const; 69 double findEclipseSpan(const Body& receiver, const Body& caster, double now, double dt) const; 70 71 }; 72 #endif // _ECLIPSEFINDER_H_ 73 74