+ my $radius = $project_cylinder_radius;
+
+ my @ot;
+ foreach my $p (@$t) {
+ my ($x,$y,$z) = @$p;
+ my $r = $radius - $y;
+ my $theta = $x / $radius;
+ push @ot, [ $r * sin($theta),
+ -$r * cos($theta),
+ $z ];
+ }
+ append_triangle \@ot;
+}
+
+sub op__project_cylinder () {
+ $project_cylinder_radius = shift_arg;
+ $project_cylinder_max_d_theta = $fa * TAU/360;
+
+ while (project_cylinder_need_subdivide()) {
+ $output = [];
+ foreach my $t (@$triangles) {
+ subdivide_triangle $t, \&append_triangle;
+ }
+ $triangles = $output;
+ }
+
+ $output = [];
+ foreach my $t (@$triangles) {
+ project_cylinder_tri $t;
+ }
+ $triangles = $output;
+}
+
+#---------- main program ----------
+
+our $raw;
+
+while (@ARGV && $ARGV[0] =~ m/^-/) {
+ $_ = shift @ARGV;
+ last if m/^--$/;
+ if (s/^--raw$//) {
+ $raw = 1;
+ } else {
+ die "$_ ?";
+ }
+}
+
+my $itmp;
+my $otmp;