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 #=======================================================================
30 $progname =~ s
#^.*/(.*?)$#$1#;
33 my $id_date = $rcs_id;
34 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
36 Getopt
::Long
::Configure
("bundling");
38 "debug" => \
$Opt{'debug'},
39 "help|h" => \
$Opt{'help'},
40 "max=f" => \
$Opt{'max'},
41 "min=f" => \
$Opt{'min'},
42 "verbose|v+" => \
$Opt{'verbose'},
43 "version" => \
$Opt{'version'},
44 ) || die("$progname: Option error. Use -h for help.\n");
46 $Opt{'debug'} && ($Debug = 1);
47 $Opt{'help'} && usage
(0);
48 $Opt{'version'} && print_version
();
60 my $Left = defined($Ele[$Lat][$Lon-1]) ?
$Ele[$Lat][$Lon-1] : rand(1);
61 my $Right = defined($Ele[$Lat][$Lon+1]) ?
$Ele[$Lat][$Lon+1] : rand(1);
62 my $Over = defined($Ele[$Lat+1][$Lon]) ?
$Ele[$Lat+1][$Lon] : rand(1);
63 my $Under = defined($Ele[$Lat-1][$Lon]) ?
$Ele[$Lat-1][$Lon] : rand(1);
64 my $Curr = ($Left+$Right+$Over+$Under)/4;
65 $Curr += rand(1) >= 0.5 ?
rand(1) : 0-rand(1);
66 # until ($Curr >= $Opt{'min'}) {
68 # $Curr += rand(1) * 1.0;
70 # until ($Curr <= $Opt{'max'}) {
72 # $Curr -= rand(1) * 1.0;
74 if ($Lat > 0 && $Lat < $Size && $Lon > 0 && $Lon < $Size) {
75 # print("$Lat\t$Lon\t$Curr\n");
76 # print($Lat . "\t" . $Lon-1 . "\t" . $Left . "\n");
77 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
79 print($Lat+1 . "\t" . $Lon . "\t" . $Over . "\n");
80 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
82 # print($Lat . "\t" . $Lon+1 . "\t" . $Right . "\n");
83 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
85 print($Lat-1 . "\t" . $Lon . "\t" . $Under . "\n");
86 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
89 $Ele[$Lat][$Lon] = $Curr;
93 last if ($Lat > $Size);
97 # Print program version {{{
104 # Send the help message to stdout {{{
111 Usage: $progname [options] [file [files [...]]]
118 Increase level of verbosity. Can be repeated.
120 Print version information.
122 Print debugging messages.
130 # Print a status message to stderr based on verbosity level {{{
131 my ($verbose_level, $Txt) = @_;
133 if ($Opt{'verbose'} >= $verbose_level) {
134 print(STDERR
"$progname: $Txt\n");
140 # Print a debugging message {{{
142 my @call_info = caller;
143 chomp(my $Txt = shift);
144 my $File = $call_info[1];
146 $File =~ s
#^.*/(.*?)$#$1#;
147 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
154 # Plain Old Documentation (POD) {{{
168 [options] [file [files [...]]]
178 =item B<-h>, B<--help>
180 Print a brief help summary.
182 =item B<-v>, B<--verbose>
184 Increase level of verbosity. Can be repeated.
188 Print version information.
192 Print debugging messages.
202 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
206 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
207 This is free software; see the file F<COPYING> for legalese stuff.
211 This program is free software; you can redistribute it and/or modify it
212 under the terms of the GNU General Public License as published by the
213 Free Software Foundation; either version 2 of the License, or (at your
214 option) any later version.
216 This program is distributed in the hope that it will be useful, but
217 WITHOUT ANY WARRANTY; without even the implied warranty of
218 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
219 See the GNU General Public License for more details.
221 You should have received a copy of the GNU General Public License along
222 with this program; if not, write to the Free Software Foundation, Inc.,
223 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
231 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :