Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: How do I calculate sunrise/sunset times for non-Earth planets?

  1. #11
      snoopy is offline
    Guild Novice
    Join Date
    Oct 2011
    Posts
    6

    Default

    So after thinking that it was wrong, I went through everything a couple more times. Turns out what I did incorrectly was checking my answer on the Navy site I posted earlier. I forgot to enter time zone when picking a location. Once I did that, the times I got for sunrise and sunset using the equations I posted were within 5 minutes of the correct times!

    It's not done yet though. To get from hour angle (the last value I solved for in my previous post) to the times, I used the equations on the Sunrise Equation Wikipedia page, which involve the Julian date. Obviously, another planet would not use Julian date. What matters is the time elapsed since epoch though, so it should be a simple matter of defining my own epochs, using an equivalent of the Julian date. This would make use of the custom planet's day length, so all of parameters involving time will need to take that into account. This means using ratios to change the length of my second and the value of my gravitational constant.

    Now, if only I could code...
    Last edited by snoopy; 07-19-2012 at 02:47 PM.

  2. #12
      xoxos is offline
    Guild Journeyer
    Join Date
    Apr 2012
    Posts
    138

    Default

    here's a basic c/c++ script i use when i need to calculate stuff..


    #include <fstream>
    #include <stdlib.h>
    #include <windows.h>
    #include "math.h"
    #include "iomanip.h"
    #include <iostream>

    using namespace std;

    ofstream out;

    int main() {
    double o;

    out.open("solve.txt");

    for(int i = 2700; i <= 2800; i++) {

    o = (double)i;
    o += 5773500000;
    o *= .0000000001;
    o = o - o * o * o;

    out << setprecision(16) << i << ",\t" << o << "\r\n";
    }

    out.close();

    return 0;
    }


    ..here's the same thing with annotations... i use an old compiler.. borland's fclt.. which is a 5 meg install. low commitment, still works.. simple as such to use..




    #include <fstream> // necessary for writing txt file
    #include <stdlib.h> // stuff you write
    #include <windows.h> // not necessary in this program
    #include "math.h"
    #include "iomanip.h" // necessary for setprecision statement
    #include <iostream> // necessary for writing txt file

    using namespace std; // stuff you write

    ofstream out; // open filestream to write a file

    int main() { // begin main program statement
    double o; // declare a double length floating point variable

    out.open("solve.txt"); // create text file

    for(int i = 2700; i <= 2800; i++) { // do the calculations i needed

    o = (double)i;
    o += 5773500000;
    o *= .0000000001;
    o = o - o * o * o;

    out << setprecision(16) << i << ",\t" << o << "\r\n"; // write variables i and o to text file, with a tab and a line break
    }

    out.close(); // close file

    return 0; // execution of program ends
    }

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •