Fix cannon_impact, by updating it to the version in the tutorial. Oops. Ref #439

This commit is contained in:
John M. Penn 2017-11-08 14:10:45 -06:00
parent 29bd27e931
commit bac90aac14

View File

@ -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) ;
}