Submodule to manage point clouds.


vedo.pointcloud.Point(pos=(0, 0, 0), r=12, c='red', alpha=1)[source]

Create a simple point.


class vedo.pointcloud.Points(inputobj=None, c=(0.2, 0.2, 0.2), alpha=1, r=4)[source]

Bases: vtkmodules.vtkRenderingCore.vtkFollower, vedo.base.BaseActor

Build a Mesh made of only vertex points for a list of 2D/3D points. Both shapes (N, 3) or (3, N) are accepted as input, if N>3. For very large point clouds a list of colors and alpha can be assigned to each point in the form c=[(R,G,B,A), … ] where 0 <= R < 256, … 0 <= A < 256.

  • r (float) – point radius.

  • c (int, str, list) – color name, number, or list of [R,G,B] colors of same length as plist.

  • alpha (float) – transparency in range [0,1].


import numpy as np
from vedo import *

def fibonacci_sphere(n):
    s = np.linspace(0, n, num=n, endpoint=False)
    theta = s * 2.399963229728653
    y = 1 - s * (2/(n-1))
    r = np.sqrt(1 - y * y)
    x = np.cos(theta) * r
    z = np.sin(theta) * r
    return [x,y,z]


manypoints.py lorenz.py lorenz.py


Clustering of points in space. The radius is the radius of local search. An array named “ClusterId” is added to the vertex points.

clustering.py clustering.py

addTrail(offset=None, maxlength=None, n=50, c=None, alpha=None, lw=2)[source]

Add a trailing line to mesh. This new mesh is accessible through mesh.trail.

  • offset (float) – set an offset vector from the object center.

  • maxlength (float) – length of trailing line in absolute units

  • n (int) – number of segments to control precision

  • lw (float) – line width of the trail


See examples: trail.py airplanes.py


alignTo(target, iters=100, rigid=False, invert=False, useCentroids=False)[source]

Aligned to target mesh through the Iterative Closest Point algorithm.

The core of the algorithm is to match each vertex in one surface with the closest surface point on the other, then apply the transformation that modify one surface to best match the other (in the least-square sense).

  • rigid (bool) – if True do not allow scaling

  • invert (bool) – if True start by aligning the target to the source but invert the transformation finally. Useful when the target is smaller than the source.

  • useCentroids (bool) – start by matching the centroids of the two objects.


Set/get mesh’s transparency. Same as mesh.opacity().

applyTransform(transformation, reset=False)[source]

Apply a linear or non-linear transformation to the mesh polygonal data.

  • transformation – a vtkTransform, vtkMatrix4x4 or a 4x4 or 3x3 python or numpy matrix.

  • reset (bool) – if True reset the current transformation matrix to identity after having moved the object, otherwise the internal matrix will stay the same (to only affect visualization). It the input transformation has no internal defined matrix (ie. non linear) then reset will be assumed as True.


Calculate the average size of a mesh. This is the mean of the vertex distances from the center of mass.

caption(txt=None, point=None, size=(0.3, 0.15), pad=5, font='VictorMono', justify='center-right', vspacing=1, c=None, alpha=1, lw=1, ontop=True)[source]

Add a 2D caption to an object which follows the camera movements. Latex is not supported. Returns the same input object for concatenation.

See also vignette(), flag(), labels() and legend() with similar functionality.

  • txt (str, optional) – text to be rendered. The default is the file name.

  • point (list, optional) – anchoring point. The default is None.

  • size (list, optional) – (width, height) of the caption box. The default is (0.30, 0.15).

  • pad (float, optional) – padding space of the caption box in pixels. The default is 5.

  • font (str, optional) – font name. Font “LogoType” allows for Japanese and Chinese characters. Use a monospace font for better rendering. The default is “VictorMono”. Type vedo -r fonts for a font demo.

  • justify (str, optional) – internal text justification. The default is “center-right”.

  • vspacing (float, optional) – vertical spacing between lines. The default is 1.

  • c (str, optional) – text and box color. The default is ‘lb’.

  • alpha (float, optional) – text and box transparency. The default is 1.

  • lw (int, optional,) – line width in pixels. The default is 1.

  • ontop (bool, optional) – keep the 2d caption always on top. The default is True.

caption.py captions.py

flag_labels.py flag_labels.py

cellColors(*args, **kwargs)[source]
cellIndividualColors(colorlist, alpha=1, alphaPerCell=False)[source]

Colorize the faces of a mesh one by one passing a 1-to-1 list of colors and optionally a list of transparencies.


alphaPerCell (bool) –

Only matters if alpha is a sequence. If so: if True assume that the list of opacities is independent on the colors (same color cells can have different opacity), this can be very slow for large meshes,

if False [default] assume that the alpha matches the color list (same color has the same opacity). This is very fast even for large meshes.


Get the center of mass of mesh.

fatlimb.py fatlimb.py


Clean mesh polydata. Can also be used to decimate a mesh if tol is large. If tol=None only removes coincident points.


tol – defines how far should be the points from each other in terms of fraction of the bounding box length.

moving_least_squares1D.py moving_least_squares1D.py

clone(deep=True, transformed=False)[source]

Clone a PointCloud or Mesh object to make an exact copy of it.

  • deep (bool) – if False only build a shallow copy of the object (faster copy).

  • transformed (bool) – if True reset the current transformation of the copy to unit.

mirror.py mirror.py

clone2D(pos=(0, 0), coordsys=4, scale=None, c=None, alpha=None, ps=2, lw=1, sendback=False, layer=0)[source]

Copy a 3D Mesh into a static 2D image. Returns a vtkActor2D.

param int coordsys

the coordinate system, options are

  1. Displays

  2. Normalized Display

  3. Viewport (origin is the bottom-left corner of the window)

  4. Normalized Viewport

  5. View (origin is the center of the window)

  6. World (anchor the 2d image to mesh)

param int ps

point size in pixel units

param int lw

line width in pixel units

param bool sendback

put it behind any other 3D object

closestPoint(pt, N=1, radius=None, returnPointId=False, returnCellId=False, returnIds=None)[source]

Find the closest point(s) on a mesh given from the input point pt.

  • N (int) – if greater than 1, return a list of N ordered closest points

  • radius (float) – if given, get all points within that radius.

  • returnPointId (bool) – return point ID instead of coordinates

  • returnCellId (bool) – return cell ID in which the closest point sits

  • returnIds (bool) – obsolete, do not use.


The appropriate tree search locator is built on the fly and cached for speed. If the object is displaced/rotated you must trigger a rebuild by setting obj.point_locator=None or obj.cell_locator=None.

cmap(cname, input_array=None, on='points', arrayName='', vmin=None, vmax=None, alpha=1, n=256)[source]

Set individual point/cell colors by providing a list of scalar values and a color map. scalars can be the string name of a vtkArray.

  • cname (str, list, vtkLookupTable, matplotlib.colors.LinearSegmentedColormap) – color map scheme to transform a real number into a color.

  • on (str) – either ‘points’ or ‘cells’. Apply the color map as defined on either point or cell data.

  • arrayName (str) – give a name to the numpy array

  • vmin (float) – clip scalars to this minimum value

  • vmax (float) – clip scalars to this maximum value

  • alpha (float,list) – mesh transparency. Can be a list of values one for each vertex.

  • n (int) – number of distinct colors to be used.

color(c=False, alpha=None)[source]

Set/get mesh’s color. If None is passed as input, will use colors from active scalars. Same as mesh.c().

computeNormalsWithPCA(n=20, orientationPoint=None, flip=False)[source]

Generate point normals using PCA (principal component analysis). Basically this estimates a local tangent plane around each sample point p by considering a small neighborhood of points around p, and fitting a plane to the neighborhood (via PCA).

  • n (int) – neighborhood size to calculate the normal

  • orientationPoint (list) – adjust the +/- sign of the normals so that the normals all point towards a specified point. If None, perform a traversal of the point cloud and flip neighboring normals so that they are mutually consistent.

  • flip (bool) – flip all normals

cutWithBox(bounds, invert=False)[source]

Cut the current mesh with a box. This is much faster than cutWithMesh().

Input bounds can be either:
  • a Mesh or Points object

  • a list of 6 number representing a bounding box [xmin,xmax, ymin,ymax, zmin,zmax]

  • a list of bounding boxes like the above: [[xmin1,…], [xmin2,…], …]

from vedo import Sphere, Cube, show
mesh = Sphere(r=1, res=50)
box  = Cube(side=1.5).wireframe()
show(mesh, box, axes=1)
Check out also:

crop(), cutWithLine(), cutWithPlane(), cutWithCylinder()

cutWithCylinder(center=(0, 0, 0), axis=(0, 0, 1), r=1, invert=False)[source]

Cut the current mesh with an infinite cylinder. This is much faster than cutWithMesh().

  • center (list) – the center of the cylinder

  • normal (list) – direction of the cylinder axis

  • r (float) – radius of the cylinder

from vedo import Disc, show
disc = Disc(r1=1, r2=1.2)
mesh = disc.extrude(3, res=50).lineWidth(1)
mesh.cutWithCylinder([0,0,2], r=0.4, axis='y', invert=True)
show(mesh, axes=1)
Check out also:

crop(), cutWithBox(), cutWithPlane(), cutWithSphere()

cutWithLine(points, invert=False)[source]

Cut the current mesh with a line vertically in the z-axis direction. The polyline is defined by a set of points (z-coordinates are ignored). This is much faster than cutWithMesh().

Check out also:

crop(), cutWithBox(), cutWithPlane(), cutWithSphere()

cutWithMesh(mesh, invert=False)[source]

Cut an Mesh mesh with another Mesh.

param bool invert

if True return cut off part of Mesh.

from vedo import *
import numpy as np
x, y, z = np.mgrid[:30, :30, :30] / 15
U = sin(6*x)*cos(6*y) + sin(6*y)*cos(6*z) + sin(6*z)*cos(6*x)
iso = Volume(U).isosurface(0).smooth().c('silver').lw(1)
cube = CubicGrid(n=(29,29,29), spacing=(1,1,1))
show(iso, cube)
Check out also:

crop(), cutWithBox(), cutWithPlane(), cutWithCylinder()

cutWithPlane(origin=(0, 0, 0), normal=(1, 0, 0))[source]

Cut the mesh with the plane defined by a point and a normal.

  • origin – the cutting plane goes through this point

  • normal – normal of the cutting plane

from vedo import Cube
cube = Cube().cutWithPlane(normal=(1,1,1))


trail.py trail.py

Check out also:

crop(), cutWithBox(), cutWithCylinder(), cutWithSphere()

cutWithSphere(center=(0, 0, 0), r=1, invert=False)[source]

Cut the current mesh with an sphere. This is much faster than cutWithMesh().

  • center (list) – the center of the sphere

  • r (float) – radius of the sphere

from vedo import Disc, show
disc = Disc(r1=1, r2=1.2)
mesh = disc.extrude(3, res=50).lineWidth(1)
mesh.cutWithSphere([1,-0.7,2], r=0.5, invert=True)
show(mesh, axes=1)
Check out also:

crop(), cutWithBox(), cutWithPlane(), cutWithCylinder()

delete(points=(), cells=())[source]

Delete points and/or cells from a point cloud or mesh.

deletePoints(indices, renamePoints=False)[source]

Delete a list of vertices identified by their index.


renamePoints (bool) – if True, point indices and faces are renamed. If False, vertices are not really deleted and faces indices will stay unchanged (default, faster).

deleteMeshPoints.py deleteMeshPoints.py

densify(targetDistance=0.1, closest=6, radius=None, niter=1, maxN=None)[source]

Return a copy of the cloud with new added points. The new points are created in such a way that all points in any local neighborhood are within a target distance of one another.

For each input point, the distance to all points in its neighborhood is computed. If any of its neighbors is further than the target distance, the edge connecting the point and its neighbor is bisected and a new point is inserted at the bisection point. A single pass is completed once all the input points are visited. Then the process repeats to the number of iterations.


Points will be created in an iterative fashion until all points in their local neighborhood are the target distance apart or less. Note that the process may terminate early due to the number of iterations. By default the target distance is set to 0.5. Note that the targetDistance should be less than the radius or nothing will change on output.


This class can generate a lot of points very quickly. The maximum number of iterations is by default set to =1.0 for this reason. Increase the number of iterations very carefully. Also, maxN can be set to limit the explosion of points. It is also recommended that a N closest neighborhood is used.

density(dims=(40, 40, 40), bounds=None, radius=None, computeGradient=False, locator=None)[source]

Generate a density field from a point cloud. Input can also be a set of 3D coordinates. Output is a Volume. The local neighborhood is specified as the radius around each sample position (each voxel). The density is expressed as the number of counts in the radius search.

  • dims (int,list) – numer of voxels in x, y and z of the output Volume.

  • computeGradient (bool) – Turn on/off the generation of the gradient vector, gradient magnitude scalar, and function classification scalar. By default this is off. Note that this will increase execution time and the size of the output. (The names of these point data arrays are: “Gradient”, “Gradient Magnitude”, and “Classification”.)

  • locator (vtkStaticPointLocator) – can be assigned from a previous call for speed.

See example script:

plot_density3d.py plot_density3d.py

flag(text=None, font='Normografo', size=18, angle=0, shadow=False, c='k', bg='w', justify=0, delay=150)[source]

Add a flag label which becomes visible when hovering the object with mouse. Can be later disabled by setting flag(False).

See also: labels(), vignette(), caption() and legend().

  • text (str, optional) – text string to be rendered. The default is the filename without extension.

  • font (str, optional) – name of font to use. The default is “Courier”.

  • size (int, optional) – size of font. The default is 18. Fonts are: “Arial”, “Courier”, “Times”.

  • angle (float, optional) – rotation angle. The default is 0.

  • shadow (bool, optional) – add a shadow to the font. The default is False.

  • c (str, optional) – color name or index. The default is ‘k’.

  • bg (str, optional) – color name of the background. The default is ‘w’.

  • justify (TYPE, optional) – justification code. The default is 0.

  • delay (float, optional) – pop up delay in milliseconds. The default is 150.

  • flag_labels.py (flag_labels) –


Flip all mesh normals. Same as mesh.mirror(‘n’).


Force the Mesh, Line or point cloud to be treated as opaque


Force the Mesh, Line or point cloud to be treated as translucent


Compute the Hausdorff distance of two point sets.

implicitModeller(distance=0.05, res=(50, 50, 50), bounds=(), maxdist=None)[source]

Find the surface which sits at the specified distance from the input one.

interpolateDataFrom(source, radius=None, N=None, kernel='shepard', exclude=('Normals'), on='points', nullStrategy=1, nullValue=0)[source]

Interpolate over source to port its data onto the current object using various kernels.

If N (number of closest points to use) is set then radius value is ignored.

  • kernel (str) – available kernels are [shepard, gaussian, linear]

  • nullStrategy (int) – specify a strategy to use when encountering a “null” point during the interpolation process. Null points occur when the local neighborhood (of nearby points to interpolate from) is empty. Case 0: an output array is created that marks points as being valid (=1) or null (invalid =0), and the nullValue is set as well Case 1: the output data value(s) are set to the provided nullValue Case 2: simply use the closest point to perform the interpolation.

  • nullValue (float) – see above.

labels(content=None, cells=False, scale=None, rotX=0, rotY=0, rotZ=0, ratio=1, precision=None, italic=False, font='', justify='bottom-left', c='black', alpha=1)[source]

Generate value or ID labels for mesh cells or points. For large nr. of labels use font="VTK" which is much faster.

See also: flag(), vignette(), caption() and legend().

  • content (list,int,str) – either ‘id’, ‘cellid’, array name or array number. A array can also be passed (must match the nr. of points or cells).

  • cells (bool) – generate labels for cells instead of points [False]

  • scale (float) – absolute size of labels, if left as None it is automatic

  • rotZ (float) – local rotation angle of label in degrees

  • ratio (int) – skipping ratio, to reduce nr of labels for large meshes

  • precision (int) – numeric precision of labels

from vedo import *
s = Sphere(res=10).lineWidth(1).c("orange").computeNormals()
point_ids = s.labels('id', cells=False).c('green')
cell_ids  = s.labels('id', cells=True ).c('black')
show(s, point_ids, cell_ids)

meshquality.py meshquality.py


Generate legend text.


txt (str) – legend text.

flag_labels.py flag_labels.py

mirror(axis='x', origin=[0, 0, 0], reset=False)[source]

Mirror the mesh along one of the cartesian axes

  • axis (str) – axis to use for mirroring, must be set to x, y, z or n. Or any combination of those. Adding ‘n’ reverses mesh faces (hence normals).

  • origin (list) – use this point as the origin of the mirroring transformation.

  • reset (bool) – if True keep into account the current position of the object, and then reset its internal transformation matrix to Identity.

mirror.py mirror.py


Return the normal vector at vertex point i.


Scale Mesh average size to unit.

normals(cells=False, compute=True)[source]

Retrieve vertex normals as a numpy array.

Params bool cells

if True return cell normals.

Params bool compute

if True normals are recalculated if not already present. Note that this might modify the number of mesh points.


Occlusion strength in range [0,1].


Set/get mesh’s transparency. Same as mesh.alpha().

pointColors(*args, **kwargs)[source]

Add gaussian noise to point positions.


sigma (float) – sigma is expressed in percent of the diagonal size of mesh. Can be a list [sigma_x, sigma_y, sigma_z].

from vedo import Sphere


Set/get mesh’s point size of vertices. Same as mesh.ps()


Returns the vtkPolyData object of a Mesh.


If transformed=True returns a copy of polydata that corresponds to the current mesh’s position in space.

projectOnPlane(plane='z', point=None, direction=None)[source]

Project the mesh on one of the Cartesian planes.

  • plane (str,Plane) – if plane is str, plane can be one of x-plane, y-plane and z-plane. Otherwise, plane should be an instance of vedo.shapes.Plane.

  • point (array) – camera point of perspective projection

  • direction (array) – direction of oblique projection


Parameters point and direction are only used if the given plane is an instance of vedo.shapes.Plane. And one of these two params should be left as None to specify the projection type.


>>> s.projectOnPlane(plane='z') # project to z-plane
>>> plane = Plane(pos=(4, 8, -4), normal=(-1, 0, 1), sx=5)
>>> s.projectOnPlane(plane=plane)                       # orthogonal projection
>>> s.projectOnPlane(plane=plane, point=(6, 6, 6))      # perspective projection
>>> s.projectOnPlane(plane=plane, direction=(1, 2, -1)) # oblique projection

Set/get mesh’s point size of vertices. Same as mesh.pointSize()


The user should input binSize and all {x,y,z} coordinates will be quantized to that absolute grain size.


from vedo import Paraboloid

Make points look spheric or make them look as squares.

shear(x=0, y=0, z=0)[source]

Apply a shear deformation to the Mesh along one of the main axes.

smoothMLS1D(f=0.2, radius=None)[source]

Smooth mesh or points with a Moving Least Squares variant. The point data array “Variances” will contain the residue calculated for each point. Input mesh’s polydata is modified.

  • f (float) – smoothing factor - typical range is [0,2].

  • radius (float) – radius search in absolute units. If set then f is ignored.

smoothMLS2D(f=0.2, radius=None)[source]

Smooth mesh or points with a Moving Least Squares algorithm variant. The list mesh.info['variances'] contains the residue calculated for each point. When a radius is specified points that are isolated will not be moved and will get a False entry in array mesh.info['isvalid'].

  • f (float) – smoothing factor - typical range is [0,2].

  • radius (float) – radius search in absolute units. If set then f is ignored.

thinPlateSpline(*args, **kwargs)[source]
threshold(scalars, above=None, below=None, on='points')[source]

Extracts cells where scalar value satisfies threshold criterion.

  • scalars (str,list) – name of the scalars array.

  • above (float) – minimum value of the scalar

  • below (float) – maximum value of the scalar

  • on (str) – if ‘cells’ assume array of scalars refers to cell data.

mesh_threshold.py mesh_threshold.py


Return the pymeshlab.Mesh object.


Return the trimesh object.

tomesh(resLine=None, resMesh=None, smooth=0, jitter=0.01, grid=None, quads=False, invert=False, verbose=False)[source]

Generate a polygonal Mesh from a closed contour line. If line is not closed it will be closed with a straight segment.

  • resLine (int, optional) – resolution of the contour line. The default is None, in this case the contour is not resampled.

  • resMesh (int, optional) – resolution of the intenal triangles not touching the boundary. The default is None.

  • smooth (float, optional) – smoothing of the contour before meshing. The default is 0.

  • jitter (float, optional) – add a small noise to the internal points. The default is 0.01.

  • grid (Grid, optional) – manually pass a Grid object. The default is True.

  • quads (bool, optional) – generate a mesh of quads instead of triangles.

  • invert (bool, optional) – flip the line orientation. The default is False.

  • verbose (bool, optional) – printout info during the process. The default is False.

transformWithLandmarks(sourceLandmarks, targetLandmarks, rigid=False)[source]

Trasform mesh orientation and position based on a set of landmarks points. The algorithm finds the best matching of source points to target points in the mean least square sense, in one single step.

vertices(pts=None, transformed=True, copy=False)[source]

Alias for points().

vignette(txt=None, point=None, offset=None, s=None, font='', rounded=True, c=None, alpha=1, lw=2, italic=0)[source]

Generate and return a vignette to describe an object. Returns a Mesh object.

  • txt (str, optional) – Text to display. The default is the filename or the object name.

  • point (list, optional) – position of the vignette pointer. The default is None.

  • offset (list, optional) – text offset wrt the application point. The default is None.

  • s (float, optional) – size of the vignette. The default is None.

  • font (str, optional) – text font. The default is “”.

  • rounded (bool, optional) – draw a rounded or squared box around the text. The default is True.

  • c (list, optional) – text and box color. The default is None.

  • alpha (float, optional) – transparency of text and box. The default is 1.

  • lw (float, optional) – line with of box frame. The default is 2.

  • italic (float, optional) – italicness of text. The default is 0.

intersect2d.py intersect2d.py

goniometer.py goniometer.py

flag_labels.py flag_labels.py

intersect2d.py intersect2d.py

warp(sourcePts, targetPts, sigma=1, mode='3d')[source]

Thin Plate Spline transformations describe a nonlinear warp transform defined by a set of source and target landmarks. Any point on the mesh close to a source landmark will be moved to a place close to the corresponding target landmark. The points in between are interpolated smoothly using Bookstein’s Thin Plate Spline algorithm.

Transformation object can be accessed with mesh.transform.

  • sigma (float) – specify the ‘stiffness’ of the spline.

  • mode (str) – set the basis function to either abs(R) (for 3d) or R2LogR (for 2d meshes)

warpByVectors(vects, factor=1, useCells=False)[source]

Deprecated. Please use mymesh.points(my_new_pts)

warpToPoint(point, factor=0.1, absolute=True)[source]

Modify the mesh coordinates by moving the vertices towards a specified point.

  • factor (float) – value to scale displacement.

  • point (list) – the position to warp towards.

  • absolute (bool) – turning on causes scale factor of the new position to be one unit away from point.

from vedo import *
s = Cylinder(height=3).wireframe()
pt = [4,0,0]
w = s.clone().warpToPoint(pt, factor=0.5).wireframe(False)
show(w,s, Point(pt), axes=1)



vedo.pointcloud.connectedPoints(mesh, radius, mode=0, regions=(), vrange=(0, 1), seeds=(), angle=0)[source]

Extracts and/or segments points from a point cloud based on geometric distance measures (e.g., proximity, normal alignments, etc.) and optional measures such as scalar range. The default operation is to segment the points into “connected” regions where the connection is determined by an appropriate distance measure. Each region is given a region id.

Optionally, the filter can output the largest connected region of points; a particular region (via id specification); those regions that are seeded using a list of input point ids; or the region of points closest to a specified position.

The key parameter of this filter is the radius defining a sphere around each point which defines a local neighborhood: any other points in the local neighborhood are assumed connected to the point. Note that the radius is defined in absolute terms.

Other parameters are used to further qualify what it means to be a neighboring point. For example, scalar range and/or point normals can be used to further constrain the neighborhood. Also the extraction mode defines how the filter operates. By default, all regions are extracted but it is possible to extract particular regions; the region closest to a seed point; seeded regions; or the largest region found while processing. By default, all regions are extracted.

On output, all points are labeled with a region number. However note that the number of input and output points may not be the same: if not extracting all regions then the output size may be less than the input size.

  • radius (float) – radius variable specifying a local sphere used to define local point neighborhood

  • mode (int) –

    • 0, Extract all regions

    • 1, Extract point seeded regions

    • 2, Extract largest region

    • 3, Test specified regions

    • 4, Extract all regions with scalar connectivity

    • 5, Extract point seeded regions

  • regions (list) – a list of non-negative regions id to extract

  • vrange (list) – scalar range to use to extract points based on scalar connectivity

  • seeds (list) – a list of non-negative point seed ids

  • angle (list) – points are connected if the angle between their normals is within this angle threshold (expressed in degrees).


vedo.pointcloud.delaunay2D(plist, mode='scipy', boundaries=(), tol=None, alpha=0, offset=0, transform=None)[source]

Create a mesh from points in the XY plane. If mode=’fit’ then the filter computes a best fitting plane and projects the points onto it. If mode=’fit’ then the xy plane is assumed.

When mode==’fit’ or ‘xy’

  • tol (float) – specify a tolerance to control discarding of closely spaced points. This tolerance is specified as a fraction of the diagonal length of the bounding box of the points.

  • alpha (float) – for a non-zero alpha value, only edges or triangles contained within a sphere centered at mesh vertices will be output. Otherwise, only triangles will be output.

  • offset (float) – multiplier to control the size of the initial, bounding Delaunay triangulation.

  • transform – a vtk transformation (eg. a thinplate spline) which is applied to points to generate a 2D problem. This maps a 3D dataset into a 2D dataset where triangulation can be done on the XY plane. The points are transformed and triangulated. The topology of triangulated points is used as the output topology.

delaunay2d.py delaunay2d.py



Fits a circle through a set of 3D points, with a very fast non-iterative method.

Returns the center, radius, normal_to_circle.

Reference: J.F. Crawford, Nucl. Instr. Meth. 211, 1983, 223-225.



Fits a line through points.

Extra info is stored in Line.slope, Line.center, Line.variances.

fitline.py fitline.py


vedo.pointcloud.fitPlane(points, signed=False)[source]

Fits a plane to a set of points.

Extra info is stored in Plane.normal, Plane.center, Plane.variance.


signed (bool) – if True flip sign of the normal based on the ordering of the points


Example: fitplanes.py



Fits a sphere to a set of points.

Extra info is stored in Sphere.radius, Sphere.center, Sphere.residue.


vedo.pointcloud.pcaEllipsoid(points, pvalue=0.95)[source]

Show the oriented PCA ellipsoid that contains fraction pvalue of points.


pvalue (float) – ellypsoid will contain the specified fraction of points.

Extra can be calculated with mesh.asphericity(), mesh.asphericity_error() (asphericity is equal to 0 for a perfect sphere).

Axes can be accessed in mesh.va, mesh.vb, mesh.vc. End point of the axes are stored in mesh.axis1, mesh.axis12 and mesh.axis3.


Examples: pca.py cell_colony.py

pca.py cell_colony.py


vedo.pointcloud.pointCloudFrom(obj, interpolateCellData=False)[source]

Build a Mesh object (as a point cloud) from any VTK dataset.


interpolateCellData (bool) – if True cell data is interpolated at point positions.


vedo.pointcloud.recoSurface(pts, dims=(100, 100, 100), radius=None, sampleSize=None, holeFilling=True, bounds=(), pad=0.1)[source]

Surface reconstruction from a scattered cloud of points.

  • dims (int) – number of voxels in x, y and z to control precision.

  • radius (float) – radius of influence of each point. Smaller values generally improve performance markedly. Note that after the signed distance function is computed, any voxel taking on the value >= radius is presumed to be “unseen” or uninitialized.

  • sampleSize (int) – if normals are not present they will be calculated using this sample size per point.

  • holeFilling (bool) – enables hole filling, this generates separating surfaces between the empty and unseen portions of the volume.

  • bounds (list) – region in space in which to perform the sampling in format (xmin,xmax, ymin,ymax, zim, zmax)

  • pad (float) – increase by this fraction the bounding box

recosurface.py recosurface.py


vedo.pointcloud.removeOutliers(points, radius, neighbors=5)[source]

Remove outliers from a cloud of points within the specified radius search.

clustering.py clustering.py


vedo.pointcloud.smoothMLS3D(meshs, neighbours=10)[source]

A time sequence of point clouds (Mesh) is being smoothed in 4D (3D + time) using a MLS (Moving Least Squares) algorithm variant. The time associated to an mesh must be specified in advance with mesh.time() method. Data itself can suggest a meaningful time separation based on the spatial distribution of points.


neighbours (int) – fixed nr. of neighbours in space-time to take into account in the fit.

moving_least_squares3D.py moving_least_squares3D.py


vedo.pointcloud.visiblePoints(mesh, area=(), tol=None, invert=False)[source]

Extract points based on whether they are visible or not. Visibility is determined by accessing the z-buffer of a rendering window. The position of each input point is converted into display coordinates, and then the z-value at that point is obtained. If within the user-specified tolerance, the point is considered visible. Associated data attributes are passed to the output as well.

This filter also allows you to specify a rectangular window in display (pixel) coordinates in which the visible points must lie.

  • area (list) – specify a rectangular region as (xmin,xmax,ymin,ymax)

  • tol (float) – a tolerance in normalized display coordinate system

  • invert (bool) – select invisible points instead.

from vedo import Ellipsoid, show, visiblePoints

s = Ellipsoid().rotateY(30)

#Camera options: pos, focalPoint, viewup, distance,
# clippingRange, parallelScale, thickness, viewAngle
camopts = dict(pos=(0,0,25), focalPoint=(0,0,0))
show(s, camera=camopts, offscreen=True)

m = visiblePoints(s)
#print('visible pts:', m.points()) # numpy array
show(m, new=True, axes=1) # optionally draw result on a new window


vedo.pointcloud.voronoi(pts, pad=0, fit=False)[source]

Generate the 2D Voronoi convex tiling of the input points (z is ignored). The points are assumed to lie in a plane. The output is a Mesh. Each output cell is a convex polygon.

The 2D Voronoi tessellation is a tiling of space, where each Voronoi tile represents the region nearest to one of the input points. Voronoi tessellations are important in computational geometry (and many other fields), and are the dual of Delaunay triangulations.

Thus the triangulation is constructed in the x-y plane, and the z coordinate is ignored (although carried through to the output). If you desire to triangulate in a different plane, you can use fit=True.

A brief summary is as follows. Each (generating) input point is associated with an initial Voronoi tile, which is simply the bounding box of the point set. A locator is then used to identify nearby points: each neighbor in turn generates a clipping line positioned halfway between the generating point and the neighboring point, and orthogonal to the line connecting them. Clips are readily performed by evaluationg the vertices of the convex Voronoi tile as being on either side (inside,outside) of the clip line. If two intersections of the Voronoi tile are found, the portion of the tile “outside” the clip line is discarded, resulting in a new convex, Voronoi tile. As each clip occurs, the Voronoi “Flower” error metric (the union of error spheres) is compared to the extent of the region containing the neighboring clip points. The clip region (along with the points contained in it) is grown by careful expansion (e.g., outward spiraling iterator over all candidate clip points). When the Voronoi Flower is contained within the clip region, the algorithm terminates and the Voronoi tile is output. Once complete, it is possible to construct the Delaunay triangulation from the Voronoi tessellation. Note that topological and geometric information is used to generate a valid triangulation (e.g., merging points and validating topology).

  • pts (list) – list of input points.

  • pad (float, optional) – padding distance. The default is 0.

  • fit (bool, optional) – detect automatically the best fitting plane. The default is False.