def CreateSpiral(self, fp, a): m = fp.Profile.Shape.BoundBox.Center # Center of the profile myNumRot = fp.Rotations myRadius = m.distanceToLine(fp.Center, fp.Center + fp.Axis) myGrowth = Growth myPitch = 1.0 myHeight = myNumRot * myPitch myAngle = atan(myGrowth / myPitch) assert myGrowth > 0, u"Growth too small" assert myNumRot > 0, u"Number of rotations too small" aPnt = VEC(0.0, 0.0, 0.0) aDir = VEC(2.0 * pi, myPitch, 0.0) surf = Part.Cone(aPnt, DIR_Z, 1.0, 0.0) line = Part.LineSegment(aPnt, aDir) beg = line.value(0) end = line.value(aDir.Length * myNumRot) # calculate end point for conical helix v = myHeight / cos(myAngle) u = myNumRot * 2.0 * pi segm = Part.LineSegment(beg, VEC(u, v, 0)) edgeOnSurf = surf.project(segm) wire = edgeOnSurf.toShape() aPlane = Part.Plane(aPnt, DIR_Z) range = (myNumRot + 1) * myGrowth + 1 + myRadius aPlane.toShape().project(wire) return spiral
def testderivatives(self): def get_dn(surface, u, v): pos = surface.value(u, v) v10 = surface.getDN(u, v, 1, 0) v01 = surface.getDN(u, v, 0, 1) v11 = surface.getDN(u, v, 1, 1) return (pos, v10, v01, v11) cone = Part.Cone() cone.SemiAngle = 0.2 cone.Radius = 2.0 u, v = (5.0, 5.0) vp, v1, v2, v3 = get_dn(cone, u, v) shape = cone.toShape(0, 2*math.pi, 0, 10) shape = shape.toNurbs() spline = shape.Face1.Surface u, v = spline.parameter(vp) wp, w1, w2, w3 = get_dn(spline, u, v) self.assertAlmostEqual(vp.distanceToPoint(wp), 0) self.assertAlmostEqual(v1.getAngle(w1), 0) self.assertAlmostEqual(v2.getAngle(w2), 0) self.assertAlmostEqual(v3.getAngle(w3), 0)