up/down length
This commit is contained in:
parent
d4270b513f
commit
cb0d97f668
|
@ -26,12 +26,12 @@ PEN_DOWN_POSITION = 45
|
||||||
PEN_DOWN_SPEED = 150
|
PEN_DOWN_SPEED = 150
|
||||||
PEN_DOWN_DELAY = 0
|
PEN_DOWN_DELAY = 0
|
||||||
|
|
||||||
ACCELERATION = 5
|
ACCELERATION = 6
|
||||||
MAX_VELOCITY = 1
|
MAX_VELOCITY = 1
|
||||||
CORNER_FACTOR = 0.005
|
CORNER_FACTOR = 0.005*3
|
||||||
|
|
||||||
JOG_ACCELERATION = 8
|
JOG_ACCELERATION = 8
|
||||||
JOG_MAX_VELOCITY = 6
|
JOG_MAX_VELOCITY = 5
|
||||||
|
|
||||||
VID_PID = '04D8:FD92'
|
VID_PID = '04D8:FD92'
|
||||||
|
|
||||||
|
@ -170,6 +170,11 @@ class Device(object):
|
||||||
self.run_plan(plan)
|
self.run_plan(plan)
|
||||||
|
|
||||||
def run_drawing(self, drawing, progress=True):
|
def run_drawing(self, drawing, progress=True):
|
||||||
|
print 'number of paths : %d' % len(drawing.paths)
|
||||||
|
print 'pen down length : %g' % drawing.down_length
|
||||||
|
print 'pen up length : %g' % drawing.up_length
|
||||||
|
print 'total length : %g' % drawing.length
|
||||||
|
print 'drawing bounds : %s' % str(drawing.bounds)
|
||||||
self.pen_up()
|
self.pen_up()
|
||||||
position = (0, 0)
|
position = (0, 0)
|
||||||
bar = Bar(drawing.length, enabled=progress)
|
bar = Bar(drawing.length, enabled=progress)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
from math import sin, cos, radians
|
from math import sin, cos, radians, hypot
|
||||||
|
|
||||||
from .paths import (
|
from .paths import (
|
||||||
simplify_paths, sort_paths, join_paths, crop_paths, convex_hull,
|
simplify_paths, sort_paths, join_paths, crop_paths, convex_hull,
|
||||||
|
@ -19,6 +19,7 @@ class Drawing(object):
|
||||||
def dirty(self):
|
def dirty(self):
|
||||||
self._bounds = None
|
self._bounds = None
|
||||||
self._length = None
|
self._length = None
|
||||||
|
self._down_length = None
|
||||||
self._hull = None
|
self._hull = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -96,9 +97,24 @@ class Drawing(object):
|
||||||
@property
|
@property
|
||||||
def length(self):
|
def length(self):
|
||||||
if self._length is None:
|
if self._length is None:
|
||||||
self._length = paths_length(self.paths)
|
length = self._down_length
|
||||||
|
for p0, p1 in zip(self.paths, self.paths[1:]):
|
||||||
|
x0, y0 = p0[-1]
|
||||||
|
x1, y1 = p1[0]
|
||||||
|
length += hypot(x1 - x0, y1 - y0)
|
||||||
|
self._length = length
|
||||||
return self._length
|
return self._length
|
||||||
|
|
||||||
|
@property
|
||||||
|
def up_length(self):
|
||||||
|
return self.length - self.down_length
|
||||||
|
|
||||||
|
@property
|
||||||
|
def down_length(self):
|
||||||
|
if self._down_length is None:
|
||||||
|
self._down_length = paths_length(self.paths)
|
||||||
|
return self._down_length
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def width(self):
|
def width(self):
|
||||||
x1, y1, x2, y2 = self.bounds
|
x1, y1, x2, y2 = self.bounds
|
||||||
|
|
|
@ -14,7 +14,7 @@ def main():
|
||||||
# print len(d.paths)
|
# print len(d.paths)
|
||||||
print 'transforming paths'
|
print 'transforming paths'
|
||||||
# d = d.scale(1, -1)
|
# d = d.scale(1, -1)
|
||||||
d = d.rotate(180)
|
# d = d.rotate(180)
|
||||||
d = d.rotate_and_scale_to_fit(12, 8.5, step=90)
|
d = d.rotate_and_scale_to_fit(12, 8.5, step=90)
|
||||||
print 'sorting paths'
|
print 'sorting paths'
|
||||||
d = d.sort_paths()
|
d = d.sort_paths()
|
||||||
|
|
Loading…
Reference in New Issue