chiark / gitweb /
poster-tube-lid: new shape, fix balls
[reprap-play.git] / poster-tube-lid-parametric.scad.pl
index a2fd3a7e8bcc9c21b5d292698cd117299f4fab16..be5f17ba4c5afa15d1335e75b64c92f4edbadf93 100755 (executable)
@@ -16,12 +16,14 @@ my $slope_angle = 45 * TAU/360;
 my $jcurverad = 5;
 my $tall = 50;
 
-my $lin_len = 5;
-my $sine_size = 10;
-my $sine_angle = TAU/8;
+my $lin_len = 4;
+my $sine_size = 5;
+my $sine_angle = 1.2 * TAU/8;
 
 my $ballend_xr = $thick/2;
 
+my $skew_slope = 0.7;
+
 my @i_sections = qw(ball0  -6
                    sine0  -10
                    -
@@ -47,11 +49,13 @@ my @j_sections = qw(lin0    2
 sub point ($$$$) {
     my ($ip,$it, $jp,$jt) = @_;
 
-    my ($i_offset, $i_outward);
+    my ($i_offset);
+
+    my $i_outward = V( 0,
+                      ($ip =~ m/0$/ ? -1 : +1),
+                      0 );
 
-    $i_outward = V( 0,
-                   ($ip =~ m/0$/ ? -1 : +1),
-                   0 );
+    my $i_j_y_angle = 0;
 
     my $i_thickscale = 1.0;
     my $sine_len = $sine_size * sin($sine_angle);
@@ -68,22 +72,28 @@ sub point ($$$$) {
                         0 );
     } elsif ($ip =~ m/^sine[01]$/) {
        my $angle = $it * $sine_angle;
-       $i_offset = V( -$sine_size * sin($angle) -$lin_len,
+       $i_offset = V( -$lin_len -$sine_size * sin($angle),
                       0,
                       +$sine_size * (1 - cos($angle))
                     );
+       $i_j_y_angle = $angle;
     } elsif ($ip =~ m/^ball[02]$/) {
+       $i_j_y_angle = $sine_angle;
        my $angle = $it * TAU/4;
        my $dx = sin($angle) * $ballend_xr;
-       $i_offset = V( -$lin_len -$sine_len - $dx,
+       $i_offset = V( -$lin_len -$sine_len - $dx * cos($sine_angle),
                       0,
-                      +$sine_height + $dx * tan($sine_angle)
+                      +$sine_height + $dx * sin($sine_angle)
                     );
        $i_thickscale = cos($angle);
     } else {
        die "$ip ?";
     }
 
+    my $i_j_y_vect = V( sin($i_j_y_angle),
+                       0,
+                       cos($i_j_y_angle ));
+
     my $j_plus_th = $jp =~ m/2$/ ? $thick : 0;
 
     my $i_thick = $thick * $i_thickscale;
@@ -120,11 +130,18 @@ sub point ($$$$) {
        die "$jp ?";
     }
 
+    $j_y -= $j_qrc_y;
+
+    if ($j_y > 0) {
+       $i_j_y_vect = V(0,0,1);
+    }
+
 #    print STDERR "@_ $j_x $j_y $i_offset $i_outward\n";
     return
        $i_offset +
        $j_x * $i_outward +
-       V(0,0,1) * $j_y +
+       $i_j_y_vect * $j_y +
+       V(0,0,1) * $j_qrc_y +
        V(0,0,-$tall) ;
 }