From 0bcf09be33f46884d217ce3289215faa309a3534 Mon Sep 17 00:00:00 2001 From: "filipe@flexcompute.com" Date: Mon, 8 Dec 2025 15:50:51 -0300 Subject: [PATCH] adding revolve function --- CreatingGeometryUsingTrimesh.ipynb | 7863 +++++++--------------------- 1 file changed, 1879 insertions(+), 5984 deletions(-) diff --git a/CreatingGeometryUsingTrimesh.ipynb b/CreatingGeometryUsingTrimesh.ipynb index 95cd1824..3106d89a 100644 --- a/CreatingGeometryUsingTrimesh.ipynb +++ b/CreatingGeometryUsingTrimesh.ipynb @@ -80,1230 +80,319 @@ " \n", " \n", "
\n", - " \n", + "\" width=\"100%\" height=\"500px\" style=\"border:none;\">" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# define a simple aspheric-like lens profile in the x-z plane\n", + "lens_vertices = np.array(\n", + " [\n", + " [0.0, 0.0],\n", + " [0.5, 0.0],\n", + " [0.8, 0.15],\n", + " [0.9, 0.35],\n", + " [0.5, 0.6],\n", + " [0.0, 0.6],\n", + " ]\n", + ")\n", + "\n", + "# visualize the 2D polygon profile before revolving\n", + "fig, ax = plt.subplots(tight_layout=True)\n", + "closed_vertices = np.vstack([lens_vertices, lens_vertices[0]])\n", + "ax.plot(closed_vertices[:, 0], closed_vertices[:, 1], marker=\"o\")\n", + "ax.fill(closed_vertices[:, 0], closed_vertices[:, 1], alpha=0.2)\n", + "ax.set_aspect(\"equal\")\n", + "ax.set_xlabel(\"x (μm)\")\n", + "ax.set_ylabel(\"z (μm)\")\n", + "ax.set_title(\"Polygon profile prior to revolution\")\n", + "plt.show()\n", + "\n", + "lens_mesh = revolve_polygon(lens_vertices, segments=180)\n", + "\n", + "lens_mesh.show()" + ] } ], "metadata": { "description": "This notebook demonstrates how to define complex geometries using trimesh in Tidy3D FDTD.", "feature_image": "", "kernelspec": { - "display_name": ".venv", + "display_name": "td2100rc2", "language": "python", "name": "python3" }, @@ -6937,7 +2832,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.5" + "version": "3.11.13" }, "title": "Defining complex geometries using trimesh | Flexcompute" },