tornado.C

Go to the documentation of this file.
00001 void tornado() {
00002 //Show 3-d polymarkers
00003 // To see the output of this macro, click begin_html <a href="gif/tornado.gif" >here</a> end_html
00004 //Author: Rene Brun
00005    
00006     gBenchmark->Start("tornado");
00007 
00008     double PI = 3.141592653;
00009     int d = 16;
00010     int numberOfPoints=200;
00011     int numberOfCircles=40;
00012 
00013     // create and open a canvas
00014     TCanvas *sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 );
00015     sky->SetFillColor(14);
00016 
00017     // creating view
00018     TView *view = TView::CreateView(1,0,0);
00019     float range = numberOfCircles*d;
00020     view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range );
00021 
00022     for( int j = d; j < numberOfCircles*d; j += d ) {
00023 
00024         // create a PolyMarker3D
00025         TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints );
00026 
00027         float x, y, z;
00028 
00029         // set points
00030         for( int i = 1; i < numberOfPoints; i++ ) {
00031             float csin = sin(2*PI / (double)numberOfPoints  * (double)i) + 1;
00032             float ccos = cos(2*PI / (double)numberOfPoints  * (double)i) + 1;
00033             float esin = sin(2*PI / (double)(numberOfCircles*d) * (double)j) + 1;
00034             x = j * ( csin + esin );
00035             y = j * ccos;
00036             z = j;
00037             pm3d->SetPoint( i, x, y, z );
00038         }
00039 
00040         // set marker size, color & style
00041         pm3d->SetMarkerSize( 1 );
00042         pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) );
00043         pm3d->SetMarkerStyle( 3 );
00044 
00045         //draw
00046         pm3d->Draw();
00047     }
00048 
00049     char timeStr[60];
00050     gBenchmark->Show("tornado");
00051 
00052     Float_t ct = gBenchmark->GetCpuTime("tornado");
00053     sprintf( timeStr, "Execution time: %g sec.", ct);
00054 
00055     TPaveText *text = new TPaveText( 0.1, 0.81, 0.9, 0.97 );
00056     text->SetFillColor( 42 );
00057     text->AddText("ROOT example: tornado.C");
00058     text->AddText(timeStr);
00059     text->Draw();
00060     sky->Update();
00061 }

Generated on Tue Jul 5 15:44:22 2011 for ROOT_528-00b_version by  doxygen 1.5.1