Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
tornado.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_graphics
3## Tornado example.
4## \notebook
5##
6## \macro_image
7## \macro_code
8##
9## \author Wim Lavrijsen
10
11from ROOT import TCanvas, TView, TPolyMarker3D, TPaveText
12from ROOT import gROOT, gBenchmark
13from math import cos, sin, pi
14
15gBenchmark.Start( 'tornado' )
16
17d = 16
18numberOfPoints = 200
19numberOfCircles = 40
20
21# create and open a canvas
22sky = TCanvas( 'sky', 'Tornado', 300, 10, 700, 500 )
23sky.SetFillColor( 14 )
24
25# creating view
26view = TView.CreateView()
27rng = numberOfCircles * d
28view.SetRange( 0, 0, 0, 4.0*rng, 2.0*rng, rng )
29
30polymarkers = []
31for j in range( d, numberOfCircles * d, d ):
32
33 # create a PolyMarker3D
34 pm3d = TPolyMarker3D( numberOfPoints )
35
36 # set points
37 for i in range( 1, numberOfPoints ) :
38 csin = sin( 2*pi / numberOfPoints * i ) + 1
39 ccos = cos( 2*pi / numberOfPoints * i ) + 1
40 esin = sin( 2*pi / (numberOfCircles*d) * j ) + 1
41 x = j * ( csin + esin );
42 y = j * ccos;
43 z = j;
44 pm3d.SetPoint( i, x, y, z );
45
46 # set marker size, color & style
47 pm3d.SetMarkerSize( 1 )
48 pm3d.SetMarkerColor( 2 + ( d == ( j & d ) ) )
49 pm3d.SetMarkerStyle( 3 )
50
51 # draw
52 pm3d.Draw()
53
54 # save a reference
55 polymarkers.append( pm3d )
56
57gBenchmark.Show( 'tornado' )
58
59ct = gBenchmark.GetCpuTime( 'tornado' )
60timeStr = 'Execution time: %g sec.' % ct
61
62text = TPaveText( 0.1, 0.81, 0.9, 0.97 )
63text.SetFillColor( 42 )
64text.AddText( 'PyROOT example: tornado.py' )
65text.AddText( timeStr )
66text.Draw()
67
68sky.Update()
The Canvas class.
Definition TCanvas.h:23
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
A 3D polymarker.
static TView * CreateView(Int_t system=1, const Double_t *rmin=nullptr, const Double_t *rmax=nullptr)
Create a concrete default 3-d view via the plug-in manager.
Definition TView.cxx:27