shapes¶
Submodule to generate basic geometric shapes.
Arc¶

class
vedo.shapes.
Arc
(center, point1, point2=None, normal=None, angle=None, invert=False, c='grey', alpha=1, res=48)[source]¶ Bases:
vedo.mesh.Mesh
Build a 2D circular arc between points point1 and point2. If normal is specified then center is ignored, and normal vector, a starting point1 (polar vector) and an angle defining the arc length need to be assigned.
Arc spans the shortest angular sector point1 and point2, if invert=True, then the opposite happens.
Arrow¶

class
vedo.shapes.
Arrow
(startPoint, endPoint, s=None, c='r', alpha=1, res=12)[source]¶ Bases:
vedo.mesh.Mesh
Build a 3D arrow from startPoint to endPoint of section size s, expressed as the fraction of the window size.
Note
If
s=None
the arrow is scaled proportionally to its length
Arrow2D¶

class
vedo.shapes.
Arrow2D
(startPoint, endPoint, shaftLength=0.8, shaftWidth=0.05, headLength=0.25, headWidth=0.2, fill=True, c='r', alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
Build a 2D arrow from startPoint to endPoint.
Arrows¶

vedo.shapes.
Arrows
(startPoints, endPoints=None, s=None, scale=1, c=None, alpha=1, res=12)[source]¶ Build arrows between two lists of points startPoints and endPoints. startPoints can be also passed in the form
[[point1, point2], ...]
.Color can be specified as a colormap which maps the size of the arrows.
 Parameters
Arrows2D¶

vedo.shapes.
Arrows2D
(startPoints, endPoints=None, shaftLength=0.8, shaftWidth=0.09, headLength=None, headWidth=0.2, fill=True, scale=1, c=None, cmap=None, alpha=1)[source]¶ Build 2D arrows between two lists of points startPoints and endPoints. startPoints can be also passed in the form
[[point1, point2], ...]
.Color can be specified as a colormap which maps the size of the arrows.
 Parameters
shaftLength (float) – fractional shaft length
shaftWidth (float) – fractional shaft width
headLength (float) – fractional head length
headWidth (float) – fractional head width
fill (bool) – if False only generate the outline
scale (float) – apply a rescaling factor to the length
c – color
alpha (float) – set transparency
 Example
from vedo import Grid, Arrows2D g1 = Grid(sx=1, sy=1) g2 = Grid(sx=1.2, sy=1.2).rotateZ(4) arrs2d = Arrows2D(g1, g2, c='jet') arrs2d.show(axes=1, bg='white')
Bezier¶
Box¶

class
vedo.shapes.
Box
(pos=0, 0, 0, length=1, width=2, height=3, size=(), c='g', alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
Build a box of dimensions x=length, y=width and z=height. Alternatively dimensions can be defined by setting size keyword with a tuple.
Brace¶

vedo.shapes.
Brace
(q1, q2, style='}', pad=0.2, thickness=1, font='Kanopus', comment='', s=1, c='black', alpha=1)[source]¶ Create a brace (bracket) shape which spans from point q1 to point q2.
 Parameters
q1 (list) – point 1.
q2 (list) – point 2.
style (str, optional) – style of the bracket, eg. {}, [], (), <>. The default is ‘{‘.
pad (float, optional) – padding space in percent. The default is 0.2.
thickness (float, optional) – thickness factor for the bracket. The default is 1.
font (str, optional) – font type. The default is ‘Kanopus’.
comment (str, optional) – additional text to appear next to the bracket. The default is ‘’.
s (float, optional) – scale factor for the comment
scatter3.py (scatter3) –
CSpline¶

class
vedo.shapes.
CSpline
(points, closed=False, res=None)[source]¶ Bases:
vedo.shapes.Line
Return a Cardinal spline which runs exactly through all the input points.
 Parameters
See also:
Spline
andKSpline
.
Circle¶

class
vedo.shapes.
Circle
(pos=0, 0, 0, r=1, c='grey', alpha=1, res=120)[source]¶ Bases:
vedo.shapes.Polygon
Build a Circle of radius r.
Cone¶

class
vedo.shapes.
Cone
(pos=0, 0, 0, r=1, height=3, axis=0, 0, 1, c='dg', alpha=1, res=48)[source]¶ Bases:
vedo.mesh.Mesh
Build a cone of specified radius r and height, centered at pos.
ConvexHull¶
Cross3D¶
CubicGrid¶
Cylinder¶

class
vedo.shapes.
Cylinder
(pos=0, 0, 0, r=1, height=2, axis=0, 0, 1, c='teal', alpha=1, cap=True, res=24)[source]¶ Bases:
vedo.mesh.Mesh
Build a cylinder of specified height and radius r, centered at pos.
If pos is a list of 2 Points, e.g. pos=[v1,v2], build a cylinder with base centered at v1 and top at v2.
DashedLine¶

class
vedo.shapes.
DashedLine
(p0, p1=None, spacing=0.1, closed=False, c='grey', alpha=1, lw=2)[source]¶ Bases:
vedo.shapes.Line
Build a dashed line segment between points p0 and p1. If p0 is a list of points returns the line connecting them. A 2D set of coords can also be passed as p0=[x..], p1=[y..].
Disc¶

class
vedo.shapes.
Disc
(pos=0, 0, 0, r1=0.5, r2=1, c='coral', alpha=1, res=12)[source]¶ Bases:
vedo.mesh.Mesh
Build a 2D disc of inner radius r1 and outer radius r2.
 Parameters
res (list) – resolution in R and Phi
Earth¶

class
vedo.shapes.
Earth
(style=1, r=1)[source]¶ Bases:
vedo.mesh.Mesh
Build a textured mesh representing the Earth.
Ellipsoid¶

class
vedo.shapes.
Ellipsoid
(pos=0, 0, 0, axis1=1, 0, 0, axis2=0, 2, 0, axis3=0, 0, 3, c='c', alpha=1, res=24)[source]¶ Bases:
vedo.mesh.Mesh
Build a 3D ellipsoid centered at position pos.
Note
axis1 and axis2 are only used to define sizes and one azimuth angle.
FlatArrow¶
Glyph¶

class
vedo.shapes.
Glyph
(mesh, glyphObj, orientationArray=None, scaleByScalar=False, scaleByVectorSize=False, scaleByVectorComponents=False, colorByScalar=False, colorByVectorSize=False, tol=0, c='white', alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
At each vertex of a mesh, another mesh  a ‘glyph’  is shown with various orientation options and coloring. The input
mesh
can also be a simple list of 2D or 3D coordinates. Color can be specified as a colormap which maps the size of the orientation vectors in orientationArray. Parameters
orientationArray (list, str, vtkAbstractArray) – list of vectors,
vtkAbstractArray
or the name of an already existing points array.scaleByScalar (bool) – glyph mesh is scaled by the active scalars.
scaleByVectorSize (bool) – glyph mesh is scaled by the size of the vectors.
scaleByVectorComponents (bool) – glyph mesh is scaled by the 3 vectors components.
colorByScalar (bool) – glyph mesh is colored based on the scalar value.
colorByVectorSize (bool) – glyph mesh is colored based on the vector size.
tol (float) – set a minimum separation between two close glyphs (not compatible with orientationArray being a list).
Grid¶

class
vedo.shapes.
Grid
(pos=0, 0, 0, normal=0, 0, 1, sx=1, sy=1, sz=0, c='gray', alpha=1, lw=1, resx=10, resy=10)[source]¶ Bases:
vedo.mesh.Mesh
Return an even or uneven 2D grid at z=0.
 Parameters
sx (float,list) – if a float is provided it is interpreted as the total size along x, if a list of coords is provided they are interpreted as the vertices of the grid along x. In this case keyword resx is ignored (see example below).
lw (float) – line width.
resx (int) – resolution along x, e.i. the number of axis subdivisions.
 Example
from vedo import * xcoords = arange(0, 2, 0.2) ycoords = arange(0, 1, 0.2) sqrtx = sqrt(xcoords) grid = Grid(sx=sqrtx, sy=ycoords) grid.show(axes=8)
Hyperboloid¶

class
vedo.shapes.
Hyperboloid
(pos=0, 0, 0, a2=1, value=0.5, height=1, c='m', alpha=1, res=100)[source]¶ Bases:
vedo.mesh.Mesh
Build a hyperboloid of specified aperture a2 and height, centered at pos.
 Full volumetric expression is:
\(F(x,y,z)=a_0x^2+a_1y^2+a_2z^2+a_3xy+a_4yz+a_5xz+ a_6x+a_7y+a_8z+a_9\)
KSpline¶

class
vedo.shapes.
KSpline
(points, continuity=0, tension=0, bias=0, closed=False, res=None)[source]¶ Bases:
vedo.shapes.Line
Return a Kochanek spline which runs exactly through all the input points.
See: https://en.wikipedia.org/wiki/Kochanek%E2%80%93Bartels_spline
 Parameters
continuity (float) – changes the sharpness in change between tangents
tension (float) – changes the length of the tangent vector
bias (float) – changes the direction of the tangent vector
closed (bool) – join last to first point to produce a closed curve
res (int) – approximate resolution of the output line. Default is 20 times the number of input points.
See also:
Spline
andCSpline
.
Latex¶

class
vedo.shapes.
Latex
(formula, pos=0, 0, 0, c='k', s=1, bg=None, alpha=1, res=30, usetex=False, fromweb=False)[source]¶ Bases:
vedo.picture.Picture
Render Latex formulas.
 Parameters
You can access the latex formula in Latex.formula’.
Line¶

class
vedo.shapes.
Line
(p0, p1=None, closed=False, c='grey', alpha=1, lw=1, res=2)[source]¶ Bases:
vedo.mesh.Mesh
Build the line segment between points p0 and p1. If p0 is a list of points returns the line connecting them. A 2D set of coords can also be passed as p0=[x..], p1=[y..].
 Parameters

eval
(x)[source]¶ Calculate the position of an intermediate point as a fraction of the length of the line, being x=0 the first point and x=1 the last point. This corresponds to an imaginary point that travels along the line at constant speed.
Can be used in conjunction with linInterpolate() to map any range to the [0,1] range.

sweep
(direction=1, 0, 0, res=1)[source]¶ Sweep the Line along the specified vector direction.
Returns a Mesh surface. Line position is updated to allow for additional sweepings.
 Example
from vedo import Line, show aline = Line([(0,0,0),(1,3,0),(2,4,0)]) surf1 = aline.sweep((1,0.2,0), res=3) surf2 = aline.sweep((0.2,0,1)) aline.color('r').lineWidth(4) show(surf1, surf2, aline, axes=1)
Lines¶

class
vedo.shapes.
Lines
(startPoints, endPoints=None, c='gray', alpha=1, lw=1, dotted=False, scale=1)[source]¶ Bases:
vedo.shapes.Line
Build the line segments between two lists of points startPoints and endPoints. startPoints can be also passed in the form
[[point1, point2], ...]
. Parameters
scale (float) – apply a rescaling factor to the lengths.
Hint
Marker¶
NormalLines¶
Paraboloid¶

class
vedo.shapes.
Paraboloid
(pos=0, 0, 0, r=1, height=1, c='cyan', alpha=1, res=50)[source]¶ Bases:
vedo.mesh.Mesh
Build a paraboloid of specified height and radius r, centered at pos.
ParametricShape¶

class
vedo.shapes.
ParametricShape
(name, c='powderblue', alpha=1, res=51)[source]¶ Bases:
vedo.mesh.Mesh
A set of builtin shapes mainly for illustration purposes.
Name can be an integer or a string in this list:
[‘Boy’, ‘ConicSpiral’, ‘CrossCap’, ‘Dini’, ‘Enneper’, ‘Figure8Klein’, ‘Klein’, ‘Mobius’, ‘RandomHills’, ‘Roman’, ‘SuperEllipsoid’, ‘BohemianDome’, ‘Bour’, ‘CatalanMinimal’, ‘Henneberg’, ‘Kuen’, ‘PluckerConoid’, ‘Pseudosphere’].
Plane¶

class
vedo.shapes.
Plane
(pos=0, 0, 0, normal=0, 0, 1, sx=1, sy=None, c='g', alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
Draw a plane of size sx and sy oriented perpendicular to vector normal and so that it passes through point pos.
Polygon¶

class
vedo.shapes.
Polygon
(pos=0, 0, 0, nsides=6, r=1, c='coral', alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
Build a polygon in the xy plane of nsides of radius r.
Pyramid¶

class
vedo.shapes.
Pyramid
(pos=0, 0, 0, s=1, height=1, axis=0, 0, 1, c='dg', alpha=1)[source]¶ Bases:
vedo.shapes.Cone
Build a pyramid of specified base size s and height, centered at pos.
Rectangle¶
Ribbon¶

class
vedo.shapes.
Ribbon
(line1, line2=None, mode=0, closed=False, width=None, c='m', alpha=1, res=200, 5)[source]¶ Bases:
vedo.mesh.Mesh
Connect two lines to generate the surface inbetween. Set the mode by which to create the ruled surface.
It also works with a single line in input. In this case the ribbon is formed by following the local plane of the line in space.
 Parameters
mode (int) – If mode=0, resample evenly the input lines (based on length) and generates triangle strips. If mode=1, use the existing points and walks around the polyline using existing points.
closed (bool) – if True, join the last point with the first to form a closed surface
res (list) – ribbon resolutions along the line and perpendicularly to it.
RoundedLine¶

vedo.shapes.
RoundedLine
(pts, lw, c='grey', alpha=1, res=10)[source]¶ Create a 2D line of specified thickness (in absolute units) passing through a list of input points. Borders of the line are rounded.
 Parameters
Example
from vedo import * pts = [(4,3),(1,1),(2,4),(4,1),(3,1),(2,5),(9,3)] ln = Line(pts, c='r', lw=2).z(0.01) rl = RoundedLine(pts, 0.6) show(Points(pts), ln, rl, axes=1)
Sphere¶

class
vedo.shapes.
Sphere
(pos=0, 0, 0, r=1, c='r', alpha=1, res=24, quads=False)[source]¶ Bases:
vedo.mesh.Mesh
Build a sphere at position pos of radius r.
 Parameters
Spheres¶

class
vedo.shapes.
Spheres
(centers, r=1, c='r', alpha=1, res=8)[source]¶ Bases:
vedo.mesh.Mesh
Build a (possibly large) set of spheres at centers of radius r.
Either c or r can be a list of RGB colors or radii.
Spline¶

class
vedo.shapes.
Spline
(points, smooth=0, degree=2, closed=False, s=2, res=None, easing='')[source]¶ Bases:
vedo.shapes.Line
Find the BSpline curve through a set of points. This curve does not necessarly pass exactly through all the input points. Needs to import scypi.
Return an
Mesh
object. Parameters
smooth (float) –
smoothing factor.
0 = interpolate points exactly [default].
1 = average point positions.
degree (int) – degree of the spline (1<degree<5)
easing (str) –
control sensity of points along the spline.
Available options are [InSine, OutSine, Sine, InQuad, OutQuad, InCubic, OutCubic, InQuart, OutQuart, InCirc, OutCirc]. Can be used to create animations (move objects at varying speed). See e.g.: https://easings.net
res (int) – number of points on the spline
See also:
CSpline
andKSpline
.
Spring¶

class
vedo.shapes.
Spring
(startPoint=0, 0, 0, endPoint=1, 0, 0, coils=20, r=0.1, r2=None, thickness=None, c='grey', alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
Build a spring of specified nr of coils between startPoint and endPoint.
 Parameters
Star¶

class
vedo.shapes.
Star
(pos=0, 0, 0, n=5, r1=0.7, r2=1.0, line=False, c='m', alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
Build a 2D star shape of n cusps of inner radius r1 and outer radius r2.
 Parameters
line (bool) – only build the outer line (no internal surface meshing).
Star3D¶

class
vedo.shapes.
Star3D
(pos=0, 0, 0, r=1.0, thickness=0.1, c='b', alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
Build a 3D star shape of 5 cusps, mainly useful as a 3D marker.
Tensors¶

class
vedo.shapes.
Tensors
(domain, source='ellipsoid', useEigenValues=True, isSymmetric=True, threeAxes=False, scale=1, maxScale=None, length=None, c=None, alpha=1)[source]¶ Bases:
vedo.mesh.Mesh
Geometric representation of tensors defined on a domain or set of points. Tensors can be scaled and/or rotated according to the source at eache input point. Scaling and rotation is controlled by the eigenvalues/eigenvectors of the symmetrical part of the tensor as follows:
For each tensor, the eigenvalues (and associated eigenvectors) are sorted to determine the major, medium, and minor eigenvalues/eigenvectors. The eigenvalue decomposition only makes sense for symmetric tensors, hence the need to only consider the symmetric part of the tensor, which is 1/2*(T+T.transposed()).
 Parameters
source (str) – preset type of source shape [‘ellipsoid’, ‘cylinder’, ‘cube’ or any specified
Mesh
]useEigenValues (bool) – color source glyph using the eigenvalues or by scalars.
threeAxes (bool) –
if False scale the source in the xdirection, the medium in the ydirection, and the minor in the zdirection. Then, the source is rotated so that the glyph’s local xaxis lies along the major eigenvector, yaxis along the medium eigenvector, and zaxis along the minor.
If True three sources are produced, each of them oriented along an eigenvector and scaled according to the corresponding eigenvector.
isSymmetric (bool) – If True each source glyph is mirrored (2 or 6 glyphs will be produced). The xaxis of the source glyph will correspond to the eigenvector on output.
length (float) – distance from the origin to the tip of the source glyph along the xaxis
scale (float) – scaling factor of the source glyph.
maxScale (float) – clamp scaling at this factor.
Text¶

class
vedo.shapes.
Text
(txt, pos=0, 0, 0, s=1, font='', hspacing=1.15, vspacing=2.15, depth=0, italic=False, justify='bottomleft', c=None, alpha=1, literal=False)[source]¶ Bases:
vedo.mesh.Mesh
Generate a 3D polygonal
Mesh
representing a text string.Can render strings like 3.7 10^9 or H_2 O with subscripts and superscripts. Most Latex symbols are also supported (e.g. mu_lambda). Symbols ~ ^ _ are reserved modifiers:
use ~ to add a short space, 1/4 of the default empty space, use ^ and _ to start up/sub scripting, a space terminates their effect.
 Parameters
pos (list) – position coordinates in 3D space
s (float) – size of text.
depth (float) – text thickness.
italic (bool,float) – italic font type (can be a signed float too).
justify (str) – text justification as centering of the bounding box (bottomleft, bottomright, topleft, topright, centered).
font (str) – available 3Dpolygonized fonts are Bongas, Calco, Comae, Kanopus, Glasgo, LionelOfParis, LogoType, Normografo, Quikhand, SmartCouric, Theemim, VictorMono, VTK. Default is Normografo, which can be changed using
settings.defaultFont
hspacing (float) – horizontal spacing of the font.
vspacing (float) – vertical spacing of the font for multiple lines text.
literal (bool) – if set to True will ignore modifiers like _ or ^
Text2D¶

vedo.shapes.
Text2D
(txt, pos=3, s=1, c=None, alpha=0.15, bg=None, font='', justify='bottomleft', bold=False, italic=False)[source]¶ Returns a
vtkActor2D
representing 2D text. Parameters
text is placed in one of the 8 positions:
1, bottomleft 2, bottomright 3, topleft 4, topright 5, bottommiddle 6, middleright 7, middleleft 8, topmiddle
If a pair (x,y) is passed as input the 2D text is place at that position in the coordinate system of the 2D screen (with the origin sitting at the bottom left).
s (float) – size of text.
bg – background color
alpha (float) – background opacity
justify (str) – text justification
font (str) –
predefined available fonts are
Arial
Bongas
Calco
Comae
Courier
Glasgo
Kanopus
LionelOfParis
LogoType
Normografo
Quikhand
SmartCouric
Theemim
Times
VictorMono
A path to a .otf or .ttf fontfile can also be supplied as input.
Torus¶

class
vedo.shapes.
Torus
(pos=0, 0, 0, r=1, thickness=0.2, c='khaki', alpha=1, res=30)[source]¶ Bases:
vedo.mesh.Mesh
Build a torus of specified outer radius r internal radius thickness, centered at pos.
Tube¶

class
vedo.shapes.
Tube
(points, r=1, cap=True, c=None, alpha=1, res=12)[source]¶ Bases:
vedo.mesh.Mesh
Build a tube along the line defined by a set of points.
 Parameters
 Para int res
resolution, number of sides of the tube