Convex Hull#
In geometry the convex hull of a point cloud is the smallest convex shape that contains all points, see Wikipedia.
Magpylib offers construction of convex hull magnets by combining the magpylib.magnets.TriangularMesh and the scipy.spatial.ConvexHull classes via the classmethod from_ConvexHull. Note, that the Scipy method does not guarantee correct face orientations if reorient_faces is disabled.
Pyramid magnet#
This is the fastest way to construct a pyramid magnet.
import magpylib as magpy
# Create pyramid magnet
points = [(-2,-2,0), (-2,2,0), (2,-2,0), (2,2,0), (0,0,3)]
tmesh_pyramid = magpy.magnet.TriangularMesh.from_ConvexHull(
magnetization=(0, 0, 1000),
points=points,
style_label="Pyramid Magnet",
)
# Display graphically
tmesh_pyramid.show(backend="plotly")