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 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
37 $progname =~ s/^.*\/(.*?)$/$1/;
40 my $id_date = $rcs_id;
41 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
43 push(@main::version_array
, $rcs_id);
45 Getopt
::Long
::Configure
("bundling");
48 "debug" => \
$Opt{'debug'},
49 "help|h" => \
$Opt{'help'},
50 "max=f" => \
$Opt{'max'},
51 "min=f" => \
$Opt{'min'},
52 "verbose|v+" => \
$Opt{'verbose'},
53 "version" => \
$Opt{'version'},
55 ) || die("$progname: Option error. Use -h for help.\n");
57 $Opt{'debug'} && ($Debug = 1);
58 $Opt{'help'} && usage
(0);
59 if ($Opt{'version'}) {
74 my $Left = defined($Ele[$Lat][$Lon-1]) ?
$Ele[$Lat][$Lon-1] : rand(1);
75 my $Right = defined($Ele[$Lat][$Lon+1]) ?
$Ele[$Lat][$Lon+1] : rand(1);
76 my $Over = defined($Ele[$Lat+1][$Lon]) ?
$Ele[$Lat+1][$Lon] : rand(1);
77 my $Under = defined($Ele[$Lat-1][$Lon]) ?
$Ele[$Lat-1][$Lon] : rand(1);
78 my $Curr = ($Left+$Right+$Over+$Under)/4;
79 $Curr += rand(1) >= 0.5 ?
rand(1) : 0-rand(1);
80 # until ($Curr >= $Opt{'min'}) {
82 # $Curr += rand(1) * 1.0;
84 # until ($Curr <= $Opt{'max'}) {
86 # $Curr -= rand(1) * 1.0;
88 if ($Lat > 0 && $Lat < $Size && $Lon > 0 && $Lon < $Size) {
89 # print("$Lat\t$Lon\t$Curr\n");
90 # print($Lat . "\t" . $Lon-1 . "\t" . $Left . "\n");
91 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
93 print($Lat+1 . "\t" . $Lon . "\t" . $Over . "\n");
94 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
96 # print($Lat . "\t" . $Lon+1 . "\t" . $Right . "\n");
97 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
99 print($Lat-1 . "\t" . $Lon . "\t" . $Under . "\n");
100 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
103 $Ele[$Lat][$Lon] = $Curr;
107 last if ($Lat > $Size);
111 # Print program version {{{
112 for (@main::version_array
) {
119 # Send the help message to stdout {{{
122 if ($Opt{'verbose'}) {
128 Usage: $progname [options] [file [files [...]]]
135 Increase level of verbosity. Can be repeated.
137 Print version information.
139 Print debugging messages.
147 # Print a status message to stderr based on verbosity level {{{
148 my ($verbose_level, $Txt) = @_;
150 if ($Opt{'verbose'} >= $verbose_level) {
151 print(STDERR
"$progname: $Txt\n");
157 # Print a debugging message {{{
159 my @call_info = caller;
160 chomp(my $Txt = shift);
161 my $File = $call_info[1];
163 $File =~ s
#^.*/(.*?)$#$1#;
164 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
171 # Plain Old Documentation (POD) {{{
185 [options] [file [files [...]]]
195 =item B<-h>, B<--help>
197 Print a brief help summary.
199 =item B<-v>, B<--verbose>
201 Increase level of verbosity. Can be repeated.
205 Print version information.
209 Print debugging messages.
219 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
223 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
224 This is free software; see the file F<COPYING> for legalese stuff.
228 This program is free software; you can redistribute it and/or modify it
229 under the terms of the GNU General Public License as published by the
230 Free Software Foundation; either version 2 of the License, or (at your
231 option) any later version.
233 This program is distributed in the hope that it will be useful, but
234 WITHOUT ANY WARRANTY; without even the implied warranty of
235 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
236 See the GNU General Public License for more details.
238 You should have received a copy of the GNU General Public License along
239 with this program; if not, write to the Free Software Foundation, Inc.,
240 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
248 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :