3 #=======================================================================
5 # File ID: 2036c7c6-f924-11dd-b41d-0001805bf4b1
6 # Create random 3D surface for use in plotting programs.
9 # ©opyleft 2007– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 3 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
33 $progname =~ s/^.*\/(.*?)$/$1/;
34 our $VERSION = "0.00";
36 Getopt
::Long
::Configure
("bundling");
39 "debug" => \
$Opt{'debug'},
40 "help|h" => \
$Opt{'help'},
41 "max=f" => \
$Opt{'max'},
42 "min=f" => \
$Opt{'min'},
43 "verbose|v+" => \
$Opt{'verbose'},
44 "version" => \
$Opt{'version'},
46 ) || die("$progname: Option error. Use -h for help.\n");
48 $Opt{'debug'} && ($Debug = 1);
49 $Opt{'help'} && usage
(0);
50 if ($Opt{'version'}) {
65 my $Left = defined($Ele[$Lat][$Lon-1]) ?
$Ele[$Lat][$Lon-1] : rand(1);
66 my $Right = defined($Ele[$Lat][$Lon+1]) ?
$Ele[$Lat][$Lon+1] : rand(1);
67 my $Over = defined($Ele[$Lat+1][$Lon]) ?
$Ele[$Lat+1][$Lon] : rand(1);
68 my $Under = defined($Ele[$Lat-1][$Lon]) ?
$Ele[$Lat-1][$Lon] : rand(1);
69 my $Curr = ($Left+$Right+$Over+$Under)/4;
70 $Curr += rand(1) >= 0.5 ?
rand(1) : 0-rand(1);
71 # until ($Curr >= $Opt{'min'}) {
73 # $Curr += rand(1) * 1.0;
75 # until ($Curr <= $Opt{'max'}) {
77 # $Curr -= rand(1) * 1.0;
79 if ($Lat > 0 && $Lat < $Size && $Lon > 0 && $Lon < $Size) {
80 # print("$Lat\t$Lon\t$Curr\n");
81 # print($Lat . "\t" . $Lon-1 . "\t" . $Left . "\n");
82 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
84 print($Lat+1 . "\t" . $Lon . "\t" . $Over . "\n");
85 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
87 # print($Lat . "\t" . $Lon+1 . "\t" . $Right . "\n");
88 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
90 print($Lat-1 . "\t" . $Lon . "\t" . $Under . "\n");
91 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
94 $Ele[$Lat][$Lon] = $Curr;
98 last if ($Lat > $Size);
102 # Print program version {{{
103 print("$progname v$VERSION\n");
108 # Send the help message to stdout {{{
111 if ($Opt{'verbose'}) {
117 Usage: $progname [options] [file [files [...]]]
124 Increase level of verbosity. Can be repeated.
126 Print version information.
128 Print debugging messages.
136 # Print a status message to stderr based on verbosity level {{{
137 my ($verbose_level, $Txt) = @_;
139 if ($Opt{'verbose'} >= $verbose_level) {
140 print(STDERR
"$progname: $Txt\n");
146 # Print a debugging message {{{
148 my @call_info = caller;
149 chomp(my $Txt = shift);
150 my $File = $call_info[1];
152 $File =~ s
#^.*/(.*?)$#$1#;
153 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
160 # Plain Old Documentation (POD) {{{
170 [options] [file [files [...]]]
180 =item B<-h>, B<--help>
182 Print a brief help summary.
184 =item B<-v>, B<--verbose>
186 Increase level of verbosity. Can be repeated.
190 Print version information.
194 Print debugging messages.
204 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
208 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
209 This is free software; see the file F<COPYING> for legalese stuff.
213 This program is free software: you can redistribute it and/or modify it
214 under the terms of the GNU General Public License as published by the
215 Free Software Foundation, either version 3 of the License, or (at your
216 option) any later version.
218 This program is distributed in the hope that it will be useful, but
219 WITHOUT ANY WARRANTY; without even the implied warranty of
220 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
221 See the GNU General Public License for more details.
223 You should have received a copy of the GNU General Public License along
225 If not, see L<http://www.gnu.org/licenses/>.
233 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :