void test() {
    int i, j;


    for (i = 0; i < window_height; i++) {
        set_color(255<<16 | 128 << 8 | i);
        for (j = 0; j < window_width; j++) {
            plot_point(j, i);
        }
    }

    update_window();

    wait_until_keypress();

    for (i = 0; i < window_height; i++) {
        set_color(255<<16 | 255 << 8 | i);
        for (j = 0; j < window_width; j++) {
            plot_point(j, i);
        }
    }

    update_window();

    wait_until_keypress();
}
Exemplo n.º 2
0
bool bresenhamLineDrawer(cv::Mat* inputMat, int* x, int* y) {
    if (y[0] == y[1]) {
        if (x[0] == x[1]) return true;

        int step = x[0] > x[1]? -1: 1;
        for (int i = x[0]; i <= x[1]; i += step)
            plot_point(inputMat, i, y[0]);
    }
    if (x[0] == x[1]) {
        int step = y[0] > y[1]? -1: 1;
        for (int i = y[0]; i <= y[1]; i += step)
            plot_point(inputMat, x[0], i);
    }

    // sort the x, y in order, and consider the case where K > 1
    float k_slope = float(y[0] - y[1]) / (x[0] - x[1]);
    float dy = k_slope;
    if (fabs(k_slope) > 1.0) {
        for (int i = 0; i <= 1; i++) {
            int temp = x[i];
            x[i] = y[i];
            y[i] = temp;
        }
        dy = 1 / k_slope;
    }
    sort_point(x, y);

    int y_i = y[0];
    float e = 0;
    if (k_slope > 0) e = -0.5;
    else e = 0.5;

    printf("start at %d, %d    %d, %d, slope = %f\n",
            x[0], y[0], x[1], y[1], k_slope);

    for (int x_i = x[0]; x_i <= x[1]; x_i ++) {
        if (fabs(k_slope) > 1) plot_point(inputMat, y_i, x_i);
        else plot_point(inputMat, x_i, y_i);

        printf("Now at %d, %d, e = %f\n", x_i, y_i, e);
        if (k_slope > 0) {
           e = e + dy;
           if (e >= 0) { y_i ++; e = e - 1;}
        }
        else {
            e = e + dy;
            if (e < 0) { y_i --; e = e + 1;}
        }
    }
    printf("Using the DDA methods\n");
    return true;
}
// Try and run the given file as a visual simulation
void run_sim(Agent **agent_list, long num_steps, long num_agents){
	
	wait_until_keypress();
		
	int x_coord, y_coord, type;
	
	int i, j;
	for(i=0; i<num_steps; i++){
		for(j=0; j<num_agents; j++){
			x_coord = agent_list[i][j].position.x;	
			y_coord = agent_list[i][j].position.y;
			type = agent_list[i][j].type;	
			
			
			
			if(type == 0){
				set_color(FUCHSIA);
			}
			else{
				set_color(WHITE);
			}
			
			plot_point(x_coord, y_coord);
		
		}
		update_window();
		//wait_until_keypress();
		usleep(50000);
	}
	
	
}
Exemplo n.º 4
0
/* draw_points
 *
 * Draw a set of 3D points on the canvas. Each point in geometry is
 * formatted (vx, vy, vz, nx, ny, nz, s, t). Don't forget to test the
 * points against the clipping plains of the projection. If you don't
 * you'll get weird behavior (especially when objects behind the camera
 * are being rendered).
 */
void canvashdl::draw_points(const vector<vec8f> &geometry)
{
	update_normal_matrix();
	mat4f transform = matrices[projection_matrix]*matrices[modelview_matrix];
	vec4f planes[6];
	for (int i = 0; i < 6; i++)
		planes[i] = transform.row(3) + (float)pow(-1.0, i)*(vec4f)transform.row(i/2);

	vector<pair<vec3f, vector<float> > > processed_geometry;
	processed_geometry.reserve(geometry.size());

	for (int i = 0; i < geometry.size(); i += 3)
	{
		bool keep = true;
		for (int j = 0; j < 6 && keep; j++)
			if (dot(homogenize((vec3f)geometry[i]), planes[j]) <= 0)
				keep = false;

		if (keep)
		{
			vector<float> varying;
			vec3f position = matrices[viewport_matrix]*homogenize(shade_vertex(geometry[i], varying));
			processed_geometry.push_back(pair<vec3f, vector<float> >(position, varying));
		}
	}

	for (int i = 0; i < processed_geometry.size(); i++)
		plot_point(processed_geometry[i].first, processed_geometry[i].second);
}
Exemplo n.º 5
0
/* plot_triangle
 *
 * Use the above functions to plot a whole triangle. Don't forget to
 * take into account the polygon mode. You should be able to render the
 * triangle as 3 points, 3 lines, or a filled in triangle. (v1, v2, v3)
 * are given in window coordinates.
 */
void canvashdl::plot_triangle(vec3f v1, vector<float> v1_varying, vec3f v2, vector<float> v2_varying, vec3f v3, vector<float> v3_varying)
{
	if (polygon_mode == point)
	{
		plot_point(v1, v1_varying);
		plot_point(v2, v2_varying);
		plot_point(v3, v3_varying);
	}
	else if (polygon_mode == line)
	{
		plot_line(v1, v1_varying, v2, v2_varying);
		plot_line(v2, v2_varying, v3, v3_varying);
		plot_line(v3, v3_varying, v1, v1_varying);
	}
	else if (polygon_mode == fill)
	{
		plot_line(v1, v1_varying, v2, v2_varying);
		plot_line(v2, v2_varying, v3, v3_varying);
		plot_line(v3, v3_varying, v1, v1_varying);

		if (v1[0] > v2[0])
		{
			swap(v1, v2);
			swap(v1_varying, v2_varying);
		}
		if (v1[0] > v3[0])
		{
			swap(v1, v3);
			swap(v1_varying, v3_varying);
		}
		if (v2[0] > v3[0])
		{
			swap(v2, v3);
			swap(v2_varying, v3_varying);
		}

		vector<float> ave_varying(v1_varying.size());

		if (shade_model == flat)
			for (int i = 0; i < (int)v1_varying.size(); i++)
				ave_varying[i] = (v1_varying[i] + v2_varying[i] + v3_varying[i])/3.0f;

		plot_half_triangle((vec3i)v1, v1_varying, (vec3i)v2, v2_varying, (vec3i)v3, v3_varying, ave_varying);
		plot_half_triangle((vec3i)v3, v3_varying, (vec3i)v1, v1_varying, (vec3i)v2, v2_varying, ave_varying);
	}
}
Exemplo n.º 6
0
int main(int argc, char* argv[]) {
	particle p_list[NUM_PARTICLES];
	png_file png;
	float t;
	int i;

	int num_nodes,id;
	MPI_Status status;

	/* init MPI */
    MPI_Init(&argv,&argc);
    MPI_Comm_rank(MPI_COMM_WORLD,&id);
    MPI_Comm_size(MPI_COMM_WORLD,&num_nodes);

	/* create datatypes */


	/* init the particle list */
	for(i=0; i < NUM_PARTICLES; i++) {
		init_particle(&p_list[i],0,0,0);
		set_x_pos_fnt(&p_list[i],&position_x);
		set_y_pos_fnt(&p_list[i],&position_y);
		set_z_pos_fnt(&p_list[i],&position_z);
		p_list[i].parm_list = (float*)malloc(sizeof(float) * NUM_PARMS);
		p_list[i].parm_list[MASS] = 1.0F;  /* kg */
		p_list[i].parm_list[X_V0] = 15.0F; /* m/s */
		p_list[i].parm_list[Y_V0] = 0.0F;  /* m/s */
		p_list[i].parm_list[Z_V0] = 0.0F;  /* m/s */
	}

	/* open the png file */
	open_file(&png,"test.png",1024,1024,0,2000,-2000,0);

	/* do some work */
	for(t=0.0F; t < 20.0F; t+=0.05F) {
		for(i=0; i < NUM_PARTICLES; i++) {
			update_particle(&p_list[i],t);
			printf("%F %F %F\n",p_list[i].x,p_list[i].y,p_list[i].z);
			plot_point(&png,(int)p_list[i].x,(int)p_list[i].y,255-i,255-i,255-i);
		}
	}

	/* write out the png file */
	write_file(&png);

	/* close the png file */
	close_file(&png);

	/* destory particle list */
	for(i=0; i < NUM_PARTICLES; i++) {
		free(p_list[i].parm_list);
	}

	/* shutdown MPI */
	MPI_Finalize();

	return(0);
}
Exemplo n.º 7
0
bool DDALineDrawer(cv::Mat* inputMat, int* x, int* y) {
    if (y[0] == y[1]) {
        if (x[0] == x[1]) return true;

        int step = x[0] > x[1]? -1: 1;
        for (int i = x[0]; i <= x[1]; i += step)
            plot_point(inputMat, i, y[0]);
    }
    if (x[0] == x[1]) {
        int step = y[0] > y[1]? -1: 1;
        for (int i = y[0]; i <= y[1]; i += step)
            plot_point(inputMat, x[0], i);
    }

    // sort the x, y in order, and consider the case where K > 1
    float k_slope = float(y[0] - y[1]) / (x[0] - x[1]);
    if (fabs(k_slope) > 1) {
        k_slope = 1 / k_slope;
        sort_point(y, x);
        float x_i = x[0];
        for (int y_i = y[0]; y_i <= y[1]; y_i ++) {
            plot_point(inputMat, int(x_i + 0.5), y_i);
            x_i = x_i + k_slope;
            printf("Now at %d, %d\n", int(x_i), int(y_i+0.5));
        }
    }
    else {
        sort_point(x, y);
        float y_i = y[0];
        for (int x_i = x[0]; x_i <= x[1]; x_i ++) {
            plot_point(inputMat, x_i, int(y_i + 0.5));
            y_i = y_i + k_slope;
            printf("Now at %d, %d\n", x_i, int(y_i+0.5));
        }
    }
    printf("Using the DDA methods\n");
    return true;
}
Exemplo n.º 8
0
Arquivo: cube.c Projeto: fuglsang/cube
void plot_heart(UINT8 x, UINT8 y)
{
  UINT8 ex = x + 9;
  UINT8 ey = y + 9;
  UINT8 ix, iy, k = 0;
  for (iy = y; iy != ey; iy++)
  {
    for (ix = x; ix != ex; ix++)
    {
      if (heart[k++] != 0)
        plot_point(ix, iy);
    }
  }
}
Exemplo n.º 9
0
// Function to draw a circle using bresenham's
// circle drawing algorithm
void bresenham_circle(int r)
{
  int x=0,y=r;
  float pk=(5.0/4.0)-r;

  /* Plot the points */
  /* Plot the first point */
  plot_point(x,y);
  int k;
  /* Find all vertices till x=y */
  while(x < y)
  {
    x = x + 1;
    if(pk < 0)
      pk = pk + 2*x+1;
    else
    {
      y = y - 1;
      pk = pk + 2*(x - y) + 1;
    }
    plot_point(x,y);
  }
  glFlush();
}
Exemplo n.º 10
0
void render(double time)
   {
   int i,j,k;

   int width,height;

   char state[size]={0};
   char state2[size]={0};

   width=get_winwidth();
   height=get_winheight();

   if (width>size) width=size;

   for (i=0; i<width; i++) state[i]=drand48()<0.5;

   for (i=0; i<height; i++)
      {
      for (j=0; j<width; j++)
         {
         unsigned int s=0;

         for (k=-b; k<=b; k++)
            {
            int l=j+k;

            if (l<0) l+=width;
            else if (l>=width) l-=width;

            s|=(state[l]<<(k+b));
            }

         state2[j]=(code&(1<<s))!=0;
         }

      for (j=0; j<width; j++) state[j]=state2[j];

      plot_color(0,0,0);
      for (j=0; j<width; j++)
         {
         double x=(j+0.5)/width;
         double y=1.0-(i+0.5)/height;

         if (state[j])
            plot_point(x,y);
         }
      }
   }
Exemplo n.º 11
0
void XYGraph::plot_sample( cairo_t *cairo, double x, double y, double width, double height )
{
    cairo_set_line_width( cairo, _linewidth );
    cairo_set_source_rgb( cairo, _color[0], _color[1], _color[2] );

    if( _linestyle == XYGRAPH_LINE_SOLID ) {

	cairo_move_to( cairo, x, y-0.5*height );
	cairo_line_to( cairo, x+width, y-0.5*height );
	cairo_stroke( cairo );

    }
    if( _pointstyle != XYGRAPH_POINT_DISABLE ) {

	plot_point( cairo, x+0.5*width, y-0.5*height );
    }
}
Exemplo n.º 12
0
/**
 * USE: Provide sample points and how many to setup_hough() transformation and plot those points
 * using plot_point() with each index of points you want to convert. The use print_classifier()
 * or get_lines() to see the lines extracted.
 */
int main(int argc, char **argv) {

	// Get points from image
	SIZE_TYPE size;
	POINT_TYPE *points = NULL;
	sizep_t count = get_points("sample_small.bmp", &points, &size);

	/*
	 *  points 		: Array of points
	 *  num_points	: Number of points in the array
	 *  threshold	: Threshold to consider line intersection
	 *  tolerance_t	: Tolerance (in grades) to consider two lines are the same
	 *  tolerance_r	: Distance (in pixels) to consider two lines are the same
	 *  precision	: Precision for degrees (10 = decimals, 100 = cents...)
	 *  size		: Size of the image
	 *  max_lines	: Lines to look for (value -1 falls back to 500)
	 */
	clock_t cp = clock();
	setup_hough(points, count, 12, 15.0, 5.0, 1, size, 10000);

	// Plot every point and measure clock ticks
	int n;
	for (n=0; n<_num_points; n++) {
		plot_point(n);
	}
	printf("_plot_point() ticks: %.4f\n", ((double)(clock()-cp))/1000000l);
	print_accumulator("accumulator.bmp");
	print_classifier();//*/

	// Get lines from classifier
	LINE_TYPE *lines;
	sizep_t clines = get_lines(&lines);

	// Print lines
	print_lines("output.bmp", "sample.bmp", lines, clines, 10);
	print_lines("output_small.bmp", "sample_small.bmp", lines, clines, 1);

	// Free memory
	finish_hough();
	free(lines);
	free(points);
	printf("All clear!");

	return EXIT_SUCCESS;
}
Exemplo n.º 13
0
int main(int argc, char* argv[]) {
	particle p_list[NUM_PARTICLES];
	png_file png;
	float t;
	int i;

	/* init the particle engine */
	init_particle_engine();
	set_x_pos_fnt(&p_list[i],&position_x);
	set_y_pos_fnt(&p_list[i],&position_y);
	set_z_pos_fnt(&p_list[i],&position_z);


	/* init the particle list */
	for(i=0; i < NUM_PARTICLES; i++) {
		init_particle(&p_list[i],0,0,0);
		p_list[i].parm_list[MASS] = 1.0F;  /* kg */
		p_list[i].parm_list[X_V0] = 15.0F; /* m/s */
		p_list[i].parm_list[Y_V0] = 0.0F;  /* m/s */
		p_list[i].parm_list[Z_V0] = 0.0F;  /* m/s */
	}

	/* open the png file */
	open_file(&png,"test.png",1024,1024,0,2000,-2000,0);

	/* do some work */
	for(t=0.0F; t < 20.0F; t+=0.05F) {
		for(i=0; i < NUM_PARTICLES; i++) {
			update_particle(&p_list[i],t);
			plot_point(&png,(int)p_list[i].x,(int)p_list[i].y,255,255,255);
		}
	}

	//plot_point(&png,0,0,255,255,255);

	/* write out the png file */
	write_file(&png);

	/* close the png file */
	close_file(&png);

	return(0);
}
Exemplo n.º 14
0
void main()
{
    UBYTE  a,b,c,d,e;
    c=0;
    /* Draw many characters on the screen with different fg and bg colours */
    for (a=0; a<=15; a++) {
	for (b=0; b<=15; b++) {
	    gotogxy(b,a);
	    d=a/4;
	    e=b/4;
	    if (d==e) {
		d=3-e;
	    }
	    color(d,e,SOLID);
	    gprintf("%c",c++);
	} 
    }

    /* Draw two circles, a line, and two boxes in different drawing modes */
    color(LTGREY,WHITE,SOLID);
    circle(140,20,15,M_FILL);
    color(BLACK,WHITE,SOLID);
    circle(140,20,10,M_NOFILL);
    color(DKGREY,WHITE,XOR);
    circle(120,40,30,M_FILL);
    line(0,0,159,143);
    color(BLACK,LTGREY,SOLID);
    box(0,130,40,143,M_NOFILL);
    box(50,130,90,143,M_FILL);

    /* Scroll the screen using the hardest method imaginable :) */
    for (c=0; c<=143; c++) {
	for (b=0; b<=142; b++) {
	    for (a=0; a<=159; a++) {
		color(getpix(a,b+1),WHITE,SOLID);
		plot_point(a,b);
	    }
	    color(WHITE,WHITE,SOLID);
	}
	line(0,143,159,143);
    }
}
Exemplo n.º 15
0
void render(double time)
   {
   int i,j;

   int width,height;

   double x,y;
   float r,g,b;

   double l;

   static double alpha=0.0,beta=0.0,gamma=0.0;

   width=get_winwidth();
   height=get_winheight();

   for (i=0; i<width; i++)
      for (j=0; j<height; j++)
         {
         x=(i+0.5)/width;
         y=(j+0.5)/height;

         l=fsqr(x-0.5)+fsqr(y-0.5);

         r=sin(300*l+alpha-PI);
         g=sin(300*l+beta);
         b=sin(300*l+gamma+PI);

         plot_color(r,g,b);
         plot_point(x,y);
         }

   if (scroll)
      {
      alpha+=0.15;
      beta+=0.3;
      gamma+=0.6;
      }
   }
Exemplo n.º 16
0
void XYGraph::plot( cairo_t *cairo, const Coordmapper *cm, const double range[4])
{
    size_t N = _xdata.size() < _ydata.size() ? _xdata.size() : _ydata.size();

    cairo_set_line_width( cairo, _linewidth );
    cairo_set_source_rgb( cairo, _color[0], _color[1], _color[2] );

    if( _histogram )
	plot_histogram_lines( cairo, cm, range, N );
    else
	plot_standard_lines( cairo, cm, range, N );

    if( _pointstyle != XYGRAPH_POINT_DISABLE ) {
	for( size_t a = 0; a < N; a++ ) {
	    double x = _xdata[a];
	    double y = _ydata[a];
	    if( comp_isnan(x) || comp_isnan(y) )
		continue;

	    cm->transform( x, y );
	    plot_point( cairo, x, y );
	}
    }
}
Exemplo n.º 17
0
void viz_update(void) {
    SDL_Rect rect;
    object_list *l;
    object *o;
    int i;
    object *last_object;
    object *last_point;
    
    
    // clear screen
    set_color(1, 1, 1);
    SDL_FillRect(screen, NULL, current_color);
    
    
    
    
    // draw known objects
    for (l = static_objects; l; l = l->next) {
        o = l->data;
        switch (o->kind) {
            case 'b':
                set_color(.4, .4, .4);
                break;
            case 'c':
                set_color(.7, .4, .3);
                break;
            case 'h':
                set_color(0, 1, 0);
                break;
            default:
                set_color(1, 0, 1);
                break;
        }
        plot_point(o->x, o->y, o->a);

    }
    for (l = martians; l; l = l->next) {
        set_color(1, 0, 0);
        o = l->data;
        plot_point(o->x, o->y, 3);
        plot_vector(o->x, o->y, o->a, o->b);
    }
    
    last_point = NULL;
    last_object = NULL;
    for (l = viz_checked_points; l; l = l->next) {
        o = l->data;
        
        if (last_object == NULL) {
            last_object = o;
        }
        
        if (last_point == NULL) {
            last_point = o;
            i = 0;
        }
        
        if (last_object->kind != viz_decided_path) {
            set_color(.5, .5, 1);
        } else {
            set_color(0, 0, 1);
        }
        
        if (last_object->kind != o->kind) {
            plot_line(last_point->x, last_point->y, last_object->x, last_object->y);
            last_point = NULL;
            i = 0;
        }
        
        if (i > 5) {
            plot_line(last_point->x, last_point->y, o->x, o->y);
            last_point = o;
            i = 0;
        }
        
        last_object = o;
        
        i++;
    }
    if (last_point && last_object) {
        plot_line(last_point->x, last_point->y, last_object->x, last_object->y);
    }
    
    // draw destination
    //set_color(.5, .5, 1);
    //plot_point(destination_x, destination_y, 0);
    
    // draw rover
    set_color(0, .5, 0);
    plot_point(last_telemetry.vehicle_x, last_telemetry.vehicle_y, 3);
    
    // draw rover's vector
    plot_vector(last_telemetry.vehicle_x, last_telemetry.vehicle_y, last_telemetry.vehicle_dir, last_telemetry.vehicle_speed);
    
    SDL_Flip(screen);
    
    //fprintf(stderr, "Done\n");
}
Exemplo n.º 18
0
int PlotArea::do_plot(const char *commands, bool clear)
{
    // Discard all commands up to `G' command, if any
    int discard = -1;

    {
      const char *cmds = commands;
      while (*cmds != '\0')
	{
	  if (cmds[0] == 'G' && cmds[1] == '\n')
	    {
	      if (pending_plots > 0)
		pending_plots--;
	      
	      discard = (cmds - commands);
	    }
	  
	  while (*cmds != '\n' && *cmds != '\0')
	    cmds++;
	  if (*cmds != '\0')
	    cmds++;
	}
    }

    // Process commands
    const char *cmds = commands;
    if (discard >= 0)
    {
	cmds += discard;
	assert(cmds[0] == 'G');
	assert(cmds[1] == '\n');
    }

#if 0				// FIXME: Not thoroughly tested yet  -AZ
    if (discard < 0 && pending_plots > 0)
	return discard;
#endif

    while (cmds[0] != '\0')
    {
	const char *command_begin = cmds;

	// Move CMDS to the next line
	while (*cmds != '\0' && *cmds != '\n')
	    cmds++;
	if (*cmds == '\0')
	    break;		// Command is incomplete - don't do it
	assert(*cmds == '\n');
	cmds++;

	// Copy current command to a NULL-terminated string. Otherwise, 
        // sscanf() takes far too much time.
	const int len_ = cmds-command_begin-1;
	assert(len_ >= 0);
	const string command_s(command_begin,len_);

	const char *command = command_s.chars();
	switch (command[0])
	{
	case 'V':
	    if (win)
		plot_vector(command);
	    break;

	case 'M':
	    if (win)
		plot_move(command);
	    break;

	case 'T':
	    if (win)
		plot_text(command);
	    break;

	case 'J':
	    if (win)
		plot_justify(command);
	    break;

	case 'L':
	    if (win)
		plot_linetype(command);
	    break;

	case 'P':
	    if (win)
		plot_point(command);
	    break;

	case 'G':
	    plot_reset(command);
	    if (win && clear)
		plot_clear(command);
	    break;

	case 'E':
	case 'R':
	    if (win)
		plot_nop(command);
	    break;

	default:
	    plot_unknown(command);
	    break;
	}
    }

    return discard;
}
Exemplo n.º 19
0
bool midPointLineDrawer(cv::Mat* inputMat, int* x, int* y) {
    if (y[0] == y[1]) {
        if (x[0] == x[1]) return true;

        int step = x[0] > x[1]? -1: 1;
        for (int i = x[0]; i <= x[1]; i += step)
            plot_point(inputMat, i, y[0]);
    }
    if (x[0] == x[1]) {
        int step = y[0] > y[1]? -1: 1;
        for (int i = y[0]; i <= y[1]; i += step)
            plot_point(inputMat, x[0], i);
    }

    // sort the x, y in order, and consider the case where K > 1
    float k_slope = float(y[0] - y[1]) / (x[0] - x[1]);
    if (fabs(k_slope) > 1.0) {
        for (int i = 0; i <= 1; i++) {
            int temp = x[i];
            x[i] = y[i];
            y[i] = temp;
        }
    }
    else printf("NOt running?\n");
    sort_point(x, y);
    printf("start at %d,%d, %d,%d\n", x[0], y[0], x[1], y[1]);
    float d_1 = 2.0 * float(y[0] - y[1]);
    float d = d_1 + float(x[1] - x[0]);
    float d_2 = d + float(x[1] - x[0]);
    printf("start with d_1 = %f, d_2 = %f, d = %f\n", d_1,d_2,d);
    int y_i = y[0];
    int x_i = x[0];
    if (fabs(k_slope) > 1) plot_point(inputMat, y_i, x_i);
    else plot_point(inputMat, x_i, y_i);

    for (int x_i = x[0]; x_i <= x[1]; x_i ++) {
        printf("Now at %d, %d, d = %f\n", x_i, y_i, d);
        if (k_slope > 0) {
            if (d < 0) {
                y_i ++;
                d += d_2;
            }
            else {
                d += d_1;
            }
        }
        else {
            if (d < 0) {
                d += d_1;
            }
            else {
                y_i --;
                d += 2 * (float(y[0]-y[1]) - float(x[1] - x[0])); //a-b
            }
        }
        if (fabs(k_slope) > 1) plot_point(inputMat, y_i, x_i);
        else plot_point(inputMat, x_i, y_i);
    }
    printf("Using the DDA methods\n");
    return true;
}
Exemplo n.º 20
0
int makePlot_uvB_MRI()
{

  TCanvas *c_uvB = new TCanvas();
  TH1 *h_uvB = c_uvB->DrawFrame(0, 1.0, 550, 5.0);
  // h_uvB->SetTitle("Permeability of Epoxy/Steel Ferromagnets");
  h_uvB->SetTitle("");
  h_uvB->GetXaxis()->SetTitle("B_{0} (mT)");
  h_uvB->GetXaxis()->SetTitleOffset(1.5);
  h_uvB->GetYaxis()->SetTitle("#mu_{r}");
  h_uvB->GetYaxis()->SetTitleOffset(1.0);
  /*Create Legend*/
  TLegend *leg_uvB = new TLegend(0.45,0.65,0.83,0.85);
  leg_uvB->SetNColumns(1);
  leg_uvB->Draw();

  const bool plot_554ramp = true;
  const bool plot_699ramp2 = true;
  const bool plot_699ramp3 = true;
  const bool plot_699ramp4 = true;
  const bool plot_699ramp5 = true;
  const bool plot_618ramp = true;

  const bool plot_554at200 = true;
  const bool plot_618at200 = true;
  const bool plot_673at200 = true;
  const bool plot_699at200 = true;

  const bool plot_554at300 = true;
  const bool plot_618at300 = true;
  const bool plot_673at300 = true;
  const bool plot_699at300 = true;

  const bool plot_554at400 = true;
  const bool plot_618at400 = true;
  const bool plot_673at400 = true;
  const bool plot_699at400 = true;

  const bool plot_554at500 = true;
  const bool plot_618at500 = true;
  const bool plot_673at500 = true;
  const bool plot_699at500 = true;

  const bool ideal_cloak = true;
  const bool exp_cloak = true;

//   vector<double> u, Fm, u_err, Fm_err;

//   /*Include Point for Fm = 0.0, No Steel Powder*/
//   u.push_back(1.0);
//   Fm.push_back(0.0);
//   u_err.push_back(0.03);
//   Fm_err.push_back(0.0);

//   /*Include Point for Fm = 1.0, Only Steel Powder*/
//   // u.push_back(1000.);
//   // Fm.push_back(1.0);
//   // u_err.push_back(0.0);
//   // Fm_err.push_back(0.0);

  if(plot_554at200)
    {
      /*
       * Permeability Plot for Fm = 0.544 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_20-31-45.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm554_di.txt";
      const TString do_file = "diameter-files/fm554_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      // g_fm554->SetLineColor(kRed);
      g_fm554->SetMarkerColor(kBlue);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
      leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.554" , "p");
    }

  if(plot_554at300)
    {
      /*
       * Permeability Plot for Fm = 0.544 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_20-58-06.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm554_di.txt";
      const TString do_file = "diameter-files/fm554_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kBlue);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_554at400)
    {
      /*
       * Permeability Plot for Fm = 0.544 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-18-15.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm554_di.txt";
      const TString do_file = "diameter-files/fm554_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kBlue);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_554at500)
    {
      /*
       * Permeability Plot for Fm = 0.544 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-37-52.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm554_di.txt";
      const TString do_file = "diameter-files/fm554_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kBlue);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_618at200)
    {
      /*
       * Permeability Plot for Fm = 0.618 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_20-35-17.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm618_di.txt";
      const TString do_file = "diameter-files/fm618_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kGreen+2);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
      leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.618" , "p");

    }

  if(plot_618at300)
    {
      /*
       * Permeability Plot for Fm = 0.618 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-00-57.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm618_di.txt";
      const TString do_file = "diameter-files/fm618_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kGreen+2);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_618at400)
    {
      /*
       * Permeability Plot for Fm = 0.618 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-20-51.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm618_di.txt";
      const TString do_file = "diameter-files/fm618_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kGreen+2);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_618at500)
    {
      /*
       * Permeability Plot for Fm = 0.618 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-40-20.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm618_di.txt";
      const TString do_file = "diameter-files/fm618_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kGreen+2);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_673at200)
    {
      /*
       * Permeability Plot for Fm = 0.673 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_20-37-24.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm673_di.txt";
      const TString do_file = "diameter-files/fm673_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P");
      g_fm554->SetMarkerColor(kMagenta);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
      leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.673" , "p");

    }

  if(plot_673at300)
    {
      /*
       * Permeability Plot for Fm = 0.618 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-03-21.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm673_di.txt";
      const TString do_file = "diameter-files/fm673_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kMagenta);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_673at400)
    {
      /*
       * Permeability Plot for Fm = 0.618 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-22-51.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm673_di.txt";
      const TString do_file = "diameter-files/fm673_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kMagenta);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_673at500)
    {
      /*
       * Permeability Plot for Fm = 0.618 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-42-13.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm673_di.txt";
      const TString do_file = "diameter-files/fm673_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kMagenta);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }


  if(plot_699at200)
    {
      /*
       * Permeability Plot for Fm = 0.699 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_20-29-24.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kRed);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
      leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.699" , "p");

    }

  if(plot_699at300)
    {
      /*
       * Permeability Plot for Fm = 0.699 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_20-54-13.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kRed);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_699at400)
    {
      /*
       * Permeability Plot for Fm = 0.699 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-15-59.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kRed);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_699at500)
    {
      /*
       * Permeability Plot for Fm = 0.699 Ferromagnet
       */
      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-36-02.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_point(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kRed);
      g_fm554->SetMarkerStyle(22);
      g_fm554->SetMarkerSize(1.5);
    }

  if(plot_554ramp)
    {
      /*
       * Permeability Plot for Fm = 0.554 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_19-56-40.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm554_di.txt";
      const TString do_file = "diameter-files/fm554_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_ramp(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      // g_fm554->SetLineColor(kRed);
      g_fm554->SetMarkerColor(kBlue);
      // leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.554 Ramp" , "p");

    }

  if(plot_699ramp2)
    {
      /*
       * Permeability Plot for Fm = 0.699 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_20-14-15.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_ramp(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kRed);
      // leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.699 Ramp" , "p");

    }

  if(plot_699ramp3)
    {
      /*
       * Permeability Plot for Fm = 0.699 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_20-41-31.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_ramp(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kRed);
      // leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.699 Ramp" , "p");

    }

  if(plot_699ramp4)
    {
      /*
       * Permeability Plot for Fm = 0.699 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-06-35.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_ramp(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kRed);
      // leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.699 Ramp" , "p");

    }

  if(plot_699ramp5)
    {
      /*
       * Permeability Plot for Fm = 0.699 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-25-26.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_ramp(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kRed);
      // leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.699 Ramp" , "p");

    }

  if(plot_618ramp)
    {
      /*
       * Permeability Plot for Fm = 0.618 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-45-58.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm699_di.txt";
      const TString do_file = "diameter-files/fm699_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_ramp(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kGreen+2);
      // leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.699 Ramp" , "p");

    }

  if(plot_673ramp)
    {
      /*
       * Permeability Plot for Fm = 0.673 Ferromagnet
       */

      const TString fmscan_fm554 = "data/DATA_MegaVIEW/DataFile_2016-12-08_21-45-58.txt";
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm673_di.txt";
      const TString do_file = "diameter-files/fm673_do.txt";
      double R_fm554 = ratio(di_file, do_file);
      double R_sig_fm554 = r_sig(di_file, do_file);
      /*Plot u vs B for FM*/
      TGraphErrors *g_fm554 = plot_ramp(fmscan_fm554, R_fm554, R_sig_fm554);
      g_fm554->Draw("P"); 
      g_fm554->SetMarkerColor(kGreen+2);
      // leg_uvB->AddEntry( g_fm554 , "F_{m} = 0.699 Ramp" , "p");

    }

  if(ideal_cloak)
    {
      /*Calculate Radius Ratio and Uncertainty*/
      const TString di_file = "diameter-files/fm554_di.txt";
      const TString do_file = "diameter-files/fm554_do.txt";
      double R_fv30 = ratio(di_file, do_file);
      // cout << R_fv30 << endl;
      double R_sig_fv30 = r_sig(di_file, do_file);
      // cout << R_sig_fv30 << endl;
      /*Calculate theoretical permeability of ferromagnet*/
      double u_cloak = (1. + pow(R_fv30,2.)) / (1. - pow(R_fv30,2.));
      cout << "Desired Permeability: " << u_cloak << endl;
      /*Draw Line for Permeability of Ideal Cloak*/
      TLine *l_ucloak = new TLine(0.0, u_cloak, 500.0, u_cloak);
      l_ucloak->SetLineStyle(2);
      l_ucloak->Draw();
      leg_uvB->AddEntry( l_ucloak , "Ideal Cloak - Theory" , "l");

      TLine *l_ucloak2 = new TLine(0.0, 2.0706, 500.0, 2.0706);
      l_ucloak2->SetLineStyle(2);
      l_ucloak2->SetLineColor(kBlue);
      l_ucloak2->Draw();
      leg_uvB->AddEntry( l_ucloak2 , "Ideal Cloak - Experiment" , "l");
    }

//   /*
//    * Plot of Permeability vs Fractional Mass of Steel Powder in Ferromagnet
//    */
//   TGraphErrors *g_uvFm = new TGraphErrors(Fm.size(), &(Fm[0]), &(u[0]), &(Fm_err[0]), &(u_err[0]) );
//   //TGraph *g_uvFm = new TGraph(Fm.size(), &(Fm[0]), &(u[0]) );
//   TCanvas *c_uvFm = new TCanvas();
//   g_uvFm->Draw("AP");
//   TF1 *fit = new TF1("fit", "[0]/TMath::Tan([1]*x + [2]) + [3]", 0.0, 1.0);
//   fit->SetParameter(0, 2.0);
//   fit->SetParameter(1, 1.0); 
//   fit->SetParameter(2, 1.0);
//   fit->SetParameter(3, 1.0);
//   g_uvFm->Fit("fit");
//   // g_uvFm->Fit("pol3");
//   g_uvFm->SetTitle("#mu_{r} vs F_{m}");
//   g_uvFm->GetXaxis()->SetTitle("F_{m}");
//   g_uvFm->GetYaxis()->SetTitle("#mu_{r}");
//   cout << g_uvFm->GetFunction("fit")->GetChisquare() << endl;
//   cout << g_uvFm->GetFunction("fit")->GetNDF() << endl;

//   /*Save plots to png and eps files*/     
      
//   // c_uvB->Print("../../Plots/uvB/EpoxySteel_uvB_161208.png");
//   // c_uvFm->Print("../../Plots/uvB/EpoxySteel_uvFm_161208.png");

  return 0;
}
Exemplo n.º 21
0
Arquivo: gsw.c Projeto: Stray/CBofN
int main(int argc, char **argv)
{
  extern int plot_mag;
  extern int plot_inverse;
  int t, i, j;

  get_options(argc, argv, options, help_string);

  plot_inverse = invert;
    plot_mag = mag;
  plot_init(width, height, 4, term);
  plot_set_all(0);

  srandom(seed);
  initialize_world();
  /* Make the sub sample size sane. */
  if(samp <= 0) samp = MIN(width, height);

  /* For each time step... */
  for(t = 0; t < steps; t++) {
    plants = herbs = carns = 0;

    /* For evey cell. */
    for(i = 0; i < height; i++)
      for(j = 0; j < width; j++) {
        world[i][j].mark = 0;
        if(t % pfreq == 0) plot_point(i, j, world[i][j].type);

        /* Count the life forms in the subsample grid. */
        if(i < samp && j < samp) {
          if(world[i][j].type == PLANT) plants++;
          else if(world[i][j].type == HERB) herbs++;
          else if(world[i][j].type == CARN) carns++;
        }
      }

    /* Do not allow extinctions, if appropriate. */
    if(noext) {
      if(herbs == 0) {
        i = random_range(0, height);
        j = random_range(0, width);
        world[i][j].type = HERB;
        world[i][j].energy = Eh;
        herbs = 1;
      }
      if(carns == 0) {
        i = random_range(0, height);
        j = random_range(0, width);
        world[i][j].type = CARN;
        world[i][j].energy = Ec;
        carns = 1;
      }
    }

    if(stats) fprintf(stderr, "%d\t%d\t%d\n", plants, herbs, carns);

    update_plants();
    update_herbs();
    update_carns();
  }

  plot_finish();
  exit(0);
}
Exemplo n.º 22
0
//Use Bresenham's algorithm
void draw_line(VB_POINT pstart, VB_POINT pend)
{
	VB_POINT pcurr;
	int do_swap = 0; /* Iterate over Y if 1 */
	//int do_reverse = 0;  /* End point < Start point if 1 */
	short dx, dy;
	//short di; /* Change in independent var */
	//short dd; /* Change in dependent var */
	//short curr_dv, start_iv, end_iv, start_dv, end_dv;
	//short * curr_x, * curr_y;

	dx = iabs(pend.x - pstart.x);
	dy = iabs(pend.y - pstart.y);

	/* If y changes at a faster rate than y, do all calculations relative to
	y (i.e. y is independent var), and reverse vars when plotting. */
	do_swap = (dx < dy);

	//error = 2*dd - di;

	plot_point(pstart);
	pcurr = pstart;

	/* X is independent var */
	if(!do_swap && (pend.x >= pstart.x))
	{
		long error = 2*dy - dx;
		while(++pcurr.x <= pend.x)
		{
			if(error > 0)
			{
				if(pend.y > pstart.y)
				{
					pcurr.y = pcurr.y + 1;
				}
				else
				{
					pcurr.y = pcurr.y - 1;
				}

				error += (2*dy - 2*dx);
			}
			else
			{
				error += 2*dy;
			}

			plot_point(pcurr);
		}
	}
	else if(!do_swap && (pend.x <= pstart.x))
	{
		long error = 2*dy - dx;
		while(--pcurr.x >= pend.x)
		{
			if(error > 0)
			{
				if(pend.y > pstart.y)
				{
					pcurr.y = pcurr.y + 1;
				}
				else
				{
					pcurr.y = pcurr.y - 1;
				}

				error += (2*dy - 2*dx);
			}
			else
			{
				error += 2*dy;
			}

			plot_point(pcurr);
		}
	}

	/* Y is independent var */
	else if(do_swap && (pend.y > pstart.y))
	{
		long error = 2*dx - dy;
		while(++pcurr.y <= pend.y)
		{
			if(error > 0)
			{
				if(pend.x > pstart.x)
				{
					pcurr.x = pcurr.x + 1;
				}
				else
				{
					pcurr.x = pcurr.x - 1;
				}

				error += (2*dx - 2*dy);
			}
			else
			{
				error += 2*dx;
			}

			plot_point(pcurr);
		}
	}
	else if(do_swap && (pend.y < pstart.y))
	{
		long error = 2*dx - dy;
		while(--pcurr.y >= pend.y)
		{
			if(error > 0)
			{
				if(pend.x > pstart.x)
				{
					pcurr.x = pcurr.x + 1;
				}
				else
				{
					pcurr.x = pcurr.x - 1;
				}

				error += (2*dx - 2*dy);
			}
			else
			{
				error += 2*dx;
			}

			plot_point(pcurr);
		}
	}
}