Coder Social home page Coder Social logo

stellarlib's Introduction

stellarlib

A simple C++ library which simulates hopefully will simulate astrodynamics.

This is my personal science project in which I try to connect my love for programming with my love for science. It's still nowhere near done or usable though I highly don't recommend anyone to use this library unless you know what you're doing (I certainly don't)

At the moment it can do these things:

  • Create Entites in a sensible object
  • Assign these entities to a Simulation instance
  • Apply velocities to their positions consistently based on the simulation speed and it's delta time.

This project is my first attempt to do something usable with C++ and it most likely violates every unwritten rule of C++ programming. If that is the case I would love you to correct my mistakes in the Issues section for me to correct them. Please keep in mind that I don't merge pull requests. I take this thing as my personal project to learn C++. Sorry to disappoint...

Yes I'm aware that it's not really a library yet since it creates a binary.

Here is a short code example

Simulation simulation; // Create a Simulation instance

vector<double> pos1{0,0,0};           // Default positons of the 2 entities we're going to create
vector<double> pos2{500,800, 1000};   //

Entity entity1("Earth", 5.972*pow(10,24), pos1); // Creating 2 instances of the Entity class
Entity entity2("Moon", 7.348*pow(10,22), pos2);  // Name, Mass (doesn't do anything yet), default position

simulation.addEntity(entity1); // Adding theese entites to the simulation
simulation.addEntity(entity2); // Note that preventing the entities from being in two simulations at once is not yet implemented


vector<double> velocity1 = vector<double>{150.3, 0, 0}; // Preparing the velocities
vector<double> velocity2 = vector<double>(0, 0, 70);    //

entity1.setVelocity(velocity1); // Setting the velocities
entity2.setVelocity(velocity2)  //

simulation.start(); // Starting the simulation
sleep(1);           // Letting it run for 1 second
simulation.stop();  // Stopping the simulation

cout << entity1.getPosition()[0] << " " << entity1.getPosition()[1] << " " <<entity1.getPosition()[2] << endl;  // Printing the results
cout << entity2.getPosition()[0] << " " << entity2.getPosition()[1] << " " <<entity2.getPosition()[2] << endl;  //

Building

make

To-do

  • Newton's law of universal gravitation (Implemented but broken atm.)
  • Newton's 3 laws of motion (Kind of implemented - not all of them)
  • The above will hopefully make Kepler's astrodynamics work

Thanks

Special thanks goes to Kurzgesagt - the channel which ignited my love for science after our school system dumped a bucket of water on it.

stellarlib's People

Contributors

cloudmracek avatar

Stargazers

Skiupace avatar  avatar Marek Maskarinec avatar Matěj Emmer avatar

Watchers

 avatar

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.