From: Ian Jackson Date: Fri, 20 Oct 2017 15:34:53 +0000 (+0100) Subject: poster-tube-lid-parametric: wip X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d02a5fe7bea6d291227df13fb7aa101b590edabe;p=reprap-play.git poster-tube-lid-parametric: wip --- diff --git a/poster-tube-lid-parametric.pl b/poster-tube-lid-parametric.pl new file mode 100644 index 0000000..491ad86 --- /dev/null +++ b/poster-tube-lid-parametric.pl @@ -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 ?"; + } +