kqcircuits.util.geometry_helper

Helper module for general geometric functions

kqcircuits.util.geometry_helper.vector_length_and_direction(vector)[source]

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.

kqcircuits.util.geometry_helper.get_direction(angle)[source]

Returns the direction vector corresponding to angle.

Parameters

angle – angle in degrees

Returns: Unit vector in direction angle

kqcircuits.util.geometry_helper.get_angle(vector)[source]

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

Parameters

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.

Parameters
  • 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

Parameters
  • obj – ObjectInstPath object

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

kqcircuits.util.geometry_helper.simple_region(region)[source]
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.

Parameters
  • region – Input region

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

Returns

with merged points

Return type

region

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.

Parameters
  • region – input region

  • tolerance – largest gap size to be ignored

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

Returns

region with merged polygons

kqcircuits.util.geometry_helper.is_clockwise(polygon_points)[source]

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

Parameters

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.

Parameters
  • 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.

Parameters
  • 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.

../_images/kqcircuits.util.geometry_helper.png