mksphere 4.29 KiB
#! /usr/bin/perl
$cmd = join(" ", @ARGV);
($me = $0) =~ s'.*/'';
$map = "aitoff";
$style = "solid";
$color = 20;
$radius = 1.0;
$txscale = 1;
while(($_ = shift(@ARGV)) ne "") {
$any = @ARGV;
if(/^-rect$/) { $map = "rect"; } # rectangular, X=lon, Y=lat
elsif(/^-cyl/) { $map = "cyl"; } # rectangular equal-area, X=lon, Y=Z
elsif(/^-ait/) { $map = "aitoff"; } # Aitoff
elsif(/^-sin/) { $map = "sin"; } # Sinusoidal
elsif(/^-st/) { $map = "stereo"; } # Stereographic
elsif(/^-t$|^-txno$/) { $txno = shift; }
elsif(/^-txfile/) { $txfile = shift; }
elsif(/^-txs/) { $txscale = shift; }
elsif(/^-line/) { $style = "line"; }
elsif(/^-solid/) { $style = "solid"; }
elsif(/^-asymp/) { $asymp = 1; }
elsif(/^-c/) { $color = shift; }
elsif(/^-n$/) { $nunv = shift; }
elsif(/^-r$|^-radius/) { $radius = shift; }
elsif(/^(\w+)=(.*)/) {
eval("\$$1 = $2;");
}
else {
print "$0: unknown option $_\n";
print STDERR <<EOF;
Usage: $0 [-rect|-cyl|-aitoff|-sin|-ster] [-n nu[,nv]] [-color cindex] [-line] \
[-txno txnumber] [-txfile imagename] [-color cindex] > file.speck
Generate sphere in partiview mesh form, with texture coordinates
for given map projection:
-rect rectangular map, X=longitude, Y=latitude
-cyl rectangular equal-area, X=lon, Y=cylinder Z
-aitoff Aitoff equal-area projection
-sin sinusoidal projection
-ster stereographic projection (center = +Z pole)
-n nu,nv Numbers of grid points in u (lon) and v (lat) directions.
-txno texture number
-txfile texture image filename
-txscale scale texture about (0.5,0.5) point
-line make wireframe sphere (default solid)
-color color (index into colormap)
Defaults: -aitoff -n 41,31 -color $color -txno $txno
EOF
exit(1);
}
}
if($nunv) {
($nu, $nv) = ($nunv =~ /(\d+),?(\d*)/);
$nv = $nu * 3/4 if $nv == 0;
} else {
$nu = 41;
$nv = 31;
}
$hu = int($nu/2);
$hv = int($nv/2);
$nu = 2*$hu + 1;
$nv = 2*$hv + 1;
$pi = 3.1415926535;