tidy3d.GeometryArray#

class GeometryArray[source]#

Bases: Geometry

A geometry representing an array of copies of a base geometry, with optional offsets and/or linear transformations applied to each copy.

Parameters:
  • geometry (Union[Box, Transformed, ClipOperation, GeometryGroup, GeometryArray, Sphere, Cylinder, PolySlab, ComplexPolySlabBase, TriangleMesh]) – Base geometry to be repeated in the array.

  • offsets (Optional[tuple[tuple[float, float, float], ...]] = None) – A tuple of 3D coordinate offsets. Each offset translates the base geometry (after any transform is applied) to create a copy. If not provided, no additional translation is applied beyond any transforms.

  • transforms (Optional[tuple[ArrayLike[dtype=float, ndim=2, shape=(4, 4)], ...]] = None) – A tuple of 4x4 linear-only transformation matrices (rotation/reflection/scale/shear, no translation). Typical transforms can be created using Transformed.rotation, Transformed.reflection, or Transformed.scaling. Each transform is applied to the base geometry before the corresponding offset translation. If not provided, only translations from offsets are applied.

  • geometries (This class provides an efficient way to represent arrays of repeated)

:param : :param avoiding the need to create many individual geometry objects.: :param The instance pose for each copy is defined as: :type The instance pose for each copy is defined as: T(offsets[i]) @ L(transforms[i]), :param where T is a translation matrix and L is the linear transform. In other words: :param : :param the transform is applied first: :param then the translation.:

Notes

  • offsets represent all per-instance translation.

  • transforms represent linear transforms only (rotation/reflection/scale/shear) and must not contain translation. Use offsets for translations.

  • If both offsets and transforms are None, the array contains a single instance of the base geometry at the origin.

  • If both are provided, they must have the same length.

  • Adjoint/autodiff is not currently supported for GeometryArray.

Parameters:
  • geometry (GeometryType) – Base geometry to be repeated in the array. Must have finite bounds.

  • offsets (Optional[tuple[Coordinate, ...]]) – Optional tuple of 3D coordinate offsets. Each offset translates the base geometry (after any transform is applied) to create a copy. If not provided, no additional translation is applied beyond any transforms.

  • transforms (Optional[tuple[MatrixReal4x4, ...]]) – Optional tuple of 4x4 linear-only transformation matrices. Each transform must be a valid homogeneous linear transform (rotation/reflection/scale/shear) with no translation component (i.e., transform[:3, 3] == 0 and transform[3, :] == [0, 0, 0, 1]). Typical transforms can be created using Transformed.rotation, Transformed.reflection, or Transformed.scaling.

Example

>>> import tidy3d as td
>>> import numpy as np
>>> box = td.Box(size=(1, 1, 1))
>>> # Using offsets only:
>>> offsets = [[0, 0, 0], [2, 0, 0], [0, 2, 0], [2, 2, 0]]
>>> array = td.GeometryArray(geometry=box, offsets=offsets)
>>> # Or use the convenience method:
>>> array = box.array(offsets=offsets)
>>> # Using linear transforms only (rotation around z-axis):
>>> rot_0 = td.Transformed.rotation(0, 2)  # no rotation
>>> rot_90 = td.Transformed.rotation(np.pi/2, 2)  # 90 degree rotation
>>> array = td.GeometryArray(geometry=box, transforms=[rot_0, rot_90])
>>> # Both None gives single instance of base geometry:
>>> array = td.GeometryArray(geometry=box)

Attributes

bounds

Returns bounding box min and max coordinates.

num_geometries

Number of geometries in the array.

geometry

offsets

transforms

Methods

inside(x, y, z)

For input arrays x, y, z of arbitrary but identical shape, return an array with the same shape which is True for every point in zip(x, y, z) that is inside the volume of the Geometry, and False otherwise.

intersections_plane([x, y, z, cleanup, ...])

Returns list of shapely geometries at plane specified by one non-None value of x,y,z.

intersections_tilted_plane(normal, origin, to_2D)

Return a list of shapely geometries at the plane specified by normal and origin.

intersects_axis_position(axis, position)

Whether self intersects plane specified by a given position along a normal axis.

geometry#
offsets#
transforms#
property num_geometries#

Number of geometries in the array.

property bounds#

Returns bounding box min and max coordinates.

Returns:

Min and max bounds packaged as (minx, miny, minz), (maxx, maxy, maxz).

Return type:

Tuple[float, float, float], Tuple[float, float, float]

intersections_tilted_plane(normal, origin, to_2D, cleanup=True, quad_segs=None)[source]#

Return a list of shapely geometries at the plane specified by normal and origin.

Parameters:
  • normal (Coordinate) – Vector defining the normal direction to the plane.

  • origin (Coordinate) – Vector defining the plane origin.

  • to_2D (MatrixReal4x4) – Transformation matrix to apply to resulting shapes.

  • cleanup (bool = True) – If True, removes extremely small features from each polygon’s boundary.

  • quad_segs (Optional[int] = None) – Number of segments used to discretize circular shapes. If None, uses high-quality visualization settings.

Returns:

List of 2D shapes that intersect plane. For more details refer to Shapely’s Documentation.

Return type:

List[shapely.geometry.base.BaseGeometry]

intersections_plane(x=None, y=None, z=None, cleanup=True, quad_segs=None)[source]#

Returns list of shapely geometries at plane specified by one non-None value of x,y,z.

Parameters:
  • x (float = None) – Position of plane in x direction, only one of x,y,z can be specified to define plane.

  • y (float = None) – Position of plane in y direction, only one of x,y,z can be specified to define plane.

  • z (float = None) – Position of plane in z direction, only one of x,y,z can be specified to define plane.

  • cleanup (bool = True) – If True, removes extremely small features from each polygon’s boundary.

  • quad_segs (Optional[int] = None) – Number of segments used to discretize circular shapes. If None, uses high-quality visualization settings.

Returns:

List of 2D shapes that intersect plane. For more details refer to Shapely’s Documentation.

Return type:

List[shapely.geometry.base.BaseGeometry]

intersects_axis_position(axis, position)[source]#

Whether self intersects plane specified by a given position along a normal axis.

Parameters:
  • axis (int = None) – Axis normal to the plane.

  • position (float = None) – Position of plane along the normal axis.

Returns:

Whether this geometry intersects the plane.

Return type:

bool

inside(x, y, z)[source]#

For input arrays x, y, z of arbitrary but identical shape, return an array with the same shape which is True for every point in zip(x, y, z) that is inside the volume of the Geometry, and False otherwise.

Parameters:
  • x (np.ndarray[float]) – Array of point positions in x direction.

  • y (np.ndarray[float]) – Array of point positions in y direction.

  • z (np.ndarray[float]) – Array of point positions in z direction.

Returns:

True for every point that is inside the geometry.

Return type:

np.ndarray[bool]