Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/images/shapes_3_obj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 24 additions & 7 deletions docs/tutorial/shapes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ Here are a few examples of basic shapes. They can be initialized like any other
instance of a class, with the approprate variables. Usually one or more diameters,
not radii, are expected.

All shapes are classes in ``mumaxplus.util.shape``, which has been imported as
``shapes`` above. Hence, all built-in shapes can be found by

.. code-block:: python

import mumaxplus.util.shape as shapes
print(dir(shapes))

.. code-block:: console

['Circle', 'Cone', 'Cube', 'Cuboid', 'Cylinder', 'DelaunayHull', 'Dodecahedron', 'Ellipse', 'Ellipsoid', 'Empty', 'Icosahedron', 'Icosidodecahedron', 'ImageShape', 'Octahedron', 'Polygon', 'Rectangle', 'RegularPolygon', 'Shape', 'Sphere', 'Square', 'Tetrahedron', 'Torus', 'Universe', 'XRange', 'YRange', 'ZRange', '_Delaunay', '_Image', '_Path', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_np']

2D Shapes
^^^^^^^^^

Expand Down Expand Up @@ -154,17 +166,22 @@ right pixels are mapped to the given x and y coordinates.
:align: center
:width: 600px

All shapes are classes in mumaxplus.util.shape, which has been imported as
"shapes" above. Hence, all built-in shapes can be found by
ObjShape
**********

.. code-block:: python
A 3D object file (e.g., .obj) can also be used as a shape.

import mumaxplus.util.shape as shapes
print(dir(shapes))
.. code-block:: python

.. code-block:: console
plotter = pv.Plotter()
x = y = z = np.linspace(0, 1e-7, 64)
shape = shapes.ObjShape("teapot.obj", (0, 0, 0), (1e-7, 1e-7, 1e-7), keep_aspect=True, rotate_z_up=True)
plot_shape_3D(shape, x, y, z, title=shape.__class__.__name__, plotter=plotter)
plotter.show()

['Circle', 'Cone', 'Cube', 'Cuboid', 'Cylinder', 'DelaunayHull', 'Dodecahedron', 'Ellipse', 'Ellipsoid', 'Empty', 'Icosahedron', 'Icosidodecahedron', 'ImageShape', 'Octahedron', 'Polygon', 'Rectangle', 'RegularPolygon', 'Shape', 'Sphere', 'Square', 'Tetrahedron', 'Torus', 'Universe', 'XRange', 'YRange', 'ZRange', '_Delaunay', '_Image', '_Path', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_np']
.. image:: ../images/shapes_3_obj.png
:align: center
:width: 600px

Transformations
---------------
Expand Down
3 changes: 3 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ dependencies:
- jupyter
- ipywidgets
- pyvista
- trimesh
- networkx
- rtree
- vtk
- pillow # should be contained in matplotlib
- pandas
Expand Down
43 changes: 34 additions & 9 deletions examples/shape.ipynb
Comment thread
JonathanMaes marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,29 @@
"source": [
"## Built-in Shapes\n",
"Here are a few examples of basic shapes. They can be initialized like any other instance of a class, with the approprate variables. Usually one or more diameters, not radii, are expected.\n",
"\n",
"All shapes are classes in mumaxplus.util.shape, which has been imported as \"shapes\" above. Hence, all built-in shapes can be found by\n",
"```python\n",
"import mumaxplus.util.shape as shapes\n",
"print(dir(shapes))\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "53a62385-cfda-41d8-8d94-6f82ecafcb91",
"metadata": {},
"outputs": [],
"source": [
"print(dir(shapes))"
]
},
{
"cell_type": "markdown",
"id": "1b1b757a-50ea-4348-9209-a08c9af17ee7",
"metadata": {},
"source": [
"### 2D Shapes"
]
},
Expand Down Expand Up @@ -196,24 +219,26 @@
},
{
"cell_type": "markdown",
"id": "1b1b757a-50ea-4348-9209-a08c9af17ee7",
"id": "a95aeae5",
"metadata": {},
"source": [
"All shapes are classes in mumaxplus.util.shape, which has been imported as \"shapes\" above. Hence, all built-in shapes can be found by\n",
"```python\n",
"import mumaxplus.util.shape as shapes\n",
"print(dir(shapes))\n",
"```"
"#### ObjShape\n",
"\n",
"A 3D object file (e.g., `.obj`) can also be used as a shape."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "53a62385-cfda-41d8-8d94-6f82ecafcb91",
"id": "648c6616",
"metadata": {},
"outputs": [],
"source": [
"print(dir(shapes))"
"plotter = pv.Plotter()\n",
"x = y = z = np.linspace(0, 1e-7, 64)\n",
"shape = shapes.ObjShape(\"teapot.obj\", (0, 0, 0), (1e-7, 1e-7, 1e-7), keep_aspect=True, rotate_z_up=True)\n",
"plot_shape_3D(shape, x, y, z, title=shape.__class__.__name__, plotter=plotter)\n",
"plotter.show()"
]
},
{
Expand Down Expand Up @@ -443,7 +468,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.19"
"version": "3.13.13"
}
},
"nbformat": 4,
Expand Down
Loading