shapes¶

Submodule to generate basic geometric shapes.

Arc¶

vtkplotter.shapes.Arc(center, point1, point2=None, normal=None, angle=None, invert=False, c='grey', alpha=1, res=48)[source]

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¶

vtkplotter.shapes.Arrow(startPoint, endPoint, s=None, c='r', alpha=1, res=12)[source]

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, otherwise it represents the fraction of the window size.

Arrows¶

vtkplotter.shapes.Arrows(startPoints, endPoints=None, s=None, scale=1, c='r', 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 specfied as a colormap which maps the size of the arrows.

Parameters: s (float) – fix aspect-ratio of the arrow and scale its cross section scale (float) – apply a rescaling factor to the length c – color or array of colors cmap (str) – color arrows by size using this color map alpha (float) – set transparency res (int) – set arrow resolution

Box¶

vtkplotter.shapes.Box(pos=(0, 0, 0), length=1, width=2, height=3, size=(), c='g', alpha=1)[source]

Build a box of dimensions x=length, y=width and z=height. Alternatively dimensions can be defined by setting size keyword with a tuple.

Circle¶

vtkplotter.shapes.Circle(pos=(0, 0, 0), r=1, fill=False, c='grey', alpha=1, res=120)[source]

Build a circle of radius r.

Cone¶

vtkplotter.shapes.Cone(pos=(0, 0, 0), r=1, height=3, axis=(0, 0, 1), c='dg', alpha=1, res=48)[source]

Build a cone of specified radius r and height, centered at pos.

Cube¶

vtkplotter.shapes.Cube(pos=(0, 0, 0), side=1, c='g', alpha=1)[source]

Build a cube of size side.

Cylinder¶

vtkplotter.shapes.Cylinder(pos=(0, 0, 0), r=1, height=2, axis=(0, 0, 1), c='teal', alpha=1, res=24)[source]

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¶

vtkplotter.shapes.DashedLine(p0, p1=None, spacing=None, c='red', alpha=1, lw=1)[source]

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..].

Parameters: spacing (float) – physical size of the dash. c (int, str, list) – color name, number, or list of [R,G,B] colors. alpha (float) – transparency in range [0,1]. lw – line width.

Disc¶

vtkplotter.shapes.Disc(pos=(0, 0, 0), r1=0.5, r2=1, c='coral', alpha=1, res=12, resphi=None)[source]

Build a 2D disc of inner radius r1 and outer radius r2.

Earth¶

vtkplotter.shapes.Earth(pos=(0, 0, 0), r=1, lw=0)[source]

Build a textured actor representing the Earth.

Ellipsoid¶

vtkplotter.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]

Build a 3D ellipsoid centered at position pos.

Note

axis1 and axis2 are only used to define sizes and one azimuth angle.

FlatArrow¶

vtkplotter.shapes.FlatArrow(line1, line2, c='m', alpha=1, tipSize=1, tipWidth=1)[source]

Build a 2D arrow in 3D space by joining two close lines.

Glyph¶

vtkplotter.shapes.Glyph(actor, glyphObj, orientationArray=None, scaleByVectorSize=False, tol=0, c=None, alpha=1)[source]

At each vertex of a mesh, another mesh - a ‘glyph’ - is shown with various orientation options and coloring.

Color can be specfied 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. scaleByVectorSize (bool) – glyph mesh is scaled by the size of the vectors. tol (float) – set a minimum separation between two close glyphs (not compatible with orientationArray being a list).

Grid¶

vtkplotter.shapes.Grid(pos=(0, 0, 0), normal=(0, 0, 1), sx=1, sy=1, c='g', alpha=1, lw=1, resx=10, resy=10)[source]

Return a grid plane.

Hyperboloid¶

vtkplotter.shapes.Hyperboloid(pos=(0, 0, 0), a2=1, value=0.5, height=1, c='m', alpha=1, res=100)[source]

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¶

vtkplotter.shapes.KSpline(points, continuity=0, tension=0, bias=0, closed=False, res=None)[source]

Return a Kochanek-Bartel spline which runs exactly throught all the input points.

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) – resolution of the output line. Default is 20 times the number of input points.

Latex¶

vtkplotter.shapes.Latex(formula, pos=(0, 0, 0), c='k', s=1, bg=None, alpha=1, res=30, usetex=False, fromweb=False)[source]

Render Latex formulas.

Parameters: formula (str) – latex text string pos (list) – position coordinates in space c – face color bg – background color box res (int) – dpi resolution usetex (bool) – use latex compiler of matplotlib fromweb – retrieve the latex image from online server (codecogs)

You can access the latex formula from the Actor object with actor.info[‘formula’].

Line¶

vtkplotter.shapes.Line(p0, p1=None, c='r', alpha=1, lw=1, dotted=False, res=None)[source]

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: c (int, str, list) – color name, number, or list of [R,G,B] colors. alpha (float) – transparency in range [0,1]. lw – line width. dotted (bool) – draw a dotted line res (int) – number of intermediate points in the segment

Lines¶

vtkplotter.shapes.Lines(startPoints, endPoints=None, c='gray', alpha=1, lw=1, dotted=False, scale=1)[source]

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.

Marker¶

vtkplotter.shapes.Marker(symbol, c='lb', alpha=1, s=0.1, filled=True)[source]

Generate a marker shape. Can be used in association with Glyph.

Paraboloid¶

vtkplotter.shapes.Paraboloid(pos=(0, 0, 0), r=1, height=1, c='cyan', alpha=1, res=50)[source]

Build a paraboloid of specified height and radius r, centered at pos.

Note

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$$

ParametricShape¶

vtkplotter.shapes.ParametricShape(name, c='powderblue', alpha=1, res=51)[source]

A set of built-in shapes 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’].
Example: from vtkplotter import * for i in range(18): ps = ParametricShape(i, c=i) show([ps, Text(ps.name)], at=i, N=18) interactive() 

Plane¶

vtkplotter.shapes.Plane(pos=(0, 0, 0), normal=(0, 0, 1), sx=1, sy=None, c='g', alpha=1)[source]

Draw a plane of size sx and sy oriented perpendicular to vector normal and so that it passes through point pos.

Point¶

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

Create a simple point actor.

Points¶

vtkplotter.shapes.Points(plist, r=5, c='gold', alpha=1)[source]

Build a point Actor 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.

Parameters: 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].

Polygon¶

vtkplotter.shapes.Polygon(pos=(0, 0, 0), nsides=6, r=1, c='coral', alpha=1)[source]

Build a 2D polygon of nsides of radius r.

Pyramid¶

vtkplotter.shapes.Pyramid(pos=(0, 0, 0), s=1, height=1, axis=(0, 0, 1), c='dg', alpha=1)[source]

Build a pyramid of specified base size s and height, centered at pos.

Rectangle¶

vtkplotter.shapes.Rectangle(p1=(0, 0, 0), p2=(2, 1, 0), lw=1, c='g', alpha=1)[source]

Build a rectangle in the xy plane identified by two corner points.

Ribbon¶

vtkplotter.shapes.Ribbon(line1, line2, c='m', alpha=1, res=(200, 5))[source]

Connect two lines to generate the surface inbetween.

Sphere¶

vtkplotter.shapes.Sphere(pos=(0, 0, 0), r=1, c='r', alpha=1, res=24)[source]

Build a sphere at position pos of radius r.

Spheres¶

vtkplotter.shapes.Spheres(centers, r=1, c='r', alpha=1, res=8)[source]

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¶

vtkplotter.shapes.Spline(points, smooth=0.5, degree=2, s=2, res=None)[source]

Return an Actor for a spline which does not necessarly passing exactly throught all the input points. Needs to import scypi.

Parameters: smooth (float) – smoothing factor. 0 = interpolate points exactly. 1 = average point positions. degree (int) – degree of the spline (1

Spring¶

vtkplotter.shapes.Spring(startPoint=(0, 0, 0), endPoint=(1, 0, 0), coils=20, r=0.1, r2=None, thickness=None, c='grey', alpha=1)[source]

Build a spring of specified nr of coils between startPoint and endPoint.

Parameters: coils (int) – number of coils r (float) – radius at start point r2 (float) – radius at end point thickness (float) – thickness of the coil section

Star¶

vtkplotter.shapes.Star(pos=(0, 0, 0), n=5, r1=0.7, r2=1.0, line=False, c='lb', alpha=1)[source]

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).

Tensors¶

vtkplotter.shapes.Tensors(domain, source='ellipsoid', useEigenValues=True, isSymmetric=True, threeAxes=False, scale=1, maxScale=None, length=None, c=None, alpha=1)[source]

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 Actor] useEigenValues (bool) – color source glyph using the eigenvalues or by scalars. threeAxes (bool) – if False scale the source in the x-direction, the medium in the y-direction, and the minor in the z-direction. Then, the source is rotated so that the glyph’s local x-axis lies along the major eigenvector, y-axis along the medium eigenvector, and z-axis 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 x-axis 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 x-axis scale (float) – scaling factor of the source glyph. maxScale (float) – clamp scaling at this factor.

Text¶

vtkplotter.shapes.Text(txt, pos='top-left', s=1, depth=0.1, justify='bottom-left', c=None, alpha=1, bc=None, bg=None, font='courier')[source]

Returns an Actor that shows a 2D/3D text.

Parameters: pos (list, int) – position in 3D space, a 2D text is placed in one of the 8 positions: 1, bottom-left 2, bottom-right 3, top-left 4, top-right 5, bottom-middle 6, middle-right 7, middle-left 8, top-middle 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. depth (float) – text thickness. justify (str) – text justification (bottom-left, bottom-right, top-left, top-right, centered). bg – background color of corner annotations. Only applies of pos is int. font (str) – additional available fonts are: Ageo Aldora CallingCode Godsway Gula ImpactLabel Komiko Lamborgini MidnightDrive Militech MonaShark Montserrat MyDisplaySt PointedLaidSt SchoolTeacher SpecialElite Font choice does not apply for 3D text. A path to otf or ttf font-file can also be supplied as input. All fonts are free for personal use. Check out conditions in vtkplotter/fonts/licenses for commercial use and: https://www.1001freefonts.com

Hint

Torus¶

vtkplotter.shapes.Torus(pos=(0, 0, 0), r=1, thickness=0.2, c='khaki', alpha=1, res=30)[source]

Build a torus of specified outer radius r internal radius thickness, centered at pos.

Tube¶

vtkplotter.shapes.Tube(points, r=1, c='r', alpha=1, res=12)[source]

Build a tube along the line defined by a set of points.

Parameters: r (float, list) – constant radius or list of radii. c (float, list) – constant color or list of colors for each point.