ROOT logo

From $ROOTSYS/tutorials/graphics/tornado.C

void tornado() {
//Show 3-d polymarkers
// To see the output of this macro, click begin_html <a href="gif/tornado.gif" >here</a> end_html
//Author: Rene Brun
   
    gBenchmark->Start("tornado");

    double PI = 3.141592653;
    int d = 16;
    int numberOfPoints=200;
    int numberOfCircles=40;

    // create and open a canvas
    TCanvas *sky = new TCanvas( "sky", "Tornado", 300, 10, 700, 500 );
    sky->SetFillColor(14);

    // creating view
    TView *view = TView::CreateView(1,0,0);
    float range = numberOfCircles*d;
    view->SetRange( 0, 0, 0, 4.0*range, 2.0*range, range );

    for( int j = d; j < numberOfCircles*d; j += d ) {

        // create a PolyMarker3D
        TPolyMarker3D *pm3d = new TPolyMarker3D( numberOfPoints );

        float x, y, z;

        // set points
        for( int i = 1; i < numberOfPoints; i++ ) {
            float csin = sin(2*PI / (double)numberOfPoints  * (double)i) + 1;
            float ccos = cos(2*PI / (double)numberOfPoints  * (double)i) + 1;
            float esin = sin(2*PI / (double)(numberOfCircles*d) * (double)j) + 1;
            x = j * ( csin + esin );
            y = j * ccos;
            z = j;
            pm3d->SetPoint( i, x, y, z );
        }

        // set marker size, color & style
        pm3d->SetMarkerSize( 1 );
        pm3d->SetMarkerColor( 2 + ( d == ( j & d ) ) );
        pm3d->SetMarkerStyle( 3 );

        //draw
        pm3d->Draw();
    }

    char timeStr[60];
    gBenchmark->Show("tornado");

    Float_t ct = gBenchmark->GetCpuTime("tornado");
    sprintf( timeStr, "Execution time: %g sec.", ct);

    TPaveText *text = new TPaveText( 0.1, 0.81, 0.9, 0.97 );
    text->SetFillColor( 42 );
    text->AddText("ROOT example: tornado.C");
    text->AddText(timeStr);
    text->Draw();
    sky->Update();
}
 tornado.C:1
 tornado.C:2
 tornado.C:3
 tornado.C:4
 tornado.C:5
 tornado.C:6
 tornado.C:7
 tornado.C:8
 tornado.C:9
 tornado.C:10
 tornado.C:11
 tornado.C:12
 tornado.C:13
 tornado.C:14
 tornado.C:15
 tornado.C:16
 tornado.C:17
 tornado.C:18
 tornado.C:19
 tornado.C:20
 tornado.C:21
 tornado.C:22
 tornado.C:23
 tornado.C:24
 tornado.C:25
 tornado.C:26
 tornado.C:27
 tornado.C:28
 tornado.C:29
 tornado.C:30
 tornado.C:31
 tornado.C:32
 tornado.C:33
 tornado.C:34
 tornado.C:35
 tornado.C:36
 tornado.C:37
 tornado.C:38
 tornado.C:39
 tornado.C:40
 tornado.C:41
 tornado.C:42
 tornado.C:43
 tornado.C:44
 tornado.C:45
 tornado.C:46
 tornado.C:47
 tornado.C:48
 tornado.C:49
 tornado.C:50
 tornado.C:51
 tornado.C:52
 tornado.C:53
 tornado.C:54
 tornado.C:55
 tornado.C:56
 tornado.C:57
 tornado.C:58
 tornado.C:59
 tornado.C:60
 tornado.C:61
 tornado.C:62