Skip to content

Commit

Permalink
update jupyter-notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
looooo committed Jan 10, 2024
1 parent 5ce0a50 commit 3fa30b7
Showing 1 changed file with 38 additions and 47 deletions.
85 changes: 38 additions & 47 deletions examples/worm_cutting_tool/cutting_tool_worm_assembly.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,24 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 1,
"id": "0811a6d6-4544-4a99-b4bd-ba5cf6b9027e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PATH_TO_FREECAD_LIBDIR not specified, using default FreeCAD version in /Users/lo/mambaforge/envs/freecad/lib\n"
]
},
{
"data": {
"text/plain": [
"<Shape object at 0x6000011f2df0>"
"<Part::PartFeature>"
]
},
"execution_count": 12,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -464,17 +471,18 @@
" def z(y, t):\n",
" r = length(y)\n",
" return - module * num_threads * np.arcsin(x / r) / 2 + r * np.tan(alpha) + t\n",
" # return r * np.tan(alpha) + t\n",
" \n",
" def dz_dy(y):\n",
" r = length(y)\n",
" return module * num_threads * x * dlength_dy(y) / \\\n",
" (2 * np.sqrt(1 - x ** 2 / r ** 2 ) * r ** 2) + \\\n",
" np.tan(alpha) * dlength_dy(y)\n",
" # return np.tan(alpha) * dlength_dy(y)\n",
" \n",
" def distance_yp(y, t):\n",
" return np.sqrt((y_p - y) ** 2 + z(y, t) ** 2)\n",
"\n",
" def distance_yp_2(y, t):\n",
" return (y_p - y) ** 2 + z(y, t) ** 2\n",
" \n",
" def ddistance_yp_dy(y, t):\n",
" return (y - y_p + z(y, t) * dz_dy(y)) / distance_yp(y, t)\n",
Expand All @@ -489,7 +497,7 @@
"\n",
" def min_head(pars):\n",
" y, t = pars\n",
" r_0 = y_p - 2 * module # * (1 + clearence)\n",
" r_0 = y_p - 5 * module # * (1 + clearence)\n",
" # y_inner = r_0 * np.cos(np.arcsin(x / r_0))\n",
" return ddistance_yp_dy(y, t) ** 2 + (y - r_0) ** 2\n",
"\n",
Expand Down Expand Up @@ -526,37 +534,45 @@
" T = np.linalg.inv(T_2 @ T_1 @ T_0)\n",
" \n",
" # find point on curve for given t\n",
" y = sp.optimize.minimize(distance_yp, y_p, (t)).x[0]\n",
" y = sp.optimize.root(ddistance_yp_dy, y_p, (t)).x[0]\n",
" z_i = z(y, t) # - y_p * np.tan(alpha) + np.sign(alpha) * module * np.pi / 4\n",
" point = np.array([x, y, z_i, 1.])\n",
" xyz_section.append((T @ point)[:3])\n",
" xyz.append(np.array(xyz_section))\n",
"\n",
" return np.array(xyz)\n",
"\n",
"# parameters\n",
"module = 1.\n",
"teeth = 50\n",
"height = 5\n",
"worm_pitch_diameter = 10\n",
"num_threads = 1\n",
"alpha = np.deg2rad(20)\n",
"y_p = worm_pitch_diameter / 2\n",
"r_w = teeth * module / 2\n",
"clearence = 0.25\n",
"head = 0.\n",
" \n",
"# create two surfaces one for positive alpha and one for negative alpha\n",
"\n",
"for alpha in [np.deg2rad(- 20), np.deg2rad(20)]: \n",
"for alpha_i in [-alpha, alpha]: \n",
" curves = []\n",
" for line in compute_involute(alpha=alpha).transpose(1, 0, 2):\n",
" xyz = compute_involute(\n",
" module=module,\n",
" teeth=teeth, \n",
" height=height,\n",
" worm_pitch_diameter=worm_pitch_diameter,\n",
" num_threads=num_threads,\n",
" alpha=alpha_i)\n",
" \n",
" for line in xyz.transpose(1, 0, 2):\n",
" bs = part.BSplineCurve()\n",
" points = [app.Vector(*point) for point in line]\n",
" bs.interpolate(points)\n",
" curves.append(bs.toShape())\n",
" part.show(part.makeLoft(curves))\n",
"\n",
"# create cutting survaces for head and bottom\n",
"# 1. compute strat and end of phi\n",
"\n",
"height = 5\n",
"worm_pitch_diameter = 10\n",
"teeth = 15\n",
"y_p = worm_pitch_diameter / 2\n",
"r_w = 7.5\n",
"module = 1.\n",
"clearence = 0.25\n",
"head = 0.\n",
"\n",
"# create cutting surfaces for head and bottom\n",
"r_head = y_p - module * (1 + head)\n",
"r_foot = y_p + module * (1 + clearence)\n",
"\n",
Expand Down Expand Up @@ -593,31 +609,6 @@
"part.show(part.makeLoft(curves_head))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "5737ef53-ab3c-4ea4-98e7-09cfc111f956",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on function numeric_transformation in module pygears.transformation:\n",
"\n",
"numeric_transformation(angle, axis, translation=array([0., 0., 0.]))\n",
" see http://en.wikipedia.org/wiki/SO%284%29#The_Euler.E2.80.93Rodrigues_formula_for_3D_rotations\n",
" angle: angle of rotation\n",
" axis: the axis of the rotation\n",
" translation: translation of transformation\n",
"\n"
]
}
],
"source": [
"help(numeric_transformation)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 3fa30b7

Please sign in to comment.