Translated doc/gnuplot.txt from Norwegian to English.
[gpstools.git] / makemesh
bloba45fa10dcfcf7d076489bdea7309a8d8fa203a5c
1 #!/usr/bin/perl -w
3 #=======================================================================
4 # makemesh
5 # File ID: 2036c7c6-f924-11dd-b41d-0001805bf4b1
6 # Create random 3D surface for use in plotting programs.
8 # Character set: UTF-8
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 #=======================================================================
14 use strict;
15 use Getopt::Long;
17 $| = 1;
19 our $Debug = 0;
21 our %Opt = (
23 'debug' => 0,
24 'help' => 0,
25 'max' => 1000,
26 'min' => 0,
27 'verbose' => 0,
28 'version' => 0,
32 our $progname = $0;
33 $progname =~ s/^.*\/(.*?)$/$1/;
34 our $VERSION = "0.00";
36 Getopt::Long::Configure("bundling");
37 GetOptions(
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'}) {
51 print_version();
52 exit(0);
55 my ($Lat, $Lon) =
56 ( 0, 0);
58 my @Ele = ();
60 my $Size = 20;
62 while (1) {
63 D("Lon = '$Lon'");
64 for $Lon (0..$Size) {
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'}) {
72 # D("Curr >= Min");
73 # $Curr += rand(1) * 1.0;
74 # }
75 # until ($Curr <= $Opt{'max'}) {
76 # D("Curr <= Max");
77 # $Curr -= rand(1) * 1.0;
78 # }
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");
83 # print("\n");
84 print($Lat+1 . "\t" . $Lon . "\t" . $Over . "\n");
85 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
86 # print("\n");
87 # print($Lat . "\t" . $Lon+1 . "\t" . $Right . "\n");
88 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
89 # print("\n");
90 print($Lat-1 . "\t" . $Lon . "\t" . $Under . "\n");
91 print($Lat . "\t" . $Lon . "\t" . $Curr . "\n");
92 # print("\n");
94 $Ele[$Lat][$Lon] = $Curr;
95 print("\n");
97 $Lat += 1;
98 last if ($Lat > $Size);
101 sub print_version {
102 # Print program version {{{
103 print("$progname v$VERSION\n");
104 # }}}
105 } # print_version()
107 sub usage {
108 # Send the help message to stdout {{{
109 my $Retval = shift;
111 if ($Opt{'verbose'}) {
112 print("\n");
113 print_version();
115 print(<<END);
117 Usage: $progname [options] [file [files [...]]]
119 Options:
121 -h, --help
122 Show this help.
123 -v, --verbose
124 Increase level of verbosity. Can be repeated.
125 --version
126 Print version information.
127 --debug
128 Print debugging messages.
131 exit($Retval);
132 # }}}
133 } # usage()
135 sub msg {
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");
142 # }}}
143 } # msg()
145 sub D {
146 # Print a debugging message {{{
147 $Debug || return;
148 my @call_info = caller;
149 chomp(my $Txt = shift);
150 my $File = $call_info[1];
151 $File =~ s#\\#/#g;
152 $File =~ s#^.*/(.*?)$#$1#;
153 print(STDERR "$File:$call_info[2] $$ $Txt\n");
154 return("");
155 # }}}
156 } # D()
158 __END__
160 # Plain Old Documentation (POD) {{{
162 =pod
164 =head1 NAME
168 =head1 SYNOPSIS
170 [options] [file [files [...]]]
172 =head1 DESCRIPTION
176 =head1 OPTIONS
178 =over 4
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.
188 =item B<--version>
190 Print version information.
192 =item B<--debug>
194 Print debugging messages.
196 =back
198 =head1 BUGS
202 =head1 AUTHOR
204 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
206 =head1 COPYRIGHT
208 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
209 This is free software; see the file F<COPYING> for legalese stuff.
211 =head1 LICENCE
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
224 with this program.
225 If not, see L<http://www.gnu.org/licenses/>.
227 =head1 SEE ALSO
229 =cut
231 # }}}
233 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :