From: Ian Jackson Date: Wed, 27 Jan 2016 23:07:11 +0000 (+0000) Subject: lemon-stand.scad.pl: wip X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=reprap-play.git;a=commitdiff_plain;h=798b9bf9b45318e7ebab5473326cd9e4fd3eea6a lemon-stand.scad.pl: wip --- diff --git a/.gitignore b/.gitignore index b5540e5..18d5848 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ pandemic-quarantine-l*.eps screw-recess-test-number-s*.* question-question.dxf question-question.eps +lemon-stand.scad diff --git a/lemon-stand.scad.pl b/lemon-stand.scad.pl new file mode 100755 index 0000000..eae50b5 --- /dev/null +++ b/lemon-stand.scad.pl @@ -0,0 +1,91 @@ +#!/usr/bin/perl -w + +use strict; +use Math::Trig; +use Math::Vector::Real; +use IO::File; +use Data::Dumper; +use constant tau => pi*2; + +print <versor(); + my $rad0 = $axis x V(0,0,1); + my $rad1 = $rad0 x $axis; + [ map { + my $theta = tau * $_ / $M; + $centre + $circle * ($rad0 * cos($theta) + $rad1 * sin($theta)); + } 0..($M-1) ]; +} 0..($N-1); + +sub circle ($$$) { my ($c,$i,$j) = @_; $c->[ $i % $N ][ $j % $M ]; } + +sub torusy () { + print "module Torusy(){ polyhedron(points=["; + my $ptix = 0; + my @cirpt; + foreach my $i (0..$N-1) { + foreach my $j (0..$M-1) { + print "," if $ptix; + print "\n"; + print " [ ", (join ", ", @{ $circles[$i][$j] }), " ]"; + $cirpt[$i][$j] = $ptix++; + } + } + print "\n ],\n"; + + print " faces=["; + foreach my $i (0..$N-1) { + my $i2 = ($i+1) % $N; + foreach my $j (0..$M-1) { + my $j2 = ($j+1) % $M; + print "," if $i || $j; + print "\n"; + print " [ ", (join ", ", + $cirpt[ $i ][ $j ], + $cirpt[ $i ][ $j2 ], + $cirpt[ $i2 ][ $j ], + ), " ],"; + print " [ ", (join ", ", + $cirpt[ $i ][ $j2 ], + $cirpt[ $i2 ][ $j2 ], + $cirpt[ $i2 ][ $j ], + ), " ]"; + } + } + print "\n ]);\n}\n"; +} + +torusy(); + +while () { print }; + +STDOUT->error and die $!; +STDOUT->flush or die $!; + +__DATA__ +Torusy();