Stefan Schuermans
move scripts into own subdir
Stefan Schuermans commited cd92b87 at 2014-01-11 13:44:27
pcb_rot_part.pl
#! /usr/bin/perl
use strict;
use warnings;
if (@ARGV < 1) {
print STDERR "usage: $0 <angle in deg (cw)>\n";
exit 2;
}
my $angle = shift(@ARGV);
my $angle_rad = $angle * 3.14159265 / 180.0;
my $angle_cos = cos($angle_rad);
my $angle_sin = sin($angle_rad);
sub round
{
my ($val) = @_;
return $val < 0 ? int($val - 0.5) : int($val + 0.5);
}
sub rotate
{
my ($x, $y) = @_;
my $xx = $angle_cos * $x - $angle_sin * $y;
my $yy = $angle_sin * $x + $angle_cos * $y;
return (round($xx), round($yy));
}
while (my $line = <>) {
chomp $line;
if ($line =~ /^\s+Pad\s*\[([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+"([^"]*)"\s+"([^"]*)"\s+("[^"]*"|0x[0-9A-Fa-f]+)\]\s*$/) {
my ($x1, $y1, $x2, $y2, $width, $clear, $mask, $name, $no, $flags) =
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);
my ($xx1, $yy1) = rotate($x1, $y1);
my ($xx2, $yy2) = rotate($x2, $y2);
$line = "\tPad[$xx1 $yy1 $xx2 $yy2 $width $clear $mask \"$name\" \"$no\" $flags]";
}
elsif ($line =~ /^\s+Pin\s*\[([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+"([^"]*)"\s+"([^"]*)"\s+("[^"]*"|0x[0-9A-Fa-f]+)\]\s*$/) {
my ($x, $y, $diam, $clear, $mask, $drill, $name, $no, $flags) =
($1, $2, $3, $4, $5, $6, $7, $8, $9);
my ($xx, $yy) = rotate($x, $y);
$line = "\tPin[$xx $yy $diam $clear $mask $drill \"$name\" \"$no\" $flags]";
}
elsif ($line =~ /^\s+ElementLine\s*\[([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\]\s*$/) {
my ($x1, $y1, $x2, $y2, $width) = ($1, $2, $3, $4, $5);
my ($xx1, $yy1) = rotate($x1, $y1);
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX