Пример #1
0
    def execute(self, fp):
        fp.gear.z = fp.teeth
        fp.gear.module = fp.module.Value
        fp.gear.pressure_angle = (90 - fp.pressure_angle.Value) * np.pi / 180.
        fp.gear.pitch_angle = fp.pitch_angle.Value * np.pi / 180
        fp.gear.backlash = fp.backlash.Value
        scale = fp.module.Value * fp.gear.z / 2 / \
            np.tan(fp.pitch_angle.Value * np.pi / 180)
        fp.gear.clearance = fp.clearance / scale
        fp.gear._update()
        pts = list(fp.gear.points(num=fp.numpoints))
        rot = rotation3D(2 * np.pi / fp.teeth)
        # if fp.beta.Value != 0:
        #     pts = [np.array([self.spherical_rot(j, fp.beta.Value * np.pi / 180.) for j in i]) for i in pts]

        rotated_pts = pts
        for i in range(fp.gear.z - 1):
            rotated_pts = list(map(rot, rotated_pts))
            pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
            pts += rotated_pts
        pts.append(np.array([pts[-1][-1], pts[0][0]]))
        wires = []
        if not "version" in fp.PropertiesList:
            scale_0 = scale - fp.height.Value / 2
            scale_1 = scale + fp.height.Value / 2
        else:  # starting with version 0.0.2
            scale_0 = scale - fp.height.Value
            scale_1 = scale
        if fp.beta.Value == 0:
            wires.append(make_bspline_wire([scale_0 * p for p in pts]))
            wires.append(make_bspline_wire([scale_1 * p for p in pts]))
        else:
            for scale_i in np.linspace(scale_0, scale_1, 20):
                # beta_i = (scale_i - scale_0) * fp.beta.Value * np.pi / 180
                # rot = rotation3D(beta_i)
                # points = [rot(pt) * scale_i for pt in pts]
                angle = fp.beta.Value * np.pi / 180. * \
                    np.sin(np.pi / 4) / \
                    np.sin(fp.pitch_angle.Value * np.pi / 180.)
                points = [
                    np.array(
                        [self.spherical_rot(p, angle) for p in scale_i * pt])
                    for pt in pts
                ]
                wires.append(make_bspline_wire(points))
        shape = makeLoft(wires, True)
        if fp.reset_origin:
            mat = App.Matrix()
            mat.A33 = -1
            mat.move(fcvec([0, 0, scale_1]))
            shape = shape.transformGeometry(mat)
        fp.Shape = shape
Пример #2
0
    def execute(self, fp):
        fp.gear.z = fp.teeth
        fp.gear.module = fp.m.Value
        fp.gear.pressure_angle = (90 - fp.pressure_angle.Value) * np.pi / 180.
        fp.gear.pitch_angle = fp.pitch_angle.Value * np.pi / 180
        fp.gear.backlash = fp.backlash.Value
        scale = fp.m.Value * fp.gear.z / 2 / np.tan(fp.pitch_angle.Value * np.pi / 180)
        fp.gear.clearance = fp.clearance / scale
        fp.gear._update()
        pts = list(fp.gear.points(num=fp.numpoints))
        rot = rotation3D(2  * np.pi / fp.teeth)
        # if fp.beta.Value != 0:
        #     pts = [np.array([self.spherical_rot(j, fp.beta.Value * np.pi / 180.) for j in i]) for i in pts]

        rotated_pts = pts
        for i in range(fp.gear.z - 1):
            rotated_pts = list(map(rot, rotated_pts))
            pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
            pts += rotated_pts
        pts.append(np.array([pts[-1][-1], pts[0][0]]))
        wires = []
        scale_0 = scale - fp.height.Value / 2
        scale_1 = scale + fp.height.Value / 2
        if fp.beta.Value == 0:
            wires.append(makeBSplineWire([scale_0 * p for p in pts]))
            wires.append(makeBSplineWire([scale_1 * p for p in pts]))
        else:
            for scale_i  in np.linspace(scale_0, scale_1, 20):
                # beta_i = (scale_i - scale_0) * fp.beta.Value * np.pi / 180
                # rot = rotation3D(beta_i)
                # points = [rot(pt) * scale_i for pt in pts]
                angle =  fp.beta.Value * np.pi / 180. * np.sin(np.pi / 4) / np.sin(fp.pitch_angle.Value * np.pi / 180.)
                points = [np.array([self.spherical_rot(p, angle) for p in scale_i * pt]) for pt in pts]
                wires.append(makeBSplineWire(points))
        shape = makeLoft(wires, True)
        if fp.reset_origin:
            mat = App.Matrix()
            mat.A33 = -1
            mat.move(fcvec([0, 0, scale_1]))
            shape = shape.transformGeometry(mat)
        fp.Shape = shape
Пример #3
0
 def create_teeth(self, pts, pos, teeth):
     w1 = []
     pts = [pt * pos for pt in pts]
     rotated_pts = scaled_points
     rot = rotation3D(- 2 * i * np.pi / teeth)
     for i in range(teeth - 1):
         rotated_pts = map(rot, rotated_pts)
         pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
         pts += rotated_pts
     s = Wire(Shape(w1).Edges)
     wi = []
     for i in range(teeth):
         rot = App.Matrix()
         rot.rotateZ(2 * i * np.pi / teeth)
         tooth_rot = s.transformGeometry(rot)
         if i != 0:
             pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
             pt_1 = tooth_rot.Edges[0].Vertexes[-1].Point
             wi.append(Wire([Line(pt_0, pt_1).toShape()]))
         wi.append(tooth_rot)
     pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
     pt_1 = wi[0].Edges[0].Vertexes[-1].Point
     wi.append(Wire([Line(pt_0, pt_1).toShape()]))
     return(Wire(wi))
Пример #4
0
 def create_teeth(self, pts, pos, teeth):
     w1 = []
     pts = [pt * pos for pt in pts]
     rotated_pts = scaled_points
     rot = rotation3D(-2 * i * np.pi / teeth)
     for i in range(teeth - 1):
         rotated_pts = map(rot, rotated_pts)
         pts.append(np.array([pts[-1][-1], rotated_pts[0][0]]))
         pts += rotated_pts
     s = Wire(Shape(w1).Edges)
     wi = []
     for i in range(teeth):
         rot = App.Matrix()
         rot.rotateZ(2 * i * np.pi / teeth)
         tooth_rot = s.transformGeometry(rot)
         if i != 0:
             pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
             pt_1 = tooth_rot.Edges[0].Vertexes[-1].Point
             wi.append(Wire([Line(pt_0, pt_1).toShape()]))
         wi.append(tooth_rot)
     pt_0 = wi[-1].Edges[-1].Vertexes[0].Point
     pt_1 = wi[0].Edges[0].Vertexes[-1].Point
     wi.append(Wire([Line(pt_0, pt_1).toShape()]))
     return (Wire(wi))
Пример #5
0
 def spherical_rot(self, point, phi):
     new_phi = np.sqrt(np.linalg.norm(point)) * phi
     return rotation3D(new_phi)(point)
Пример #6
0
 def spherical_rot(self, point, phi):
     new_phi = np.sqrt(np.linalg.norm(point)) * phi
     return rotation3D(new_phi)(point)