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));
46 print "module Torusy(){ polyhedron(points=[";
49 foreach my $i (0..$N-1) {
50 foreach my $j (0..$M-1) {
53 print " [ ", (join ", ", @{ $circles[$i][$j] }), " ]";
54 $cirpt[$i][$j] = $ptix++;
60 foreach my $i (0..$N-1) {
62 foreach my $j (0..$M-1) {
64 print "," if $i || $j;
66 print " [ ", (join ", ",
71 print " [ ", (join ", ",
83 while (<DATA>) { print };
85 STDOUT->error and die $!;
86 STDOUT->flush or die $!;