CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-vedo

A python module for scientific visualization, analysis of 3D objects and point clouds.

Overview
Eval results
Files

shape-generation.mddocs/

Shape Generation

Comprehensive library of 3D shape primitives, geometric constructions, and procedural generation tools. Vedo provides an extensive collection of shapes ranging from basic geometric primitives to complex curves, text rendering, and specialized visualization objects.

Capabilities

Basic Geometric Primitives

Fundamental 3D shapes that serve as building blocks for complex visualizations.

class Sphere:
    """
    Create a spherical mesh.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Center position coordinates
    - r: float, default 1
        Sphere radius
    - res: int, default 24
        Resolution (number of subdivisions)
    - quads: bool, default False
        Use quad faces instead of triangles
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), r=1, res=24, quads=False, c="red", alpha=1): ...

class Box:
    """
    Create a box/rectangular mesh.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Center position coordinates
    - length: float, default 1
        Size along x-axis
    - width: float, default 1
        Size along y-axis  
    - height: float, default 1
        Size along z-axis
    - c: str or tuple, default "gold"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), length=1, width=1, height=1, c="gold", alpha=1): ...

class Cylinder:
    """
    Create a cylindrical mesh.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Center position coordinates
    - r: float, default 1
        Cylinder radius
    - height: float, default 2
        Cylinder height
    - axis: tuple, default (0, 0, 1)
        Cylinder axis direction
    - res: int, default 24
        Resolution around circumference
    - c: str or tuple, default "teal"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), r=1, height=2, axis=(0, 0, 1), res=24, c="teal", alpha=1): ...

class Cone:
    """
    Create a conical mesh.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Base center position
    - r: float, default 1
        Base radius
    - height: float, default 2
        Cone height
    - axis: tuple, default (0, 0, 1)
        Cone axis direction
    - res: int, default 24
        Resolution around circumference
    - c: str or tuple, default "dg"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), r=1, height=2, axis=(0, 0, 1), res=24, c="dg", alpha=1): ...

Advanced 3D Shapes

More complex geometric shapes for specialized visualization needs.

class Torus:
    """
    Create a toroidal mesh.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Center position coordinates
    - r: float, default 1
        Major radius (center to tube center)
    - thickness: float, default 0.2
        Minor radius (tube thickness)
    - res: int, default 24
        Resolution around major circumference
    - c: str or tuple, default "yellow"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), r=1, thickness=0.2, res=24, c="yellow", alpha=1): ...

class Ellipsoid:
    """
    Create an ellipsoidal mesh.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Center position coordinates
    - axis1: float, default 1
        Semi-axis length along x
    - axis2: float, default 1
        Semi-axis length along y
    - axis3: float, default 1
        Semi-axis length along z
    - res: int, default 24
        Surface resolution
    - c: str or tuple, default "cyan"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), axis1=1, axis2=1, axis3=1, res=24, c="cyan", alpha=1): ...

class Paraboloid:
    """
    Create a paraboloid surface.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Center position coordinates
    - height: float, default 1
        Paraboloid height
    - res: int, default 50
        Surface resolution
    - c: str or tuple, default "cyan"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), height=1, res=50, c="cyan", alpha=1): ...

Lines and Curves

Linear and curved objects for creating paths, connections, and smooth curves.

class Line:
    """
    Create a line object from points.
    
    Parameters:
    - p0: array-like
        Starting point or list of points
    - p1: array-like, optional
        Ending point (if p0 is single point)
    - res: int, default 1
        Line resolution/subdivisions
    - lw: float, default 1
        Line width
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, p0, p1=None, res=1, lw=1, c="red", alpha=1): ...

class DashedLine:
    """
    Create a dashed line visualization.
    
    Parameters:
    - p0: array-like
        Starting point
    - p1: array-like
        Ending point
    - spacing: float, default 0.1
        Spacing between dashes
    - lw: float, default 2
        Line width
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, p0, p1, spacing=0.1, lw=2, c="red", alpha=1): ...

class Spline:
    """
    Create a smooth spline curve through points.
    
    Parameters:
    - points: array-like
        Control points for spline
    - s: float, default 0
        Smoothing factor
    - degree: int, default 3
        Spline degree
    - res: int, default None
        Output resolution
    - closed: bool, default False
        Create closed curve
    - c: str or tuple, default "blue"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, points, s=0, degree=3, res=None, closed=False, c="blue", alpha=1): ...

class Arc:
    """
    Create a circular arc.
    
    Parameters:
    - center: tuple, default (0, 0, 0)
        Arc center position
    - point1: tuple
        First point on arc
    - point2: tuple
        Second point on arc
    - normal: tuple, optional
        Normal vector to arc plane
    - res: int, default 50
        Arc resolution
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, center=(0, 0, 0), point1=None, point2=None, normal=None, res=50, c="red", alpha=1): ...

Text and Annotations

Text rendering capabilities for labels, titles, and annotations in 3D space.

class Text3D:
    """
    Create 3D text objects.
    
    Parameters:
    - txt: str
        Text string to render
    - pos: tuple, default (0, 0, 0)
        Text position coordinates
    - s: float, default 1
        Text scale/size
    - font: str, default ""
        Font family name
    - hspacing: float, default 1.15
        Horizontal character spacing
    - vspacing: float, default 2.15
        Vertical line spacing
    - depth: float, default 0
        Text extrusion depth (0 for flat)
    - italic: bool, default False
        Use italic styling
    - justify: str, default "bottom-left"
        Text justification
    - c: str or tuple, default "black"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(
        self, 
        txt, 
        pos=(0, 0, 0), 
        s=1, 
        font="", 
        hspacing=1.15, 
        vspacing=2.15, 
        depth=0, 
        italic=False, 
        justify="bottom-left", 
        c="black", 
        alpha=1
    ): ...

class Text2D:
    """
    Create 2D text overlays.
    
    Parameters:
    - txt: str
        Text string to render
    - pos: tuple, default (0, 0)
        Screen position (0-1 normalized coordinates)
    - s: float, default 1
        Text size
    - font: str, default ""
        Font family name
    - c: str or tuple, default "black"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, txt, pos=(0, 0), s=1, font="", c="black", alpha=1): ...

class Caption:
    """
    Create caption annotations attached to 3D objects.
    
    Parameters:
    - obj: vedo object
        Object to attach caption to
    - txt: str
        Caption text
    - point: tuple, optional
        Specific attachment point
    - size: tuple, default (0.2, 0.05)
        Caption box size
    - padding: int, default 5
        Text padding
    - font: str, default ""
        Font family name
    - c: str or tuple, default "black"
        Text color
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, obj, txt="", point=None, size=(0.2, 0.05), padding=5, font="", c="black", alpha=1): ...

2D Shapes and Polygons

Flat geometric shapes and polygon creation tools.

class Circle:
    """
    Create a circular shape.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Center position coordinates
    - r: float, default 1
        Circle radius
    - res: int, default 24
        Resolution (number of points)
    - c: str or tuple, default "gray"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), r=1, res=24, c="gray", alpha=1): ...

class Rectangle:
    """
    Create a rectangular shape.
    
    Parameters:
    - p1: tuple, default (0, 0)
        First corner coordinates
    - p2: tuple, default (1, 1)
        Opposite corner coordinates
    - c: str or tuple, default "gray"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, p1=(0, 0), p2=(1, 1), c="gray", alpha=1): ...

class Polygon:
    """
    Create a polygon from vertices.
    
    Parameters:
    - vertices: array-like
        List of vertex coordinates
    - c: str or tuple, default "gold"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, vertices, c="gold", alpha=1): ...

class Star:
    """
    Create a star shape.
    
    Parameters:
    - pos: tuple, default (0, 0, 0)
        Center position coordinates
    - n: int, default 5
        Number of star points
    - r1: float, default 1
        Outer radius
    - r2: float, default 0.5
        Inner radius
    - c: str or tuple, default "blue"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, pos=(0, 0, 0), n=5, r1=1, r2=0.5, c="blue", alpha=1): ...

Arrows and Directional Indicators

Arrow objects for indicating directions, vectors, and flows.

class Arrow:
    """
    Create a 3D arrow object.
    
    Parameters:
    - startPoint: tuple, default (0, 0, 0)
        Arrow starting position
    - endPoint: tuple, default (1, 0, 0)
        Arrow ending position
    - s: float, default None
        Arrow shaft scale
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, startPoint=(0, 0, 0), endPoint=(1, 0, 0), s=None, c="red", alpha=1): ...

class Arrows:
    """
    Create multiple arrows from arrays of start/end points.
    
    Parameters:
    - startPoints: array-like
        Array of starting positions
    - endPoints: array-like
        Array of ending positions
    - s: float, default None
        Arrow scale factor
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, startPoints, endPoints, s=None, c="red", alpha=1): ...

class Arrow2D:
    """
    Create 2D arrow graphics.
    
    Parameters:
    - startPoint: tuple
        Arrow starting position (2D)
    - endPoint: tuple  
        Arrow ending position (2D)
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, startPoint, endPoint, c="red", alpha=1): ...

Specialized Shapes

Advanced shapes for specific visualization purposes.

class Tube:
    """
    Create a tube along a path.
    
    Parameters:
    - line: Line object or array-like
        Path to create tube along
    - r: float, default 1
        Tube radius
    - res: int, default 12
        Cross-sectional resolution
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, line, r=1, res=12, c="red", alpha=1): ...

class Spring:
    """
    Create a spring/helix shape.
    
    Parameters:
    - startPoint: tuple, default (0, 0, 0)
        Spring starting position
    - endPoint: tuple, default (1, 0, 0)
        Spring ending position
    - coils: int, default 20
        Number of coil turns
    - r1: float, default 0.1
        Spring radius
    - r2: float, default None
        Wire thickness radius
    - c: str or tuple, default "blue"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, startPoint=(0, 0, 0), endPoint=(1, 0, 0), coils=20, r1=0.1, r2=None, c="blue", alpha=1): ...

class Ribbon:
    """
    Create a ribbon surface along a path.
    
    Parameters:
    - line: Line object or array-like
        Path for ribbon centerline
    - width: float, default 1
        Ribbon width
    - c: str or tuple, default "red"
        Color specification
    - alpha: float, default 1
        Transparency value
    """
    def __init__(self, line, width=1, c="red", alpha=1): ...

Usage Examples

import vedo
import numpy as np

# Create basic geometric shapes
sphere = vedo.Sphere(pos=(0, 0, 0), r=1.5, c='red')
box = vedo.Box(pos=(3, 0, 0), length=2, width=1, height=1, c='blue')
cylinder = vedo.Cylinder(pos=(0, 3, 0), r=0.8, height=2, c='green')

# Create complex curves
points = np.array([[0, 0, 0], [1, 1, 2], [2, 0, 3], [3, 1, 1]])
spline = vedo.Spline(points, closed=False, c='purple')
line = vedo.Line(points, lw=3, c='orange')

# Add text annotations  
title = vedo.Text3D("3D Shapes Demo", pos=(0, -2, 2), s=0.5, c='black')
caption = vedo.Caption(sphere, "Red Sphere", size=(0.3, 0.1))

# Create arrows showing directions
arrow = vedo.Arrow((0, 0, 3), (2, 0, 3), c='yellow')

# Assemble and visualize
vedo.show(sphere, box, cylinder, spline, line, title, caption, arrow,
          title="Shape Generation Examples", axes=True, bg='lightblue')

# Create more complex compositions
stars = [vedo.Star(pos=(i*2, j*2, 0), n=5+i, c=f'C{i+j}') 
         for i in range(3) for j in range(3)]
         
tube_path = vedo.Line([[0, 0, 0], [2, 2, 1], [4, 0, 2], [6, 2, 3]])
tube = vedo.Tube(tube_path, r=0.2, c='cyan')

vedo.show(stars + [tube], title="Advanced Shapes")

Install with Tessl CLI

npx tessl i tessl/pypi-vedo

docs

analysis-algorithms.md

applications.md

colors-visual.md

core-objects.md

file-io.md

index.md

plotting-visualization.md

shape-generation.md

transformations-geometry.md

ui-components.md

tile.json