ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tornado.py
Go to the documentation of this file.
1 # To see the output of this macro, click begin_html <a href="gif/tornado.gif" >here</a> end_html
2 
3 from ROOT import TCanvas, TView, TPolyMarker3D, TPaveText
4 from ROOT import gROOT, gBenchmark
5 from math import cos, sin, pi
6 
7 
8 
9 gBenchmark.Start( 'tornado' )
10 
11 d = 16
12 numberOfPoints = 200
13 numberOfCircles = 40
14 
15 # create and open a canvas
16 sky = TCanvas( 'sky', 'Tornado', 300, 10, 700, 500 )
17 sky.SetFillColor( 14 )
18 
19 # creating view
21 rng = numberOfCircles * d
22 view.SetRange( 0, 0, 0, 4.0*rng, 2.0*rng, rng )
23 
24 polymarkers = []
25 for j in range( d, numberOfCircles * d, d ):
26 
27  # create a PolyMarker3D
28  pm3d = TPolyMarker3D( numberOfPoints )
29 
30  # set points
31  for i in xrange( 1, numberOfPoints ) :
32  csin = sin( 2*pi / numberOfPoints * i ) + 1
33  ccos = cos( 2*pi / numberOfPoints * i ) + 1
34  esin = sin( 2*pi / (numberOfCircles*d) * j ) + 1
35  x = j * ( csin + esin );
36  y = j * ccos;
37  z = j;
38  pm3d.SetPoint( i, x, y, z );
39 
40  # set marker size, color & style
41  pm3d.SetMarkerSize( 1 )
42  pm3d.SetMarkerColor( 2 + ( d == ( j & d ) ) )
43  pm3d.SetMarkerStyle( 3 )
44 
45  # draw
46  pm3d.Draw()
47 
48  # save a reference
49  polymarkers.append( pm3d )
50 
51 gBenchmark.Show( 'tornado' )
52 
53 ct = gBenchmark.GetCpuTime( 'tornado' )
54 timeStr = 'Execution time: %g sec.' % ct
55 
56 text = TPaveText( 0.1, 0.81, 0.9, 0.97 )
57 text.SetFillColor( 42 )
58 text.AddText( 'PyROOT example: tornado.py' )
59 text.AddText( timeStr )
60 text.Draw()
61 
62 sky.Update()
double cos(double)
double sin(double)
static TView * CreateView(Int_t system=1, const Double_t *rmin=0, const Double_t *rmax=0)
Create a concrete default 3-d view via the plug-in manager.
Definition: TView.cxx:36