5 use Math::Vector::Real;
8 use constant tau => pi*2;
12 // *** AUTOGENERATED - DO NOT EDIT ***
18 my $N = 30; # around ellipse
19 my $M = 20; # around each circle
22 my $theta = tau * $_ / $N;
23 V( cos($theta) * $ellipse * $xscale, sin($theta) * $ellipse, 0 )
26 #print Dumper(\@ellipse);
30 $ellipse[ ($i+1) % $N ] - $ellipse[ ($i-1) % $N];
35 my $centre = $ellipse[$i];
36 my $axis = $alongs[$i]->versor();
37 my $rad0 = $axis x V(0,0,1);
38 my $rad1 = $rad0 x $axis;
40 my $theta = tau * $_ / $M;
41 $centre + $circle * ($rad0 * cos($theta) + $rad1 * sin($theta));
45 sub circle ($$$) { my ($c,$i,$j) = @_; $c->[ $i % $N ][ $j % $M ]; }
48 print "module Torusy(){ polyhedron(points=[";
51 foreach my $i (0..$N-1) {
52 foreach my $j (0..$M-1) {
55 print " [ ", (join ", ", @{ $circles[$i][$j] }), " ]";
56 $cirpt[$i][$j] = $ptix++;
62 foreach my $i (0..$N-1) {
64 foreach my $j (0..$M-1) {
66 print "," if $i || $j;
68 print " [ ", (join ", ",
73 print " [ ", (join ", ",
85 while (<DATA>) { print };
87 STDOUT->error and die $!;
88 STDOUT->flush or die $!;