chiark / gitweb /
poster-tube-lid-parametric: wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 20 Oct 2017 15:34:53 +0000 (16:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 20 Oct 2017 15:34:53 +0000 (16:34 +0100)
poster-tube-lid-parametric.pl [new file with mode: 0644]

diff --git a/poster-tube-lid-parametric.pl b/poster-tube-lid-parametric.pl
new file mode 100644 (file)
index 0000000..491ad86
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+use strict;
+
+use Math::Vector::Real;
+
+my $lin_len = 10;
+my $sine_len = 8;
+my $sine_height = 6;
+
+my @i_sections = qw(ball0   6
+                   sine0  10
+                   lin0    2
+                   circle 20
+                   lin1    2
+                   sine1  10
+                   lin2    2
+                   ball2   6);
+
+sub point ($$) {
+    my ($ip,$it, $jp,$jt) = @_;
+
+    my ($i_offset, $i_outward);
+
+    $i_outward = V( 0,
+                 ($ip =~ m/0$/ ? -1 : +1),
+                 0 );
+
+    if ($ip =~ m/^lin[01]$/) {
+       $i_offset = V( $lin_len * ($ip =~ m/1/ ? $it : 1-$it),
+                      0,
+                      0 );
+    } elsif ($ip =~ m/^circle$/) {
+       $i_offset = V( 0,0,0 );
+       $i_outward = V(  sin($ip / PI),
+                        -cos($ip / PI),
+                        0 );
+    } elsif ($ip =~ m/^lin2$/) {
+       $i_offset = V( -$lin_len -$sine_len,
+                      0,
+                      +1 );
+    } elsif ($ip =~ m/^sine[01]$/) {
+       $i_offset = V( -$lin_len -$it*$sine_len,
+                      0,
+                      $sine_height * ( 0.5 - 0.5*cos( $it*PI ) )
+                    );
+    } else {
+       die "$ip ?";
+    }
+