.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/example_generate_parametric_surfaces.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_example_generate_parametric_surfaces.py: .. _example_generation_parametric_surfaces: =================================== Generating parametric surfaces in slam =================================== .. GENERATED FROM PYTHON SOURCE LINES 8-17 .. code-block:: default # Authors: # Guillaume Auzias # Julien Barrès # License: BSD (3-clause) # sphinx_gallery_thumbnail_number = 2 .. GENERATED FROM PYTHON SOURCE LINES 18-19 Importation of slam modules .. GENERATED FROM PYTHON SOURCE LINES 19-23 .. code-block:: default import slam.generate_parametric_surfaces as sgps import slam.plot as splt import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 24-25 Generating a quadrix surface .. GENERATED FROM PYTHON SOURCE LINES 25-47 .. code-block:: default K = [1, 1] quadric = sgps.generate_quadric( K, nstep=[20, 20], ax=3, ay=1, random_sampling=True, ratio=0.3, random_distribution_type="gamma", ) quadric_mean_curv = sgps.quadric_curv_mean(K)( np.array(quadric.vertices[:, 0]), np.array(quadric.vertices[:, 1]) ) visb_sc = splt.visbrain_plot( mesh=quadric, tex=quadric_mean_curv, caption="quadric", cblabel="mean curvature" ) visb_sc.preview() .. image:: /auto_examples/images/sphx_glr_example_generate_parametric_surfaces_001.png :alt: example generate parametric surfaces :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 48-49 Generating an ellipsiods .. GENERATED FROM PYTHON SOURCE LINES 49-61 .. code-block:: default nstep = 50 randomSampling = True a = 2 b = 1 ellips = sgps.generate_ellipsiod(a, b, nstep, randomSampling) visb_sc = splt.visbrain_plot(mesh=ellips, caption="ellipsoid") visb_sc.preview() .. image:: /auto_examples/images/sphx_glr_example_generate_parametric_surfaces_002.png :alt: example generate parametric surfaces :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 62-63 Generating a sphere .. GENERATED FROM PYTHON SOURCE LINES 63-71 .. code-block:: default sphere_regular = sgps.generate_sphere_icosahedron(subdivisions=3, radius=4) visb_sc = splt.visbrain_plot(mesh=sphere_regular, caption="sphere_regular") visb_sc.preview() .. image:: /auto_examples/images/sphx_glr_example_generate_parametric_surfaces_003.png :alt: example generate parametric surfaces :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 72-74 Generating a more randomized sphere (random sampling with the same number of vertices) .. GENERATED FROM PYTHON SOURCE LINES 74-86 .. code-block:: default sphere_random = sgps.generate_sphere_random_sampling( vertex_number=sphere_regular.vertices.shape[0], radius=4 ) visb_sc = splt.visbrain_plot( mesh=sphere_random, caption="sphere_random", visb_sc=visb_sc ) visb_sc.preview() .. image:: /auto_examples/images/sphx_glr_example_generate_parametric_surfaces_004.png :alt: example generate parametric surfaces :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 87-88 Computation of the volume and volume error of the spheres .. GENERATED FROM PYTHON SOURCE LINES 88-100 .. code-block:: default analytical_vol = (4 / 3) * np.pi * np.power(4, 3) print( "volume error for regular sampling: {:.3f}".format( sphere_regular.volume - analytical_vol ) ) print( "volume error for random sampling: {:.3f}".format( sphere_random.volume - analytical_vol ) ) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none volume error for regular sampling: -2.307 volume error for random sampling: -5.000 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.998 seconds) .. _sphx_glr_download_auto_examples_example_generate_parametric_surfaces.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_generate_parametric_surfaces.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_generate_parametric_surfaces.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_