Ejemplo n.º 1
0
double Bridge:: find_zeta_max(const double theta)
{
    // a good value
    double zeta_lo = 0.0;
    if( find_alpha(theta, zeta_lo, NULL) < 0 )
    {
        throw exception("Cannot find alpha for zeta=0");
    }

    // a bad balue
    double zeta_up = 1.0;
    while(find_alpha(theta,zeta_up,NULL)>=0)
    {
        zeta_lo = zeta_up;
        zeta_up += 1.0;
    }
    std::cerr << "Looking up between " << zeta_lo << " and " << zeta_up << std::endl;
    const double zeta_ftol = numeric<double>::sqrt_ftol;
    while( Fabs(zeta_up-zeta_lo) >= zeta_ftol * ( Fabs(zeta_lo) + Fabs(zeta_up) ) )
    {
        const double zeta_mid = 0.5*(zeta_lo+zeta_up);
        if(find_alpha(theta,zeta_mid,NULL) < 0 )
        {
            zeta_up = zeta_mid;
        }
        else
        {
            zeta_lo = zeta_mid;
        }
    }

    // highest good value
    return zeta_lo;
}
Ejemplo n.º 2
0
      void init(const T& sample_frequency, const T& center_frequency, const T& bandwidth)
      {
        alpha = find_alpha(sample_frequency,bandwidth);
        omega = find_omega(sample_frequency,center_frequency);
	period = 1.0 / sample_frequency;
        reset();
      }
Ejemplo n.º 3
0
void move_projectiles(GameState* state) {
	register int i, j;
	for (i = 0; i < state->towers_length; i++) {
		for (j = 0; j < state->towers[i]->tower.ammo; j++) {
			Projectile* proj = &state->towers[i]->tower.projectiles[j];
			int from_x = proj->world_x;
			int from_y = proj->world_y;
			if (proj->target != NULL && proj->live) {
				int to_x = proj->target->world_x;
				int to_y = proj->target->world_y;
				float alpha, a, b, c;
				calc_direction(from_x, from_y, to_x, to_y, &proj->direction_x, &proj->direction_y);

				a = fabs(proj->target->world_x - proj->world_x);
				b = fabs(proj->target->world_y - proj->world_y);
				c = euclidean_distance(proj->target->world_x, proj->target->world_y, proj->world_x, proj->world_y);
				alpha = find_alpha(a, b, c);

				proj->world_x += proj->speed * proj->direction_x;
				proj->world_y += proj->speed * proj->direction_y;
				proj->angle = find_render_angle(alpha, proj->direction_x, proj->direction_y);
			} else{
				//verwijder stilstaande projectielen
				proj->live = 0;
			}
		}
	}
}
Ejemplo n.º 4
0
void print_hist_fg(simplex *root, fg *faces_gr, FILE *F) {
    int i,j,k;
    double tot_good[100], tot_bad[100], tot_far[100];
    for (i=0;i<20;i++) {
        tot_good[i] = tot_bad[i] = tot_far[i] = 0;
        for (j=0;j<100;j++) {
            fg_hist[i][j]= fg_hist_bad[i][j]= fg_hist_far[i][j] = 0;
        }
    }
    if (!root) return;

    find_alpha(root);

    if (!faces_gr) faces_gr = build_fg(root);

    visit_fg(faces_gr, h_fg);
    visit_fg_far(faces_gr, h_fg_far);

    for (j=0;j<100;j++) for (i=0;i<20;i++) {
        tot_good[i] += fg_hist[i][j];
        tot_bad[i] += fg_hist_bad[i][j];
        tot_far[i]  += fg_hist_far[i][j];
    }

    for (i=19;i>=0 && !tot_good[i] && !tot_bad[i]; i--);
    fprintf(F,"totals   ");
    for (k=0;k<=i;k++) {
        if (k==0) fprintf(F, "  ");
        else fprintf(F,"            ");
        fprintf(F, "%d/%d/%d",
                (int)tot_far[k], (int)tot_good[k], (int)tot_good[k] + (int)tot_bad[k]);
    }
        
    
    for (j=0;j<100;j++) {
        for (i=19; i>=0 && !fg_hist[i][j] && !fg_hist_bad[i][j]; i--);
        if (i==-1) continue;
        fprintf(F, "\n%d    ",j);fflush(F);
            
        for (k=0;k<=i;k++) {
            if (k==0) fprintf(F, "  ");
            else fprintf(F,"            ");
            if (fg_hist[k][j] || fg_hist_bad[k][j])
                fprintf(F,
                        "%2.1f/%2.1f/%2.1f",
                        tot_far[k] ? 100*fg_hist_far[k][j]/tot_far[k]+.05 : 0,
                        tot_good[k] ? 100*fg_hist[k][j]/tot_good[k]+.05 : 0,
                        100*(fg_hist[k][j]+fg_hist_bad[k][j])/(tot_good[k]+tot_bad[k])+.05
                    );
        }
    }
    fprintf(F, "\n");
}
Ejemplo n.º 5
0
int main(int argc, char **argv) {


	short	pine = 0,
		output = 1,
		hist = 0,
		vol = 0,
		ahull = 0,
		ofn = 0,
		ifn = 0;
	int	option;
	double	alpha = 0;
	int	main_out_form=0, alpha_out_form=0;
	simplex *root;
	fg 	*faces_gr;

	mult_up = 1;

	while ((option = getopt(argc, argv, "i:m:rs:do:X:a:Af:")) != EOF) {
		switch (option) {
		case 'm' :
			sscanf(optarg,"%lf",&mult_up);
			DEBEXP(-4,mult_up);
			break;
		case 'a' :
			vd = ahull = 1;
			switch(optarg[0]) {
				case 'a': sscanf(optarg+1,"%lf",&alpha); break;
				case '\0': break;
				default: tell_options();
			 }
			break;
		default :
			tell_options();
			exit(1);
		}
	}

	INFILE = stdin;
	OUTFILE = stdout;
	DFILE = stderr;
	read_next_site(-1);
	if (dim > MAXDIM) panic("dimension bound MAXDIM exceeded"); 

	point_size = site_size = sizeof(Coord)*dim;

	shuf = &noshuffle;
	get_site_n = read_next_site;

	root = build_convex_hull(get_next_site, site_numm, dim, vd);

	out_func* aof = out_funcs[alpha_out_form];
	
	if (alpha==0) alpha=find_alpha(root);
	alph_test(0,0,&alpha);
	make_output(root, visit_outside_ashape, afacets_print, aof, OUTFILE);

	free_hull_storage();

	exit(0);
}