Skip to content

Instantly share code, notes, and snippets.

@sjhalayka
Created April 19, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjhalayka/a499a7f0429884bf3fd6ef38151ecd58 to your computer and use it in GitHub Desktop.
Save sjhalayka/a499a7f0429884bf3fd6ef38151ecd58 to your computer and use it in GitHub Desktop.
void idle_func(void)
{
custom_math::vector_3 grav_dir = sun_pos - mercury_pos;
float distance = grav_dir.length();
grav_dir.normalize();
custom_math::vector_3 accel = grav_dir*(G*sun_mass/pow(distance, 2.0));
float dt = 10000;
mercury_vel = mercury_vel + accel*dt;
mercury_pos = mercury_pos + mercury_vel*dt;
positions.push_back(mercury_pos);
glutPostRedisplay();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment