Metalworking (rec.crafts.metalworking) Discuss various aspects of working with metal, such as machining, welding, metal joining, screwing, casting, hardening/tempering, blacksmithing/forging, spinning and hammer work, sheet metal work.

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to rec.crafts.metalworking
external usenet poster
 
Posts: 13
Default Perl script to compute bolt hole pattern

#!/usr/bin/perl

# If you have a mill with a DRO, and/or a rotary table then you may find
# this script handy when dividing circle. To print the angles (in
# degrees, minutes and seconds) you just specify the number of
# divisions.
#
# If you want to calculate bolt hole pattern given a certain radius
# (assuming that coordinate (0,0) is the center of the circle), you give
# this script an optional argument --radius.
#
# Copyright(C) 2009, Igor Chudov.
# Distributed under the terms of the GNU PUBLIC LICENSE V2
#

use strict;
use warnings;

use Getopt::Long;

my $radius = undef;

GetOptions(
"r|radius=f", \$radius,
);

my $number = shift @ARGV || die "USAGE: $0 number";

$number =~ /^\d+$/ || die "USAGE: $0 number";;

foreach( my $i = 0; $i $number; $i++ ) {
my $angle = 360/$number*$i;

my $degrees = int( $angle );
my $minutes = int( ($angle - $degrees) * 60 );
my $seconds = int( int( ($angle - $degrees - $minutes/60)*60*60 ) );

my $xy = "";
if( $radius ) {
$xy = sprintf( ", x = %.4f, y = %.4f",
$radius * cos( $angle/360 ),
$radius * sin( $angle/360 )
);

}
print sprintf( "%d: %03d %02d' %02d\" (%f) %s\n", $i+1, $degrees, $minutes, $seconds, $angle, $xy );
}
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Script to track UPS-Packages Ignoramus22443 Metalworking 25 August 17th 07 04:03 AM
Damaged 8mm bolt hole... Best repair? Noozer Home Repair 7 July 4th 06 06:26 PM
layout question - bolt hole pattern [email protected] Metalworking 16 October 4th 05 03:51 PM
DXF drawing of Chev bellhousing bolt pattern Steve Peterson Metalworking 1 March 10th 04 09:00 PM
Is milwaukee router insrt plate mounting hole pattern same as porter cable pattern Rich Woodworking 1 July 22nd 03 04:22 AM


All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 DIYbanter.
The comments are property of their posters.
 

About Us

"It's about DIY & home improvement"