#!/usr/bin/perl -w
# script to test involuteGear.pl module
# for production run MUST provide separation, pitch, teeth1, teeth2 AND dummy
$preview = $#ARGV < 4;
# ponoko laser cutting sheets come in 181x181mm, 384x384mm, 384 wide x 790mm long
$wPx = 181; # width of drawing, pixels?!?? -- most programs seem to ignore units, use mm
$hPx = 181; # height of drawing, pixels?!??
require 'involuteGear.pl';
require 'laserCutPartsPrimitives.pl';
#require 'laserCutPartsGroups.pl';
#require 'JansenDefs.pl'; # for $cutWidth, $irS
$cutWidth = 0.2; $irS=1.38;
&printPonokoHeader($wPx,$hPx,$preview);
local $gearDist = ($#ARGV>=0) ? $ARGV[0] : 40;
local $n1 = ($#ARGV>=1) ? $ARGV[1] : 23;
local $n2 = ($#ARGV>=2) ? $ARGV[2] : 11;
print STDERR "$0 dist=$gearDist n1=$n1 n2=$n2" .
($preview?"\n":"production\n");
local %a = &defaultGearParams();
# I guess common values are 20, 14.5, and 25
$a{'pressure_angle' } = 25; # higher than default 20 degrees might be good for plastic
$a{'involute_facets'} = 16;
# $a{'clearance' } = 0.2;
# $a{'backlash'} = 0;
# fudge the seperation a bit to give a little "slop"
$a{'pitch'} = &scalePitch($gearDist-.17,$n1,$n2);
print STDERR %a;
local $y0=($wPx+$gearDist)/2;
local $mid = $hPx/2;
$a{'number_of_teeth'} = $n1;
local $halfToothAng = 180/$n1;
printf("\n",
(($n1+1) % 2) * $halfToothAng); # left space always on axis
&startPart(0,0);&drawArc('M',0,0,$irS,0,360,30);print $endPart;
&drawInvoluteGear(%a);
$a{'number_of_teeth'} = $n2;
printf("\n",$y0-$gearDist);
&startPart(0,0);&drawArc('M',0,0,$irS,0,360,30);print $endPart;
&drawInvoluteGear(%a);
print "\n"; # end of drawing
printf STDERR ("pitch=%.2f\n",$a{'pitch'});