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 #=======================================================================
34 $progname =~ s/^.*\/(.*?)$/$1/;
35 our $VERSION = "0.00";
37 Getopt
::Long
::Configure
("bundling");
40 "debug" => \
$Opt{'debug'},
41 "help|h" => \
$Opt{'help'},
42 "max=f" => \
$Opt{'max'},
43 "min=f" => \
$Opt{'min'},
44 "verbose|v+" => \
$Opt{'verbose'},
45 "version" => \
$Opt{'version'},
47 ) || die("$progname: Option error. Use -h for help.\n");
49 $Opt{'debug'} && ($Debug = 1);
50 $Opt{'help'} && usage
(0);
51 if ($Opt{'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 print("$progname v$VERSION\n");
109 # Send the help message to stdout {{{
112 if ($Opt{'verbose'}) {
118 Usage: $progname [options] [file [files [...]]]
125 Increase level of verbosity. Can be repeated.
127 Print version information.
129 Print debugging messages.
137 # Print a status message to stderr based on verbosity level {{{
138 my ($verbose_level, $Txt) = @_;
140 if ($Opt{'verbose'} >= $verbose_level) {
141 print(STDERR
"$progname: $Txt\n");
147 # Print a debugging message {{{
149 my @call_info = caller;
150 chomp(my $Txt = shift);
151 my $File = $call_info[1];
153 $File =~ s
#^.*/(.*?)$#$1#;
154 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
161 # Plain Old Documentation (POD) {{{
171 [options] [file [files [...]]]
181 =item B<-h>, B<--help>
183 Print a brief help summary.
185 =item B<-v>, B<--verbose>
187 Increase level of verbosity. Can be repeated.
191 Print version information.
195 Print debugging messages.
205 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
209 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
210 This is free software; see the file F<COPYING> for legalese stuff.
214 This program is free software: you can redistribute it and/or modify it
215 under the terms of the GNU General Public License as published by the
216 Free Software Foundation, either version 3 of the License, or (at your
217 option) any later version.
219 This program is distributed in the hope that it will be useful, but
220 WITHOUT ANY WARRANTY; without even the implied warranty of
221 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
222 See the GNU General Public License for more details.
224 You should have received a copy of the GNU General Public License along
226 If not, see L<http://www.gnu.org/licenses/>.
234 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :