From f6f789cc2e0fe091b7b4261fb755d8b06548a53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Oudin?= Date: Tue, 13 Feb 2018 20:53:23 +0100 Subject: [PATCH] Utility function --- Ball.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Ball.cpp b/Ball.cpp index f9044a3..1494091 100644 --- a/Ball.cpp +++ b/Ball.cpp @@ -72,12 +72,7 @@ void Ball::_compute_v_z(Point normal) { v_z *= (0.5 + factor); } -void Ball::update_pos(double dt) { - //double height = (*ground)(Center.x, Center.z); - crt_time += dt; - if ((bouncing) && (crt_time >= T)) { - double old_t = T; - double max_t; +void Ball::_compute_parameters() { Point normal = (*ground).get_normal(Center.x, Center.z); bounce_number += 1; _compute_U_n(); @@ -88,6 +83,16 @@ void Ball::update_pos(double dt) { _compute_v_z(normal); min_height = fmin(radius, min_height + 0.2 * (radius - min_height)); std::cout << "U:" << U << "\n"; +} + +void Ball::update_pos(double dt) { + //double height = (*ground)(Center.x, Center.z); + crt_time += dt; + if ((bouncing) && (crt_time >= T)) { + double old_t = T; + double max_t; + _compute_parameters(); +>>>>>>> Utility function max_t = (T - old_t)/2.0 + old_t; if (((A + B * max_t - (G_CTE / 2) * max_t * max_t + min_height) < radius)) {