コード例 #1
0
ファイル: cannon_numeric.c プロジェクト: lonnell/trick
/* The cannonball sim's dynamic job */
double cannon_impact( CANNON* C ) {
    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) ) ; 
        C->impact = 1 ;
        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, pos = %.9f\n\n", now, C->pos[0] ) ;
    }
    return (tgo) ;
}
コード例 #2
0
ファイル: sched_dyn_event.c プロジェクト: carylogan/Trick
double sched_dyn_event(       /* RETURN: s  Time to go to event */
    SCHEDULE * S)             /* INOUT:  --  */
{

    double tgo;  /* Estimated time to go (in seconds) to the defined event */
    double now = get_integ_time();

    /* CALCULATE TIME TO GO FOR EVENT */
    S->rf.error = S->mass - 1.2;
    tgo = regula_falsi( now , &(S->rf) );

    if ( tgo == 0.0 ) {
        /* FIRE EVENT */
        reset_regula_falsi( now , &(S->rf) );
        /* Make mass zig zag once it hits 1.2kg */
        S->mass = S->mass - 0.01;
    }

    return( tgo ) ;
}