vispy.visuals.mesh_normals module#
A visual for displaying mesh normals as lines.
- class vispy.visuals.mesh_normals.MeshNormalsVisual(meshdata=None, primitive='face', length=None, length_method='median_edge', length_scale=1.0, **kwargs)#
Bases:
LineVisual
Display mesh normals as lines.
- Parameters:
- meshdatainstance of
MeshData
The mesh data.
- primitive{‘face’, ‘vertex’}
The primitive type on which to compute and display the normals.
- lengthNone or float or array-like, optional
The length(s) of the normals. If None, the length is computed with length_method.
- length_method{‘median_edge’, ‘max_extent’}, default=’median_edge’
The method to compute the length of the normals (when length=None). Methods: ‘median_edge’, the median edge length; ‘max_extent’, the maximum side length of the bounding box of the mesh.
- length_scalefloat, default=1.0
A scale factor applied to the length computed with length_method.
- **kwargsdict, optional
Extra arguments to define the appearance of lines. Refer to
LineVisual
.
- meshdatainstance of
Examples
Create a
MeshVisual
on which to display the normals and get theMeshData
:>>> mesh = MeshVisual(vertices=vertices, faces=faces, ...) >>> meshdata = mesh.mesh_data
Create a visual for the mesh normals:
>>> normals = MeshNormalsVisual(meshdata)
Display the face normals:
>>> MeshNormalsVisual(..., primitive='face') >>> MeshNormalsVisual(...) # equivalent (default values)
Display the vertex normals:
>>> MeshNormalsVisual(..., primitive='vertex')
Fixed length for all normals:
>>> MeshNormalsVisual(..., length=0.25)
Individual length per normal:
>>> lengths = np.array([0.5, 0.2, 0.7, ..., 0.7], dtype=float) >>> MeshNormalsVisual(..., length=lengths) >>> assert len(lengths) == len(faces) # for face normals >>> assert len(lengths) == len(vertices) # for vertex normals
Normals at about the length of a triangle:
>>> MeshNormalsVisual(..., length_method='median_edge', length_scale=1.0) >>> MeshNormalsVisual(...) # equivalent (default values)
Normals at about 10% the size of the mesh:
>>> MeshNormalsVisual(..., length_method='max_extent', length_scale=0.1)
- set_data(meshdata=None, primitive='face', length=None, length_method='median_edge', length_scale=1.0, **kwargs)#
Set the data used to draw this visual
- Parameters:
- meshdatainstance of
MeshData
The mesh data.
- primitive{‘face’, ‘vertex’}
The primitive type on which to compute and display the normals.
- lengthNone or float or array-like, optional
The length(s) of the normals. If None, the length is computed with length_method.
- length_method{‘median_edge’, ‘max_extent’}, default=’median_edge’
The method to compute the length of the normals (when length=None). Methods: ‘median_edge’, the median edge length; ‘max_extent’, the maximum side length of the bounding box of the mesh.
- length_scalefloat, default=1.0
A scale factor applied to the length computed with length_method.
- **kwargsdict, optional
Extra arguments to define the appearance of lines. Refer to
LineVisual
.
- meshdatainstance of