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
32 sub pointmap_project_cylinder {
34 my $radius = shift_arg;
36 my $theta = $x / $radius;
37 return ($r * sin($theta),
42 if (@ARGV && $ARGV[0] =~ m/^-/) {
43 die "no options supported\n";
46 my $itmp = new File::Temp;
47 my $otmp = new File::Temp;
51 my $admesh_stdout = '--write-ascii-stl /dev/fd/3 3>&1 >/dev/null';
53 open I, "admesh $admesh_stdout $itmp |";
55 our @saved_argv = @ARGV;
59 if (s/^\s+vertex\s+//) {
62 my @xyz = split /\s+/, $_;
66 @xyz = &{ ${*::}{"pointmap_$op"} }( @xyz );
68 @xyz = map { sprintf "%.18g", $_ } @xyz;
75 <I> if 0; # suppresses Name "main::I" used only once
79 system "admesh --normal-values $admesh_stdout $otmp";