diff --git a/Scratch.ipynb b/Scratch.ipynb index e0467c1..4d91923 100644 --- a/Scratch.ipynb +++ b/Scratch.ipynb @@ -1,5 +1,29 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To do:\n", + "\n", + "- Parametrize gen_twisted_boundary over boundaries\n", + "- Encode the notions of \"generator which transforms an\n", + "existing list of boundaries\", \"generator which transforms\n", + "another generator\"\n", + "- Work directly with lists of boundaries. The only thing\n", + "I ever do with them is apply transforms to all of them, or\n", + "join adjacent ones with corresponding elements.\n", + "- Refactor/rewrite 'concat' with meshes because I think it\n", + "is scaling horribly. Perhaps have pre-allocated arrays that\n", + "scale by a factor of 1.5 every time they need to be grown, or\n", + "something.\n", + "- Why do I get the weird zig-zag pattern on the triangles,\n", + "despite larger numbers of them? Is it something in how I\n", + "twist the frames? (Note that I always connect one diagonal\n", + "on the boundaries - but I can choose the other. This might\n", + "not matter, but I should understand why.)" + ] + }, { "cell_type": "code", "execution_count": 1, @@ -17,280 +41,34 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#mesh = examples.ram_horn()\n", "#mesh = examples.twist()\n", "#mesh = examples.twist_nonlinear()\n", - "#mesh = examples.twist_from_gen()" + "#mesh = examples.twist_from_gen()\n", + "#mesh = examples.twisty_torus(4000)" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "mesh = examples.twisty_torus(400)" + "# for me to be able to nest this, gen_twisted_boundary has to\n", + "# be parametrized over some other boundary (the way )\n", + "gen = examples.gen_inc_y(examples.gen_twisted_boundary())\n", + "mesh = gen2mesh(gen, 100, True)" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "# what even is this?\n", - "dx0=2\n", - "frames=100\n", - "b = numpy.array([\n", - " [0, 0, 0],\n", - " [1, 0, 0],\n", - " [1, 0, 1],\n", - " [0, 0, 1],\n", - "], dtype=numpy.float64) - [0.5, 0.5, 0]\n", - "ang = -numpy.pi*2 / frames\n", - "# negative because of winding order annoyance\n", - "mesh2 = meshutil.FaceVertexMesh.Empty()\n", - "xf = meshutil.Transform() \\\n", - " .translate(dx0, 0, 0)\n", - "b0 = xf.apply_to(b)\n", - "for layer in range(frames):\n", - " b_sub0 = xf.apply_to(b)\n", - " incr = meshutil.Transform().rotate([0,0,1], ang)\n", - " b_sub1 = xf.compose(incr).apply_to(b)\n", - " m = meshutil.join_boundary_simple(b_sub0, b_sub1)\n", - " mesh2 = mesh2.concat(m)\n", - " xf = xf.compose(incr)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "face_normals didn't match triangles, ignoring!\n", - "/home/hodapp/.local/lib/python3.6/site-packages/IPython/core/display.py:694: UserWarning: Consider using IPython.display.IFrame instead\n", - " warnings.warn(\"Consider using IPython.display.IFrame instead\")\n" - ] - }, - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "# Work around some annoying-ass trimesh/threejs bug:\n", "wtf = meshutil.Transform().scale(0.1).translate(20,0,0)\n", @@ -298,11 +76,18 @@ "base = meshutil.cube(open_xz=False).transform(center)\n", "base = base.transform(wtf)\n", "# to enable:\n", - "mesh = mesh.concat(base)\n", - "\n", - "mesh_fname = \"twist.stl\"\n", - "mesh.to_stl_mesh().save(mesh_fname)\n", + "mesh_out = mesh.concat(base)\n", "\n", + "mesh_fname = \"twist_wtf.stl\"\n", + "mesh_out.to_stl_mesh().save(mesh_fname)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# TODO: Just use the mesh data directly (no sense in saving & re-loading)\n", "m = trimesh.load_mesh(mesh_fname)\n", "#m.show()\n",