Exemplo n.º 1
0
 /* Plot the trace of the walk */
 void plotWalk() const
     {
     Plotter2D Plotter;
     auto L = makePlot2DLattice(*this, std::string("OERRW-d") + mtools::toString(delta));
     L.setImageType(L.TYPEIMAGE);
     Plotter[L];
     Plotter.gridObject(true)->setUnitCells();
     Plotter.range().setRange(zoomOut(fBox2(R)));
     Plotter.plot();
     }
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	MTOOLS_SWAP_THREADS(argc, argv);         // required on OSX, does nothing on Linux/Windows

	RGBc RR = RGBc::c_Red.getMultOpacity(0.5);
	RGBc GG = RGBc::c_Green.getMultOpacity(0.5);
	RGBc BB = RGBc::c_Blue.getMultOpacity(0.5);

	RGBc FF = RGBc::c_Yellow.getMultOpacity(0.5f);

	int64 L = 50;

	TestImage im(L, L);
	im.clear(RGBc(240,240,240));

	using namespace internals_bseg;




	fVec2 P1(10,10);

	fVec2 P2(37.49,25.49);

	fVec2 P3(13,20.99);

	im._bseg_draw(BSeg(P1, P2), true, RR);
	im._bseg_avoid1(BSeg(P1, P3), true, BSeg(P1, P2), true, GG);
	im._bseg_avoid11(BSeg(P2, P3), BSeg(P2, P1), true, BSeg(P3, P1), true, BB);

	im._bseg_fill_triangle(P1, P2, P3, FF);


	/*
	im.blendPixel({ 40, 9 }, BB);
	im.blendPixel({ 10, 9 }, BB);
	im.blendPixel({ 20, 9 }, BB);
	im.blendPixel({ 30, 9 }, BB);
	*/
	Plotter2D plotter;
	auto P = makePlot2DImage(im);
	plotter[P];
	plotter.range().setRange(fBox2{ -0.5, L - 0.5, -0.5, L - 0.5});

	plotter.gridObject(true);
	plotter.gridObject()->setUnitCells();

	plotter.plot();

	return 0;
	}
Exemplo n.º 3
0
int main(int argc, char *argv[]) 
    {
    MTOOLS_SWAP_THREADS(argc, argv);		
    parseCommandLine(argc, argv, true);
    cout << "**************************************\n";
    cout << "Simulation of a 1D simple random walk.\n";
    cout << "**************************************\n";
    bool autorange = arg("auto").info("update the plotter's range automatically"); 
    cout << "\nSimulating...\n";
    MT2004_64 gen;                      // the RNG
    std::vector<int>  tab;              // the vector containing the positions
    int pos = 0;                        // current position
    Plotter2D P;                        // the plotter object
    auto PF1 = makePlot2DFun(f1);       // the first function plot object
    auto PF2 = makePlot2DFun(f2);       // the second function plot object
    auto PV = makePlot2DVector(tab);    // the vector plot, use natural dynamically growing range.
    P[PV][PF1][PF2];                    // insert everything in the plotter
    PV.interpolationLinear();           // use linear interpolation
    PV.hypograph(true);                 // fill the hypograph
    PV.hypographOpacity(0.3f);          // but make it half transparent
    P.autoredraw(60);                   // the plotter window should redraw itself at least every second (more in fact since it redraws after unsuspending)
    P.range().fixedAspectRatio(false);  // disable the fixed aspect ratio
    if (!autorange) P.range().setRange(fBox2(-1.0e7, 5.0e8, -60000, 60000)); // set the range (if not automatic adjustment)
    P.startPlot();                      // display the plotter
    while (P.shown())                   // loop until the plotter window is closed
        {
        while (tab.size() < tab.capacity()) { pos += ((Unif(gen) < 0.5) ? -1 : 1); tab.push_back(pos); } // fill the vector with new steps of the walk until its capacity()
        PV.suspend(true);      // suspend access to PV while we reallocate the vector memory.
        tab.reserve(tab.capacity() + 1000000); // reserve more space
        PV.suspend(false);     // resume access to the graph.
        if (autorange) P.autorangeXY(); // autorange (causes a redraw)
        }
    return 0;
  	}
Exemplo n.º 4
0
/* run the simulation */
void run()
{
    cout << "\nSimulating : zoom in to view the details of the tree structure...\n";
    auto P = makePlot2DLattice(EC, "Tree Eden model"); P.opacity(0.5);
    P.setImageType(P.TYPEIMAGE);
    Plotter2D Plotter;
    Plotter[P];
    Plotter.startPlot();
    Plotter.range().setRange(unionRect(mtools::zoomOut(EC.range()), fBox2(-5000, 5000, -5000, 5000)));
    Plotter.autoredraw(600);
    cout << EC.toString();
    watch("Cluster size", EC, printSize);
    while (Plotter.shown())
        {
        if (EC.size() % 10000000 == 0) cout << EC.toString();
        EC.simulate(1000000);
        }
    watch.remove("Cluster size");
    return;
}
Exemplo n.º 5
0
int main(int argc, char *argv[]) 
    {
    MTOOLS_SWAP_THREADS(argc, argv);		
	parseCommandLine(argc,argv,false);
    cout << "******************************\n";
    cout << "internal DLA on Z2\n";
    cout << "******************************\n";
    int autoredraw = arg('a', 300).info("autoredraw rate");
    Grid.reset(0, 1, false);
    Grid.set(0, 0, 1); // initial cluster. 
    Plotter2D P;
    auto Cl = makePlot2DLattice(LatticeObj<colorCluster>::get(), "iDLA cluster"); P[Cl]; Cl.opacity(0.5);
    auto Ci = makePlot2DLattice(LatticeObj<colorCircle>::get(), "Circle"); P[Ci]; Ci.opacity(0.5);
    P.autoredraw(autoredraw);
    P.startPlot();
    Chronometer();
    watch("# of particles", N);
    while (P.shown())
        {
        makeCluster(1000);
        }
    return 0;
	}
Exemplo n.º 6
0
int main(int argc, char *argv[])
  {	
  MTOOLS_SWAP_THREADS(argc,argv);         // required on OSX, does nothing on Linux/Windows
  cout << "Hello from the console !";     // print on mtools::cout console (saved in cout.text)
    
  Image im(800, 600, RGBc(220,220,220));  // image of size 800x600 with a light gray background
    
  // draw on the image
  im.draw_thick_filled_ellipse_in_box(fBox2( 100,400,50,550 ), 20,60, RGBc::c_Green.getMultOpacity(0.5f), RGBc::c_Cyan);
  im.draw_text({400, 300}, "Hello\n  World!",MTOOLS_TEXT_CENTER,RGBc::c_Red.getMultOpacity(0.5f), 200);
  im.draw_cubic_spline({ {10,10},{100,100},{200,30},{300,100}, {600,10} , {700,300},
      {720, 500}, {600, 480}, {400,500} }, RGBc::c_Yellow.getMultOpacity(0.5f), true, true, true, 3);
	
  // display the image
  auto P = makePlot2DImage(im);   // Encapsulate the image inside a 'plottable' object.	
  Plotter2D plotter;              // Create a plotter object
  plotter.axesObject(false);      // Remove the axe system.
  plotter[P];                     // Add the image to the list of objects to draw.  	
  plotter.autorangeXY();          // Set the plotter range to fit the image.
  plotter.plot();                 // start interactive display.
  
  return 0;
  }