Geometry API

Complete API reference for geometric primitives and shapes in Prismo.

Geometric Shapes

Box

class prismo.geometry.shapes.Box(material, center, size)[source]

Bases: Shape

Rectangular box/cuboid shape.

Parameters:
  • material (Material) – Material filling the box.

  • center (Tuple[float, float, float]) – Box center coordinates.

  • size (Tuple[float, float, float]) – Box dimensions (Lx, Ly, Lz). For 2D, set Lz=0.

__init__(material, center, size)[source]
contains(points)[source]

Check if points are inside the box.

Return type:

ndarray

Sphere

class prismo.geometry.shapes.Sphere(material, center, radius)[source]

Bases: Shape

Spherical shape.

Parameters:
  • material (Material) – Material filling the sphere.

  • center (Tuple[float, float, float]) – Sphere center coordinates.

  • radius (float) – Sphere radius.

__init__(material, center, radius)[source]
contains(points)[source]

Check if points are inside the sphere.

Return type:

ndarray

Cylinder

class prismo.geometry.shapes.Cylinder(material, center, radius, height, axis='z')[source]

Bases: Shape

Cylindrical shape.

Parameters:
  • material (Material) – Material filling the cylinder.

  • center (Tuple[float, float, float]) – Cylinder center coordinates.

  • radius (float) – Cylinder radius.

  • height (float) – Cylinder height.

  • axis (str) – Cylinder axis (‘x’, ‘y’, or ‘z’), default=’z’.

__init__(material, center, radius, height, axis='z')[source]
contains(points)[source]

Check if points are inside the cylinder.

Return type:

ndarray

Polygon

class prismo.geometry.shapes.Polygon(material, vertices, z_min=-inf, z_max=inf)[source]

Bases: Shape

Polygonal shape (2D, extruded in z).

Parameters:
  • material (Material) – Material filling the polygon.

  • vertices (array-like) – Polygon vertices as (N, 2) array of (x, y) coordinates.

  • z_min (float) – Z-extent for extrusion.

  • z_max (float) – Z-extent for extrusion.

__init__(material, vertices, z_min=-inf, z_max=inf)[source]
contains(points)[source]

Check if points are inside the polygon.

Uses ray casting algorithm for 2D point-in-polygon test.

Return type:

ndarray

Composite Structures

GeometryGroup

class prismo.geometry.shapes.GeometryGroup(shapes, operation='union')[source]

Bases: object

Group of shapes with boolean operations.

Supports union, intersection, and difference operations.

Parameters:
  • shapes (list of Shape) – List of shapes to combine.

  • operation (str) – Boolean operation: ‘union’, ‘intersection’, ‘difference’.

__init__(shapes, operation='union')[source]
rasterize(x, y, z=None)[source]

Rasterize combined geometry.

Returns:

Combined mask and list of material indices for each shape.

Return type:

Tuple[ndarray, list]

Usage Examples

Creating Basic Shapes

from prismo.geometry import Box, Cylinder
from prismo.materials import Material

# Silicon waveguide core
si = Material(epsilon=3.48**2)

core = Box(
    center=(0, 0, 0),
    size=(10e-6, 0.5e-6, 0.22e-6),
    material=si,
)

# Cylindrical post
post = Cylinder(
    center=(5e-6, 0, 0.5e-6),
    radius=0.3e-6,
    height=1e-6,
    material=si,
    axis='z',
)

Combining Shapes

from prismo.geometry import GeometryGroup

# Create a group of structures
waveguide_array = GeometryGroup()
for i in range(5):
    wg = Box(
        center=(i * 5e-6, 0, 0),
        size=(3e-6, 0.5e-6, 0.22e-6),
        material=si,
    )
    waveguide_array.add(wg)

# Add to simulation
sim.add_structure(waveguide_array)

See Also