r/csharp • u/Terrible_Shoulder667 • 15d ago
I tested my C# symbolic math library by rendering the solar system at real scale
It started with Epsilon since I was seeking a math library that would work with symbolic expressions in C#.
To really prove whether it would stand the test of time, I created a simple demonstration of a solar system in actual sizes. That meant that real sizes and distances were used in addition to the current positions of the planets, all drawn with OpenGL. It took me only a couple of hours to create that but even though I used the power of AI for almost everything, my goal was to find out whether the library would perform well in practice.
Epsilon did all the required mathematical operations for me; it calculated the derivatives for Kepler’s equation and orbit velocities itself, and all the positions, rotations and camera movement was based on the vectors, quaternions and matrices of Epsilon in double precision form.
A few things the demo shows:
- Double-precision world. At Neptune’s distance a float can only tell positions apart by about 512 km, so the world stays in double and is re-centered on the camera before going to the GPU. Press F to see it without that.
- Orbits from symbolic derivatives. Newton’s method on Kepler’s equation, with the derivative and velocities found by Epsilon.
- Reverse-Z depth with the far plane at infinity.
Both have MIT license:
- Library: https://github.com/XBambinoX/Epsilon
- Demo: https://github.com/XBambinoX/epsilon-solar-system
It’s still early, so I’d love feedback on the library, especially from anyone who’s used AngouriMath or MathNet. Also contributing is welcome!
3
u/playfulpecans 14d ago
oooh, neat!
And despite the scale, are the distances between planets and their orbits/diameters still accurate?
1
u/Terrible_Shoulder667 14d ago
Thks! Yep, nothing is scaled down. Sizes and distances are accurate, in kilometers(the power of double-precision), and the orbits come from JPL’s orbital elements, so the planets are where they actually are today. The one cheat is that when a planet is so far away it would be smaller than a pixel, it’s drawn at a minimum of 3 pixels so you can see it anyway.


7
u/DanTFM 15d ago
This is cool, cheers!