def test_poly_path(self): """ """ blueprint('Test ParametricPolyPath', 'A4') offset = Point(0., 0.) class Pillow(ParametricPolyPathBase): DEFAULT_PAR_DICT = dict(width=75., height=25.) def construct(self): """ """ hw = 0.5 * self.width hh = 0.5 * self.height p = Point(-hw, hh) top = Line(p, p.move(self.width, 0.)) c = top.end_point.move(hh, -90.) right = CircularArc(c, hh, 90., -180.) bot = right.connecting_line(self.width) left = CircularArc(c.move(self.width, 180.), hh, -90., -180.) return locals() p = Pillow() p.draw_construction(offset) p.draw(offset) p.draw_reference_points(offset)
def test_head_accuracy(self): """ """ blueprint('Music Man Axis head accuracy', 'A4') offset = Point(-60., 0.) plt.plot(self.xh + offset.x, self.yh + offset.y, 'o') head = Head() head.draw_top(offset)
def test_body_accuracy(self): """ """ blueprint('Music Man Axis body accuracy', 'A1') offset = Point(-200., -50.) plt.plot(self.xb + offset.x, self.yb + offset.y, 'o') body = Body() body.draw(offset)
def test_body_draw(self): """ """ blueprint('Music Man Axis', 'A1') offset = Point(-200., -50.) body = Body() body.draw_construction(offset) body.draw(offset) body.draw_reference_points(offset)
def test_accuracy(self): """ """ blueprint('Fender Stratocaster accuracy', 'A4') x, y, xh, yh = self.load_data() offset = Point(-80., 0.) plt.plot(x + offset.x, y + offset.y, 'o') head = FenderStratocasterContour() head.draw(offset)
def test_head_draw(self): """ """ blueprint('Music Man Axis head', 'A4') offset = Point(-60., 0.) head = Head() head.contour.draw_construction(offset) head.draw_top(offset) head.contour.draw_reference_points(offset)
def test_draw(self): """ """ blueprint('Fender Stratocaster', 'A4') offset = Point(-80., 0.) head = FenderStratocaster() head.contour.draw_construction(offset) head.draw_top(offset) head.dimension_top(offset) head.contour.draw_reference_points(offset)
def test_connecting_arc(self): """ """ blueprint('Test connecting arcs', 'A4') p0 = Point() d = 50. r = 15. for angle in np.linspace(0., 360., 9): l = line(p0, p0.move(d, angle)) l.draw_connecting_arc(r, 90.) l.draw_connecting_arc(r, -90.)
def test(self): """ """ offset = Point(-80., 0.) blueprint('Bliss---cool, eh?', 'A4') head = BlissContour() head.draw_construction(offset) head.draw(offset) head.draw_reference_points(offset) MusicManContour().draw(offset, color='lightgray') blueprint('Bliss simplified', 'A4') head.draw(offset)
def test_draw(offset): """ """ blueprint(f'EJ #1{offset}', 'A3', orientation='Portrait') #body = Body() #body.draw(offset) x = np.array([ 0., 15., 50., 125., 200., 230., 250., 280., 300., 325., 350., 370., 385., 400., 405., 395., 384., 380.5, 379., 383., 393., 375., 354., 340., 320., 305., 298.7, 315., 334.7, 325.8, 310., 266., 230., 200., 120., 50., 10. ]) y = np.array([ 0., 80., 131., 160., 141.5, 124.3, 113.3, 106.4, 107.4, 115., 123., 125.7, 123., 110.3, 90., 68., 57., 50., 42., 28., 10., -13.2, -27.5, -28.58, -30.5, -40.5, -60., -90, -108.7, -122.5, -127.4, -115.1, -116.2, -136., -159.4, -131., -69. ]) s = ParametricSpline(x, y) s.draw(offset) #s.draw_points(offset) #scale = 1.05 #s1 = ParametricSpline(x * scale, y * scale) #s1.draw(offset - Point(8., 0.)) h1 = 52. h2 = 25. w1 = 75. x, y = s.calculate_contour(offset, tmin=0., tmax=0.5) mask = abs(y - offset.y) > h1 x = x[mask] y = y[mask] plt.plot(x, y, color='black') plt.hlines(h1 + offset.y, x[0], x[-1]) x, y = s.calculate_contour(offset, tmin=0.5, tmax=1.) mask = np.logical_and(abs(y - offset.y) > h1, x - offset.x < 317.) x = x[mask] y = y[mask] plt.plot(x, y, color='black') plt.hlines(-h1 + offset.y, x[0], x[-1]) p0 = Point(-50., 0.) l = Line(p0, p0.move(500., 0.)) l.draw(offset) p1 = Point(200., -200.) l = Line(p1, p1.vmove(400.)) l.draw(offset)
def test_arc(self): """ """ blueprint('Test arcs', 'A4') center = Point() radius = 50. span = 15. length = 20. offset = Point(20., 20.) for start_angle in np.linspace(0., 360., 9): arc(center, radius, start_angle, span, offset, color='red').\ draw_connecting_line(length, offset, color='red', ls='dashed') arc(center, radius, start_angle, -span, offset, color='blue').\ draw_connecting_line(length, offset, color='blue', ls='dashed')
def test_drawables(self): """ """ drawables = [ Point(), Line(Point(-10., -10.), Point(10., 10)), Rectangle(Point(0., 0.), 50., 20., 2.5), Circle(Point(0., 0.), 25.), Cap(Point(0., 0.), 90., 50., 20., 2.5), Cross(Point(0., 0.), 25.), Hole(Point(0., 0.), 25.), ] offsets = [Point(), Point(50., 50.), Point(-50., -50.)] for drawable in drawables: blueprint(f'Test {drawable.__class__.__name__}', 'A4') for offset in offsets: drawable.draw(offset)
def test_point(self) -> None: """Test the Point class. """ offset = Point(0., 0.) p1 = Point(0., 0., 'p1') p2 = Point(0., 50., 'p2') p3 = Point(-50., -50., 'p2') p4 = Point(50., 50., 'p4') p5 = Point(100., 50., 'p5') blueprint('Test dimensioning', 'A4') p1.draw(offset) p2.draw(offset) p3.draw(offset) p4.draw(offset) p5.draw(offset) dim(p1, p2, offset) dim(p1, p3, offset) dim(p3, p1, offset) dim(p4, p5, offset)
def test_caps(self): """ """ blueprint('Test caps', 'A4') start_point = Point(0., 0.) base = 50. height = 25. corner_radius = 2.5 offset = Point(-50., 50.) start_point.draw(offset) ccap(start_point, base, height, corner_radius, offset) offset = Point(-50., -75.) start_point.draw(offset) rccap(start_point, base, height, corner_radius, offset) offset = Point(50., 50.) start_point.draw(offset) ucap(start_point, base, height, corner_radius, offset) offset = Point(50., -50.) start_point.draw(offset) rucap(start_point, base, height, corner_radius, offset)
def test_circular_arc(self) -> None: """Test the circular arc class. """ blueprint('Test CircularArc', 'A4') offset = Point(0., 0.) c1 = Point(0., 0., 'c1') arc1 = self._test_circular_arc_base(c1, 20., 0., 90., offset) c2 = Point(40., 40., 'c2') arc2 = self._test_circular_arc_base(c2, 30, 0., -90., offset, color='red') c3 = Point(-40., -40., 'c3') arc3 = self._test_circular_arc_base(c3, 25, 250., 40., offset, color='blue') c4 = Point(-40., 40., 'c4') arc4 = self._test_circular_arc_base(c4, 15, 180., -90., offset)
def test_body_draw_split(self): """ """ x0 = 200. y0 = 0. blueprint('Music Man Axis 1', 'A3', orientation='Portrait') offset = Point(-100., 15.) plt.hlines(y0, -1000., 1000.) plt.vlines(x0 + offset.x, -1000., 1000.) body = Body() body.draw_construction(offset) body.draw(offset) body.draw_reference_points(offset) plt.savefig('axis1.pdf') blueprint('Music Man Axis 2', 'A3', orientation='Portrait') offset = Point(-300., 15.) plt.hlines(y0, -1000., 1000.) plt.vlines(x0 + offset.x, -1000., 1000.) body = Body() body.draw_construction(offset) body.draw(offset) body.draw_reference_points(offset) plt.savefig('axis2.pdf')
def test_a4(self) -> None: """Test a plain a4 blueprint. """ blue = blueprint('Test blueprint', 'A4')
super().__init__(HumbuckerRouting, **params) class NeckPocketRoutingTemplate(RoutingTemplateBase): """Neck routing template. """ LENGTH = 280. WIDTH = 140. if __name__ == '__main__': offset = Point(0., 0.) blueprint('Single-coil Routing Template', 'A4', 'Luca Baldini', orientation='Portrait') SingleCoilRoutingTemplate().draw(offset) plt.savefig('single_coil_routing_template.pdf') blueprint('Humbucker Routing Template', 'A4', 'Luca Baldini', orientation='Portrait') HumbuckerRoutingTemplate().draw(offset, drilling_holes=True) plt.savefig('humbucker_routing_template.pdf') blueprint('Neck Pocket Routing Template', 'A3', 'Luca Baldini', orientation='Landscape')
class DrillPress(Drawable): """ """ width : float = 180. height : float = 120. mandrel_diameter : float = 40. head_radius : float = 40. def _draw(self, offset, **kwargs): """Overloaded method. """ p = Point(0., 0.) + offset hole(p, self.mandrel_diameter) p = p.hmove(-0.75 * self.width) slope = -np.degrees(np.arctan2(0.5 * (self.height - self.mandrel_diameter), self.width)) l = 0.85 * self.width vline(p.vmove(-0.4 * self.height), self.height).\ draw_connecting_line(l, slope).\ draw_connecting_arc(self.head_radius, -180. + 2. * abs(slope)).\ draw_connecting_line(l) if __name__ == '__main__': blueprint('Jigsaw jig', 'A4') DrillPress().draw(Point(50., 0.)) plt.show()
h, 0., offset, ls='dashed') rectangle(center.hmove(d), self.base_stud_thickness, h, 0., offset, ls='dashed') # Hole grid and channels. h = 4. * self.hole_pitch + self.hole_diameter for i in range(-4, 5): for j in range(-2, 3): if i in [-3, 0, 3]: p = Point(i * self.hole_pitch, 0.) rectangle(p, self.channel_width, h, 0.4999 * self.channel_width, offset) else: c = Point(i * self.hole_pitch, j * self.hole_pitch) hole(c, self.hole_diameter, offset=offset) if __name__ == '__main__': blueprint('Jigsaw jig', 'A1') JigsawJig().draw() blueprint('Workbench', 'A0', orientation='Landscape') Workbench().draw() plt.show()
line = self._draw_cap(p, -90., w2, l2, offset) p = line.end_point() line = self._draw_cap(p, 0., l1, w1, offset) if drilling_holes: l = self.length - 2. * self.corner_radius w = self.inner_width - 2. * self.corner_radius for p in Rectangle((0., 0.), l, w).points: Hole(p, 2 * self.corner_radius, 1.).draw(offset) l = self.wing_length - 2. * self.corner_radius w = self.outer_width - 2. * self.corner_radius for p in Rectangle((0., 0.), l, w).points: Hole(p, 2 * self.corner_radius, 1.).draw(offset) if __name__ == '__main__': blueprint('Single coil', 'A4') offset = Point(0., 0.) SingleCoilEMG().draw(offset) SingleCoilRouting().draw(offset) offset = Point(50., 0.) SingleCoilDiMarzio().draw(offset) SingleCoilRouting().draw(offset) blueprint('Humbuckers', 'A4') offset = Point(-75., 0.) HumbuckerDiMarzio().draw(offset) HumbuckerRouting().draw(offset) offset = Point(-0., 0.) HumbuckerEMG().draw(offset) HumbuckerRouting().draw(offset) offset = Point(75., 0.)