I'm making a very basic orbit simulator in C# using the Helix Toolkit.

I want to position the Helix lighting object at the sun, but also be able to calculate solar eclipse by the moon and earth for a satellite (position defined in ECEF).

Upon some brief research, I'm reading that getting an accurate position calculation for the sun in ECEF is a lot of work.

Is there an algorithm that can perform this calculation for me that I can include into an UpdateSunPosition() method so that I can have a reasonably accurate position calculation of the sun in ECEF?

Perhaps I have to scratch the eclipse calculation ambitions for now, instead calculate Geographical Position of the sun to get the Declination and Greenwich Hour Angle, Call those latitude and longitude, and then just give it a satisfactory altitude.

I've noticed that people are referring to SOFA a lot when talking about this, but I'm not sure what SOFA is, or whether I can use it in C#. I'm pretty sure it doesn't operate in a .NET environment like visual studio, but please correct me if I'm wrong.

I appreciate any and all suggestions or insights anyone may be able to offer here.

SOFA is the Standards Of Fundamental Astronomy, approved by the International Astronomical Union (IAU) as being the canonical standard for calculating positions and time in astronomy. It is available in C and F77 versions as standard, and wrappers have been written in other languages, most notably Python as part of AstroPy. For your purpose, the thirdparty part of the website mentions the World Wide Astronomy (WWA) library which is C# so that would be worth a look for your application. I would recommend reading the SOFA Cookbooks, particularly the ones on Earth Attitude and Time Scales to get a better idea of how the (many) various time and co-ordinate systems fit together.

  • Thank you sir! I'll look into this and hopefully be able to update my question if I run into something I don't understand. – Matt S Oct 5 at 18:27
  • I'd personally recommend CSPICE, which is what NASA uses, but SOFA is good to. – barrycarter Oct 7 at 18:15
  • Since the OP was looking for a C# version and seemed to have some exposure to SOFA already, it seemed the logical choice. It also comes with the reasonable precision ephemerides built in: epv00 for Earth position (reversible for Sun position) and plan94 for the planets. Saves having to download extra kernels – astrosnapper Oct 7 at 21:34
  • 1
    Given that the CSPICE toolkit is provided in C, how would I use it in C#? I actually am quite new to programming, and realistically I have no exposure to SOFA, just heard of it when I would search for previous inquiries toward my objective. Which one would be easier to implement? I have no problem installing extra stuff as long as its reasonably simple to do. Also, any tutorials or advice/pointers in the right direction toward implementing this would surely go a really long way and save me a lot of time. Otherwise, looking forward to learning and struggling with this for a day or so! – Matt S Oct 8 at 5:08
  • 1
    I'm doing this for my work and they're pretty set up in the .NET environment with C# right now, so as much as I wish I could just use python, it's a bit of a stretch for my case since I can implement it with the SOFA functions. I've been reading through the SOFA documentation, they have equivalent C# functions posted on github already, and this seems to have potential to work really well. Thank you all! – Matt S Oct 10 at 23:06

@astrosnapper's answer is probably the one you want. But if you'd like something you can implement yourself, have a look at Astronomical Algorithms in this answer

This is something you'll have to dig into a bit, but if you like to program, it may be exactly what you're looking for. The Gaisma website is one of my favorites on the internet - easy to use and presents a bunch of information in easy-to-understand graphics. Click around!

I believe that this site uses algorithms from the collection found at this NOAA site. Click around there as well. They provide Excel spreadsheets which contain the algorithms and other resources. The "main" resource is a collection of algorithms published in the book Astronomical Algorithms - Jean Meeus. Search the books title and you can find that there are many similarly titled books. I'd recommend going to a library if possible, because it's (in my opinion) always good to go to libraries. However parts of these can be found on-line. For example, a few pages shown from the book Astronomical Formulae for Calculators (1988) include an interesting table of contents.

  • 1
    Wow these are great resources. Thank you very much! – Matt S Oct 10 at 23:05

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.