File: Scientific_47.html

package info (click to toggle)
python-scientific 2.4.11-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,956 kB
  • ctags: 3,063
  • sloc: python: 9,157; ansic: 4,483; xml: 4,145; makefile: 126; sh: 18; csh: 1
file content (678 lines) | stat: -rw-r--r-- 8,412 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
<h1>Module Scientific.Visualization.VRML2</h1>





<p>This module provides definitions of simple 3D graphics objects and
VRML scenes containing them. The objects are appropriate for data
visualization, not for virtual reality modelling. Scenes can be written
to VRML files or visualized immediately using a VRML browser, whose
name is taken from the environment variable VRML2VIEWER (under Unix).</p>



There are a few attributes that are common to all graphics objects:

<p><dl>


<dt>material</dt>


<dd><p>
a Material object defining color and surface properties</p></dd>


<dt>comment</dt>


<dd><p>
a comment string that will be written to the VRML file</p></dd>


<dt>reuse</dt>


<dd><p>
a boolean flag (defaulting to false). If set to one,
           the object may share its VRML definition with other
           objects. This reduces the size of the VRML file, but
           can yield surprising side effects in some cases.</p></dd>


</dl>
</p>





<p>This module used the VRML 2.0 definition, also known as VRML97. For
the original VRML 1, use the module VRML, which uses exactly the same
interface. There is another almost perfectly compatible module VMD,
which produces input files for the molecular visualization program
VMD.</p>



<p>Example:</p>



<pre>
from Scientific.Visualization.VRML2 import *
scene = Scene([])
scale = ColorScale(10.)
for x in range(11):
    color = scale(x)
    scene.addObject(Cube(Vector(x, 0., 0.), 0.2,
                         material=Material(diffuse_color = color)))
scene.view()
</pre>
























<hr width=70%>
<h2>Functions</h2>





<ul>


<li> <p>

<b><i>DiffuseMaterial</i></b>()<br>


</p>



<p>Returns a material with the <tt>diffuse color</tt> attribute set to <i>color</i>.</p>

<li> <p>

<b><i>EmissiveMaterial</i></b>()<br>


</p>



<p>Returns a material with the <tt>emissive color</tt> attribute set to <i>color</i>.</p>

</ul>




<hr width=70%>
<h2>Class Scene: VRML scene</h2>





<p>A VRML scene is a collection of graphics objects that can be
written to a VRML file or fed directly to a VRML browser.</p>



<p>Constructor: Scene(<i>objects</i>=None, <i>cameras</i>=None, **|options|)</p>



<p><dl>


<dt><i>objects</i></dt>


<dd><p>
a list of graphics objects or <tt>None</tt> for an empty scene</p></dd>


<dt><i>cameras</i></dt>


<dd><p>
a list of cameras</p></dd>


<dt><i>options</i></dt>


<dd><p>
options as keyword arguments (none defined at the moment;
             this argument is provided for compatibility with
             other modules)
</p></dd>


</dl>
</p>



<b>Methods:</b><br>
<ul>
<li> <b><i>addObject</i></b>(<i>object</i>)




<p>Adds <i>object</i> to the list of graphics objects.</p>





<li> <b><i>addCamera</i></b>(<i>camera</i>)




<p>Adds <i>camera</i> to the list of cameras.</p>





<li> <b><i>writeToFile</i></b>(<i>filename</i>)




<p>Writes the scene to a VRML file with name <i>filename</i>.</p>





<li> <b><i>view</i></b>()


<p>Start a VRML browser for the scene.</p>





</ul>
<hr width=70%>
<h2>Class Camera: Camera/viewpoint for a scene</h2>





<p>Constructor: Camera(<i>position</i>, <i>orientation</i>, <i>description</i>,
                    <i>field_of_view</i>)</p>



<p><dl>


<dt><i>position</i></dt>


<dd><p>
the location of the camera (a vector)</p></dd>


<dt><i>orientation</i></dt>


<dd><p>
an (axis, angle) tuple in which the axis is
                 a vector and angle a number (in radians);
                 axis and angle specify a rotation with respect
                 to the standard orientation along the negative z axis</p></dd>


<dt><i>description</i></dt>


<dd><p>
a label for the viewpoint (a string)</p></dd>


<dt><i>field_of_view</i></dt>


<dd><p>
the field of view (a positive number)
</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class NavigationInfo: Navigation Information</h2>





<p>Constructor: NavigationInfo(<i>speed</i>, <i>type</i>)</p>



<p><dl>


<dt><i>speed</i></dt>


<dd><p>
walking speed in length units per second</p></dd>


<dt><i>type</i></dt>


<dd><p>
one of <tt>WALK</tt>, <tt>EXAMINE</tt>, <tt>FLY</tt>, <tt>NONE</tt>, <tt>ANY</tt>

</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class Sphere: Sphere</h2>





<p>Constructor: Sphere(<i>center</i>, <i>radius</i>, **|attributes|)</p>



<p><dl>


<dt><i>center</i></dt>


<dd><p>
the center of the sphere (a vector)</p></dd>


<dt><i>radius</i></dt>


<dd><p>
the sphere radius (a positive number)</p></dd>


<dt><i>attributes</i></dt>


<dd><p>
any graphics object attribute
</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class Cube: Cube</h2>





<p>Constructor: Cube(<i>center</i>, <i>edge</i>, **|attributes|)</p>



<p><dl>


<dt><i>center</i></dt>


<dd><p>
the center of the cube (a vector)</p></dd>


<dt><i>edge</i></dt>


<dd><p>
the length of an edge  (a positive number)</p></dd>


<dt><i>attributes</i></dt>


<dd><p>
any graphics object attribute</p></dd>


</dl>
</p>



<p>The edges of a cube are always parallel to the coordinate axes.
</p>



<hr width=70%>
<h2>Class Cylinder: Cylinder</h2>





<p>Constructor: Cylinder(<i>point1</i>, <i>point2</i>, <i>radius</i>,
                      <i>faces</i>=<tt>(1, 1, 1)</tt>, **|attributes|)</p>



<p><dl>


<dt><i>point1</i>, <i>point2</i></dt>


<dd><p>
the end points of the cylinder axis (vectors)</p></dd>


<dt><i>radius</i></dt>


<dd><p>
the radius  (a positive number)</p></dd>


<dt><i>attributes</i></dt>


<dd><p>
any graphics object attribute</p></dd>


<dt><i>faces</i></dt>


<dd><p>
a sequence of three boolean flags, corresponding to
           the cylinder hull and the two circular end pieces,
           specifying for each of these parts whether it is visible
           or not.
</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class Cone: Cone</h2>





<p>Constructor: Cone(<i>point1</i>, <i>point2</i>, <i>radius</i>, <i>face</i>=<tt>1</tt>, **|attributes|)</p>



<p><dl>


<dt><i>point1</i>, <i>point2</i></dt>


<dd><p>
the end points of the cylinder axis (vectors).
                      <i>point1</i> is the tip of the cone.</p></dd>


<dt><i>radius</i></dt>


<dd><p>
the radius  (a positive number)</p></dd>


<dt><i>attributes</i></dt>


<dd><p>
any graphics object attribute</p></dd>


<dt><i>face</i></dt>


<dd><p>
a boolean flag, specifying if the circular bottom is visible
</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class Line: Line</h2>





<p>Constructor: Line(<i>point1</i>, <i>point2</i>, **|attributes|)</p>



<p><dl>


<dt><i>point1</i>, <i>point2</i></dt>


<dd><p>
the end points of the line (vectors)</p></dd>


<dt><i>attributes</i></dt>


<dd><p>
any graphics object attribute
</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class PolyLines: Multiple connected lines</h2>





<p>Constructor: PolyLines(<i>points</i>, **|attributes|)</p>



<p><dl>


<dt><i>points</i></dt>


<dd><p>
a sequence of points to be connected by lines</p></dd>


<dt><i>attributes</i></dt>


<dd><p>
any graphics object attribute
</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class Polygons: Polygons</h2>





<p>Constructor: Polygons(<i>points</i>, <i>index_lists</i>, **|attributes|)</p>



<p><dl>


<dt><i>points</i></dt>


<dd><p>
a sequence of points</p></dd>


<dt><i>index_lists</i></dt>


<dd><p>
a sequence of index lists, one for each polygon.
                 The index list for a polygon defines which points
                 in <i>points</i> are vertices of the polygon.</p></dd>


<dt><i>attributes</i></dt>


<dd><p>
any graphics object attribute
</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class Arrow: Arrow</h2>





<p>An arrow consists of a cylinder and a cone.</p>



<p>Constructor: Arrow(<i>point1</i>, <i>point2</i>, <i>radius</i>, **|attributes|)</p>



<p><dl>


<dt><i>point1</i>, <i>point2</i></dt>


<dd><p>
the end points of the arrow (vectors).
                      <i>point2</i> defines the tip of the arrow.</p></dd>


<dt><i>radius</i></dt>


<dd><p>
the radius of the arrow shaft (a positive number)</p></dd>


<dt><i>attributes</i></dt>


<dd><p>
any graphics object attribute
</p></dd>


</dl>
</p>



<hr width=70%>
<h2>Class Material: Material for graphics objects</h2>





<p>A material defines the color and surface properties of an object.</p>



<p>Constructor: Material(**|attributes|)</p>



<p>The attributes are "ambient_color", "diffuse_color", "specular_color",
"emissive_color", "shininess", and "transparency".
</p>