Last active
November 5, 2016 21:14
-
-
Save jsancheznet/d1b436618a5ad125df27 to your computer and use it in GitHub Desktop.
Equation of Motion
This file contains hidden or 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
/* | |
// THIS CODE DOES NOT COMPILE, ITS PSEUDOCODE IN C'ish style | |
1- Calculate the Sum of Forces for an object | |
2- Acceleration is proportional to the sum of forces | |
3- Calculate Velocity | |
4- Calculate Position | |
*/ | |
v2 Acceleration = {}; | |
v2 Velocity = {}; | |
v2 Position = {}; | |
v2 Gravity = {}; | |
v2 Gravity = {0.0f, 9.81f}; // Top->Down Cartesian system (SDL Like) | |
// Add Gravity to the Sum of Forces | |
Acceleration += Gravity; | |
NewVelocity = Acceleration * TimeStep + OldVelocity; | |
NewPosition = (1/2 * Acceleration * (TimeStep * TimeStep) + OldVelocity * TimeStep + OldPosition; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment