Created
April 19, 2018 20:14
-
-
Save sjhalayka/a499a7f0429884bf3fd6ef38151ecd58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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