#!/usr/bin/perl # -*- perl -*- if ($ARGV[0] eq "show-source") { print "Content-type: text/plain\n\n"; print `cat compound-cuts.cgi`; exit; } use POSIX; $pi = atan2(1,1) * 4; $original_email = ' From: "Robert Smith" Subject: Re: Best CAD Program for Woodworkers Newsgroups: rec.woodworking Date: Fri, 31 Oct 2003 13:51:59 GMT Now to try and make the formula easier to understand we need to define two variables. The number of sides will be in variable "s". The angle of the sides, which we just calculated will be in variable "b" Just plug the correct values in this short formula and you will have your answer a=360/s x=arctan((cos b)*tan(a/2)) y=arcsin((sin b)*sin(a/2)) The "x" value will be the angle that you set your cross cut to. The "y" value will be the angle that you set your saw blade to. '; require "./woodlib.pl"; $sides = $in{'nsides'}; $angle = $in{'angle'}; $sides = 4 unless $sides > 0; $angle = 0 unless $angle > 0; if ($angle =~ m@([0-9\.]+)/([0-9\.]+)@) { ($rise, $run) = ($1, $2); $angle = atan2($rise, $run); } else { $angle = $angle * $pi / 180; } $a = $pi / $sides; $x = atan(cos($angle)*tan($a)); $y = asin(sin($angle)*sin($a)); print "Content-type: text/html\n\n"; print `header Compound Cut Calculations`; print "
"; &row("Number of sides:", $sides); &row("Angle of sides:", $angle * 180/$pi); &row("
", ""); &row("Cross Cut Angle:", $x * 180/$pi); &row("Blade Angle:", $y * 180/$pi); sub row { $v = $_[1]; if ($v =~ m@[0-9]\.@) { $v = sprintf("%.1f", $v); } print "\n"; } print "
$_[0]   $v

"; print "

Return to the Form

\n"; print "
"; print `trailer`;