Helper module for general geometric functions


Returns the direction and length of the pya.DVector “vector”.

kqcircuits.util.geometry_helper.point_shift_along_vector(start, other, distance=None)[source]

Returns a point at a distance away from point start in the direction of point other.


Returns the direction vector corresponding to angle.


angle – angle in degrees

Returns: Unit vector in direction angle


Returns the angle in degrees for a given DVector (or DPoint)


vector – input vector

Returns: angle in degrees

kqcircuits.util.geometry_helper.get_cell_path_length(cell, layer=None)[source]

Returns the length of the paths in the cell.

Adding together the cell’s paths’ lengths in the “1t1_waveguide_path”, “2b1_waveguide_path” and “waveguide_length” layers.

  • cell – A cell object.

  • layer – None or an unsigned int to specify a non-standard layer

kqcircuits.util.geometry_helper.get_object_path_length(obj, layer=None)[source]

Returns sum of lengths of all the paths in the object and its children

  • obj – ObjectInstPath object

  • layer – layer integer id in the database, waveguide layer by default

kqcircuits.util.geometry_helper.region_with_merged_points(region, tolerance)[source]

In each polygon of the region, removes points that are closer to other points than a given tolerance.

  • region – Input region

  • tolerance – Minimum distance, in database units, between two adjacent points in the resulting region


with merged points

Return type


kqcircuits.util.geometry_helper.region_with_merged_polygons(region, tolerance, expansion=0.0)[source]

Merges polygons in given region. Ignores gaps that are smaller than given tolerance.

  • region – input region

  • tolerance – largest gap size to be ignored

  • expansion – the amount by which the polygons are expanded (edges move outwards)


region with merged polygons


Returns True if the polygon points are in clockwise order, False if they are counter-clockwise.


polygon_points – list of polygon points, must be either in clockwise or counterclockwise order

kqcircuits.util.geometry_helper.circle_polygon(r, n=64, origin=0, 0)[source]

Returns a polygon for a full circle around the origin.

  • r – Radius

  • origin – Center of the circle, default (0,0)

  • n – Number of points.

Returns: list of DPoint``s, length ``n.

kqcircuits.util.geometry_helper.arc_points(r, start=0, stop=6.283185307179586, n=64, origin=0, 0)[source]

Returns point describing an arc around the origin with specified start and stop angles. The start and stop angle are included.

If start < stop, the points are counter-clockwise; if start > stop, the points are clockwise.

  • r – Arc radius

  • start – Start angle in radians, default 0

  • stop – Stop angle in radians, default 2*pi

  • origin – Center of the arc, default (0,0)

  • n – Number of steps corresponding to a full circle.