4 # ./distort-stl <INPUT >OUTPUT DISTORTION [PARAMS...] ...
8 # project-cylinder RADIUS
9 # projects the X-Z plane onto the cylinder of
10 # radius RADIUS with axis [0, 0, t]
11 # origin becomes [0, -RADIUS, 0]
12 # other planes of the input are projected onto smaller
13 # or larger cylinders accordingly
14 # probably a bad idea if
15 # object has any Y > RADIUS
16 # object has any |X| > tau / RADIUS
17 # technically, treats input as if it were
18 # polar-rectangular coords:
19 # Z' = Z; R' = Y + RADIUS; theta' = X / RADIUS
20 # and then converts back into cartesian
30 sub pointmap_distortion {
32 my $radius = shift_arg;
34 my $theta = $x / $radius;
35 return ($r * cos($theta),
40 if (@ARGV && $ARGV[0] =~ m/^-/) {
41 die "no options supported\n";
44 my $admesh_pipe = '--write-ascii-stl 3<&0 4>&1 >/dev/null /dev/fd/4 /dev/fd/3';
46 open I, "admesh $admesh_pipe |";
47 open O, "| admesh --normal-values $admesh_pipe";
49 our @saved_argv = @ARGV;
52 if (s/^\s+vertex\s+//) {
55 my @xyz = split /\s+/, $_;
58 @xyz = &{ $::{"pointmap_$op"} }( @xyz );
60 @xyz = map { sprintf "%.18g", $_ } @xyz;
66 <I>,<O> if 0; # suppresses Name "main::I" used only once