Created
March 29, 2019 18:04
-
-
Save Sascha-T/8a169d09bca5218b985a958bcb089148 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
let grav = 9.8 | |
// Velocity is in meters per second | |
// Angle is in radians | |
// Initial Height is in meters | |
// Returns: Horizontal distance travelled by object | |
function artillery(velocity, angle, initHeight) { | |
return Math.pow(velocity, 2) / (2 * grav) * (1 + Math.sqrt(1 + ((2*grav * initHeight) / (Math.pow(velocity, 2) * Math.pow(Math.sin(angle), 2))))) * Math.sin(2*angle) | |
} | |
/* Warning: This assumes that: | |
There is no air resistance | |
There is a uniform gravity field | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment