#!C:/Perl/bin/perl
# Table of Sacred Cuts of the Square, by Vinyasi, no rights reserved.
# http://vinyasi.mayashastra.org/book/zip/sacred_square.zip
print "Content-Type: text/html\n\n";
#
Sacred Square Cuts Among Even-Sided Polygons
use constant PI => 4 * atan2 1, 1;
$shift = 100000;
$limit = 5;
#
#Sacred Square Cuts Among Even-Sided Polygons
for($x1 = 2; $x1 <= $limit; $x1++) { # even sides
$mod = "false";
for($x2 = 2; $x2 <= sqrt($x1); $x2++) {
if($x1 % $x2 == 0) {
$mod = "true";
last; }}
if($mod eq "false") {
$read = "";
$tot_sides = $x1 * 4; # even sides
$readout = "\n". $x1. "p ". $tot_sides. "-Gon
\n";
$num_ang = $tot_sides / 2; # even sides
$ang = 360 / $tot_sides; # even sides
for($x3 = 1; $x3 <= $num_ang; $x3++) { # even sides
$angle = $ang * $x3;
$sin[$x3] = 2 * sin(PI * $angle / 360); # even sides
$readout .= "
Angle No.". $x3. ", Sin (". (int(int($angle * $shift + 1) / $shift));
$readout .= "° / 2) = ". $sin[$x3]. " / 2\n"; }
for($x4 = 1; $x4 <= $num_ang; $x4++) { # even sides
for($x5 = ($x4 + 1); $x5 <= $num_ang; $x5++) { # even sides
for($x7 = 1; $x7 <= $num_ang; $x7++) { # even sides
for($x8 = ($x7 + 1); $x8 <= $num_ang; $x8++) { # even sides
for($alt_sign = -1; $alt_sign <= 1; $alt_sign += 2) {
$bsign = " ";
$csign = "+ ";
$sin2sign = "+ ";
for($alt1 = -1; $alt1 <= 1; $alt1 += 2) {
for($alt2 = -1; $alt2 <= 1; $alt2 += 2) {
$alt3 = $alt1 * (-1);
$alt4 = $alt2 * (-1);
$al1 = '';
$al2 = '';
$al3 = '';
$al4 = '';
$al1 = "-" if($alt1 < 0);
$al2 = "-" if($alt2 < 0);
$al3 = "-" if($alt3 < 0);
$al4 = "-" if($alt4 < 0);
$sin1 = $sin[$x4] ** ($alt1) * $sin[$x5] ** ($alt3);
$sin2 = $sin[$x7] ** ($alt2) * $sin[$x8] ** ($alt4);
$be = $sin1 + ($alt_sign * $sin2);
$ce = $alt_sign * $sin1 * $sin2;
if($alt_sign < 0) {
$sin2 = abs($sin2);
$sin2sign = " "; }
if($be < 0) {
$be = abs($be);
$bsign = "+ "; }
if($ce < 0) {
$ce = abs($ce);
$csign = " "; }
if($be != 0 and length $be < 13 and length $ce < 13 and (length $sin1 >= 13 or length $sin2 >= 13)) {
if(!$read) {
$read = "yes";
print $readout, "\n"; }
$ae = 1;
if($ce =~ /\./) {
$ae *= 1 / $ce;
$be *= 1 / $ce;
$ce *= 1 / $ce; }
print "Angles ";
print "[", $x4, $al1, " ", $x5, $al3, ", ", $x7, $al2;
print " ", $x8, $al4, "] Roots ";
print "{", $sin1, ", ", $sin2sign, $sin2, "}", " = ";
print $ae if($ae != 1);
print "x2 ", $bsign;
print $be if($be ne '1');
print "x ", $csign, $ce, "\n"; }}}}}}}}
undef @sin; }}
exit;