From bac90aac144dd1edc3701bd069005215e97597af Mon Sep 17 00:00:00 2001 From: "John M. Penn" Date: Wed, 8 Nov 2017 14:10:45 -0600 Subject: [PATCH] Fix cannon_impact, by updating it to the version in the tutorial. Oops. Ref #439 --- .../cannon/gravity/src/cannon_numeric.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/trick_sims/Cannon/models/cannon/gravity/src/cannon_numeric.c b/trick_sims/Cannon/models/cannon/gravity/src/cannon_numeric.c index eb66964e..05d71443 100644 --- a/trick_sims/Cannon/models/cannon/gravity/src/cannon_numeric.c +++ b/trick_sims/Cannon/models/cannon/gravity/src/cannon_numeric.c @@ -49,21 +49,20 @@ int cannon_integ( CANNON* C ) { /* The cannonball sim's dynamic job */ double cannon_impact( CANNON* C ) { - - double tgo ; - double now ; - /* Set error function --- how far ball is above ground */ - C->rf.error = C->pos[1] ; - now = get_integ_time() ; - tgo = regula_falsi( now, &(C->rf) ) ; - if (tgo == 0.0) { + double tgo ; /* time-to-go */ + double now ; /* current integration time. */ + + C->rf.error = C->pos[1] ; /* Specify the event boundary. */ + now = get_integ_time() ; /* Get the current integration time */ + tgo = regula_falsi( now, &(C->rf) ) ; /* Estimate remaining integration time. */ + if (tgo == 0.0) { /* If we are at the event, it's action time! */ now = get_integ_time() ; - reset_regula_falsi( now, &(C->rf) ) ; + reset_regula_falsi( now, &(C->rf) ) ; C->impact = 1 ; - C->impactTime = now; + C->impactTime = now ; C->vel[0] = 0.0 ; C->vel[1] = 0.0 ; C->acc[0] = 0.0 ; C->acc[1] = 0.0 ; - fprintf(stderr, "\n\nIMPACT: SimTime = %.9f, ModelTime = %.9f, pos = %.9f\n\n", now, C->impactTime, C->pos[0] ) ; + fprintf(stderr, "\n\nIMPACT: SimTime = %.9f, pos = %.9f\n\n", now, C->pos[0] ) ; } - return ( tgo ) ; + return (tgo) ; }