File: random.pl

package info (click to toggle)
voro%2B%2B 0.4.6%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,372 kB
  • sloc: cpp: 6,384; perl: 232; makefile: 164
file content (24 lines) | stat: -rw-r--r-- 769 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
# This script can be used to generate random lists of particles in the unit
# box 0<x<1, 0<y<1, 0<z<1, that can be used as test input to voro++. The -r
# switch adds extra radial information for use with the Voronoi radical
# tessellation.
use Getopt::Std;
getopts("hr:");

if ($opt_h) {
	print "Usage: random.pl [switches] <number of particles> <filename>\n";
	print "Switches:\n";
	print "-h                Print this information\n";
	print "-r <max radius>   Add extra radial column\n";
	exit 0;
};

@ARGV==2 or die "Exactly two command line arguments required\n";
open A,">@ARGV[1]" or die "Can't open output file";

foreach (1..@ARGV[0]) {
	printf A "$_ %f %f %f", rand(), rand(), rand();
	printf A " %f",$opt_r*rand() if $opt_r;
	printf A "\n";
}