Created
January 17, 2024 20:38
-
-
Save sjhalayka/e11580248caf2449f4a96b6fa5621676 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
custom_math::vector_3 grav_acceleration(const custom_math::vector_3 &pos, const custom_math::vector_3 &vel, const double G) | |
{ | |
custom_math::vector_3 grav_dir = sun_pos - pos; | |
float distance = grav_dir.length(); | |
grav_dir.normalize(); | |
float alpha = (vel.length()*vel.length()) / (speed_of_light * speed_of_light); | |
alpha = pow(alpha, 0.01); // suit to taste | |
float G_factor = G*(2.0f - sqrt(1 - alpha)); | |
custom_math::vector_3 accel = grav_dir * (G_factor*sun_mass / pow(distance, 2.0)); | |
return accel; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment