.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/geometry/curves/plot_01_helix_frenet_frame.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_geometry_curves_plot_01_helix_frenet_frame.py: The Frenet-Serret frame of a circular helix ================================================== A helix has constant curvature and torsion -- both confirmed here against their closed forms -- and the moving tangent/normal/binormal frame is visualized in 2D projection alongside an ellipse (whose curvature varies). .. GENERATED FROM PYTHON SOURCE LINES 12-18 .. code-block:: Python import numpy as np from mathematicskit.geometry import frenet_serret_frame from mathematicskit.geometry.utils.curves_library import ellipse, helix from mathematicskit.geometry.visualizers.plots import plot_curve_frame .. GENERATED FROM PYTHON SOURCE LINES 19-21 Helix: constant curvature and torsion ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 21-32 .. code-block:: Python a, b = 3.0, 2.0 t = np.linspace(0.0, 4.0 * np.pi, 1000) result = frenet_serret_frame(helix(a, b), t) expected_curvature = a / (a**2 + b**2) expected_torsion = b / (a**2 + b**2) print(f"curvature: mean={np.mean(result.curvature):.6f}, closed form={expected_curvature:.6f}") print(f"torsion: mean={np.mean(result.torsion):.6f}, closed form={expected_torsion:.6f}") print(f"total arc length: {result.arc_length[-1]:.4f}") .. rst-class:: sphx-glr-script-out .. code-block:: none curvature: mean=0.230419, closed form=0.230769 torsion: mean=0.153480, closed form=0.153846 total arc length: 45.3079 .. GENERATED FROM PYTHON SOURCE LINES 33-35 An ellipse: curvature varies around the curve ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 35-40 .. code-block:: Python ellipse_result = frenet_serret_frame(ellipse(3.0, 1.0), np.linspace(0.0, 2.0 * np.pi, 200, endpoint=False)) print(f"\nellipse curvature range: [{ellipse_result.curvature.min():.4f}, {ellipse_result.curvature.max():.4f}]") plot_curve_frame(ellipse_result) .. image-sg:: /api/gallery/geometry/curves/images/sphx_glr_plot_01_helix_frenet_frame_001.png :alt: Frenet-Serret frame (red=tangent, green=normal) :srcset: /api/gallery/geometry/curves/images/sphx_glr_plot_01_helix_frenet_frame_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none ellipse curvature range: [0.1111, 3.0000] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.023 seconds) .. _sphx_glr_download_api_gallery_geometry_curves_plot_01_helix_frenet_frame.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_helix_frenet_frame.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_helix_frenet_frame.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_helix_frenet_frame.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_