Canvas

class braket.ahs.canvas.Canvas(boundary_points)[source]

Bases: object

Defines a region where atoms can be placed using boundary points.

A Canvas represents a polygonal region in 2D space defined by boundary points. It is used by factory methods to determine which lattice sites should contain atoms.

Parameters:

boundary_points (list[tuple[Number, Number]])

Initialize a Canvas with boundary points.

Parameters:

boundary_points (list[tuple[Number, Number]]) – List of (x, y) coordinates defining the polygon boundary. Must have at least 3 points.

Raises:
  • ValueError – If fewer than 3 boundary points are provided.

  • TypeError – If boundary points are not properly formatted.

contains_point(point)[source]

Check if a point is inside the canvas using ray casting algorithm.

Parameters:

point (tuple[Number, Number]) – The (x, y) coordinate to test.

Return type:

bool

Returns:

bool – True if the point is inside the canvas, False otherwise.

get_bounding_box()[source]

Get the bounding box of the canvas.

Return type:

tuple[tuple[Number, Number], tuple[Number, Number]]

Returns:

tuple[tuple[Number, Number], tuple[Number, Number]] – ((min_x, min_y), (max_x, max_y)) coordinates of the bounding box.