6 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#package bitcreator;
use strict;
use Data::Dumper;
$Data::Dumper::Terse = 1;
$Data::Dumper::Indent = 1;
$Data::Dumper::Sortkeys = sub { my @keys = sort {$a cmp $b} keys %{@_}; return \@keys; };
#sub bitcreator {
my $h = {};#shift;
$h->{0}{X1} = 0;
$h->{0}{Y1} = 0;
$h->{1}{X1} = 6;
$h->{1}{Y1} = 4;
my @stream;
# cuttingmaschine 34 cm = 32000 steps on each motor (x,y)
my @keys = sort { my $x = $a; $x ||= 0; my $y = $b; $y ||= 0; $x <=> $y} keys %{$h};
for my $a(1..$#keys){
my $xbefore = $h->{$a-1}{X1};
my $ybefore = $h->{$a-1}{Y1};
my $x = $h->{$a}{X1};
my $y = $h->{$a}{Y1};
my $distx = ($x - $xbefore) #realer Wert in cm
my $disty = ($y - $ybefore) #realer Wert in cm
# y = m * x + t
my $m = ($ybefore - $y) / ($xbefore - $x);
my $t = $y - ($x * $m);
my $anzxsteps = sprintf("%0.f",($distx ));#* (32000/34)));
my $anzysteps = sprintf("%0.f",($disty ));#* (32000/34)));
my $stepsizeX = $distx / $anzxsteps;
my $stepsizeY = $disty / $anzysteps;
if ($anzxsteps >= $anzysteps){
my $Xbit = 1;
for my $b (1..$anzxsteps){
my $Ybit = 0;
my $y1 = $m * ($b*$stepsizeX) + $t;
if (sprintf("%0.f",$y1 / $stepsizeY) >= $y1) {$Ybit = 1;}
push @stream,$Xbit,$Ybit;
}#end for $b
}#end if
else{
my $Ybit = 1;
for my $b (1..$anzysteps){
my $Xbit = 0;
my $x1 = (($b*$stepsizeY) - $t) / $m;
if (sprintf("%0.f",$x / $stepsizeX) >= $x1) {$Xbit = 1;}
push @stream,$Xbit,$Ybit;
}#end for $b
}#end else
}#end for $a
print "@stream\n";
#} # end sub
#1;
Mako+2007-11-13 11:27:47--
[...]
wie gesagt es funktioniert nicht, oder gibts vielleicht einen anderen Weg um ans Ziel zu kommen und mir fällt das nur nicht ein.
mfg
Danke
6 Einträge, 1 Seite |