3 #=======================================================================
5 # Create random 3D surface for use in plotting programs.
8 # ©opyleft 2007– Øyvind A. Holm <sunny@sunbase.org>
9 # License: GNU General Public License version 2 or later, see end of
10 # file for legal stuff.
11 #=======================================================================
34 $progname =~ s/^.*\/(.*?)$/$1/;
37 my $id_date = $rcs_id;
38 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
40 push(@main::version_array
, $rcs_id);
42 Getopt
::Long
::Configure
("bundling");
44 "debug" => \
$Opt{'debug'},
45 "help|h" => \
$Opt{'help'},
46 "max=f" => \
$Opt{'max'},
47 "min=f" => \
$Opt{'min'},
48 "verbose|v+" => \
$Opt{'verbose'},
49 "version" => \
$Opt{'version'},
50 ) || die("$progname: Option error. Use -h for help.\n");
52 $Opt{'debug'} && ($Debug = 1);
53 $Opt{'help'} && usage
(0);
54 $Opt{'version'} && print_version
();
66 my $Left = defined($Ele[$Lat][$Lon-1]) ?
$Ele[$Lat][$Lon-1] : rand(1);
67 my $Right = defined($Ele[$Lat][$Lon+1]) ?
$Ele[$Lat][$Lon+1] : rand(1);
68 my $Over = defined($Ele[$Lat+1][$Lon]) ?
$Ele[$Lat+1][$Lon] : rand(1);
69 my $Under = defined($Ele[$Lat-1][$Lon]) ?
$Ele[$Lat-1][$Lon] : rand(1);
70 my $Curr = ($Left+$Right+$Over+$Under)/4;
71 $Curr += rand(1) >= 0.5 ?
rand(1) : 0-rand(1);
72 # until ($Curr >= $Opt{'min'}) {
74 # $Curr += rand(1) * 1.0;
76 # until ($Curr <= $Opt{'max'}) {
78 # $Curr -= rand(1) * 1.0;
80 if ($Lat > 0 && $Lat < $Size && $Lon > 0 && $Lon < $Size) {
81 # print("$Lat\t$Lon\t$Curr\n");
82 # print($Lat . "\t" . $Lon-1 . "\t" . $Left . "\n");
83 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
85 print($Lat+1 . "\t" . $Lon . "\t" . $Over . "\n");
86 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
88 # print($Lat . "\t" . $Lon+1 . "\t" . $Right . "\n");
89 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
91 print($Lat-1 . "\t" . $Lon . "\t" . $Under . "\n");
92 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
95 $Ele[$Lat][$Lon] = $Curr;
99 last if ($Lat > $Size);
103 # Print program version {{{
104 for (@main::version_array
) {
112 # Send the help message to stdout {{{
119 Usage: $progname [options] [file [files [...]]]
126 Increase level of verbosity. Can be repeated.
128 Print version information.
130 Print debugging messages.
138 # Print a status message to stderr based on verbosity level {{{
139 my ($verbose_level, $Txt) = @_;
141 if ($Opt{'verbose'} >= $verbose_level) {
142 print(STDERR
"$progname: $Txt\n");
148 # Print a debugging message {{{
150 my @call_info = caller;
151 chomp(my $Txt = shift);
152 my $File = $call_info[1];
154 $File =~ s
#^.*/(.*?)$#$1#;
155 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
162 # Plain Old Documentation (POD) {{{
176 [options] [file [files [...]]]
186 =item B<-h>, B<--help>
188 Print a brief help summary.
190 =item B<-v>, B<--verbose>
192 Increase level of verbosity. Can be repeated.
196 Print version information.
200 Print debugging messages.
210 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
214 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
215 This is free software; see the file F<COPYING> for legalese stuff.
219 This program is free software; you can redistribute it and/or modify it
220 under the terms of the GNU General Public License as published by the
221 Free Software Foundation; either version 2 of the License, or (at your
222 option) any later version.
224 This program is distributed in the hope that it will be useful, but
225 WITHOUT ANY WARRANTY; without even the implied warranty of
226 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
227 See the GNU General Public License for more details.
229 You should have received a copy of the GNU General Public License along
230 with this program; if not, write to the Free Software Foundation, Inc.,
231 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
239 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :