Skip to content

Instantly share code, notes, and snippets.

@mr21
Created May 14, 2018 12:25
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 mr21/a0f06364f84bd3c756d4e989d1f4a591 to your computer and use it in GitHub Desktop.
Save mr21/a0f06364f84bd3c756d4e989d1f4a591 to your computer and use it in GitHub Desktop.
Function to calcul the Schwarzschild radius with a mass
const lightSpeed = 299792458; // meter (per second)
const solarMass = 1.98855 * Math.pow( 10, 30 ); // kilograms
const gravity = 6.67408 * Math.pow( 10, -11 );
function calcSchwarzschildRadius( nbSolarMass ) {
return ( 2 * gravity * nbSolarMass * solarMass ) / ( lightSpeed * lightSpeed );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment