MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / PhysicsComp_YPosAt

Function PhysicsComp_YPosAt

src/EntityComponents.c:994–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

992}
993
994static double PhysicsComp_YPosAt(int t, float u) {
995 /* v(t, u) = (4 + u) * (0.98^t) - 4, where u = initial velocity */
996 /* x(t, u) = Σv(t, u) from 0 to t (since we work in discrete timesteps) */
997 /* plugging into Wolfram Alpha gives 1 equation as */
998 /* (0.98^t) * (-49u - 196) - 4t + 50u + 196 */
999 double a = Math_Exp2(-0.02914633510256746 * t); /* ~0.98^t */
1000 return a * (-49 * u - 196) - 4 * t + 50 * u + 196;
1001}
1002
1003double PhysicsComp_CalcMaxHeight(float u) {
1004 /* equation below comes from solving diff(x(t, u))= 0 */

Callers 1

Calls 1

Math_Exp2Function · 0.85

Tested by

no test coverage detected