Circle

class photonforge.Circle(radius, center=(0, 0), inner_radius=None, sector=(0, 0), rotation=0, min_evals=0)

Circular primitives including circles, ellipses, rings and sectors.

Parameters:
  • radius (float | Sequence[float] | complex) – Outer radius for the circle. If a pair of number is given, an ellipse is constructed instead.

  • center (Sequence[float] | complex) – Pair of coordinates (or complex number) for the center of the circle.

  • inner_radius (float | Sequence[float] | complex) – If set to a number or pair of numbers, constructs a ring with circular or elliptical hole.

  • sector (Sequence[float] | complex) – Initial and final angles (in degrees) to create a circular or elliptical sector.

  • rotation (float) – Rotation angle for the main axis of the ellipse (in degrees).

  • min_evals (int) – Minimal number of points used when converting arcs in this shape to polygonal lines. If required, the number of points will be greater to guarantee that config.tolerance is enforced.

Example

>>> circle = Circle(10, (-3, 4))  # Circular shape
>>> elliptical_ring = Circle(radius=(10, 8), inner_radius=(8, 6))
>>> half_ring = Circle(radius=10, inner_radius=8, sector=(0, 180))

Methods

add_gds_property(value)

Add a custom property to this object compatible with GDSII files.

area()

Structure area.

bounds()

Calculate the structure bounds

copy()

Create a copy of this structure.

mirror([axis_endpoint, axis_origin])

Mirror this structure.

perimeter()

Structure perimeter.

rotate(rotation[, center])

Rotate this structure.

scale(scaling[, center])

Scale this structure.

to_polygon()

Create a Polygon from this structure.

transform([translation, rotation, scaling, ...])

Apply a transformation to this structure: self = translate(rotate(mirror(scale(self))))

translate(translation)

Translate this structure.

Attributes

center

Center of the circle.

inner_radius

Inner radius of a ring.

json

(DEPRECATED) Json representation of this layer specification.

min_evals

Minimal number of points used to convert arcs in this shape to polygonal lines.

properties

Object properties.

radius

Circle radius.

rotation

Rotation angle of an elliptical shape (in degrees).

sector

Initial and final angles of a circular sector.

x_max

Upper bound in the x axis.

x_mid

Bounding box center in the x axis.

x_min

Lower bound in the x axis.

y_max

Upper bound in the y axis.

y_mid

Bounding box center in the y axis.

y_min

Lower bound in the y axis.

add_gds_property(value)

Add a custom property to this object compatible with GDSII files.

Parameters:
  • attribute (int) – Property number.

  • value (str) – Property value.

area()

Structure area.

Returns:

Area of the structure.

Return type:

float

bounds()

Calculate the structure bounds

Returns:

The lower-left and upper-right corners of the bounding box of the structure: ((min_x, min_y), (max_x, max_y)).

Return type:

tuple[ndarray, ndarray]

Example

>>> polygon = Polygon([(0, 1), (1, 2), (3, -1)])
>>> bounds = polygon.bounds()
>>> print(bounds)
((0.0, -1.0), (3.0, 2.0))
center

Center of the circle.

Type:

ndarray

copy()

Create a copy of this structure.

Returns:

New copy.

Return type:

Circle

inner_radius

Inner radius of a ring.

Type:

ndarray

json

(DEPRECATED) Json representation of this layer specification.

Type:

str

min_evals

Minimal number of points used to convert arcs in this shape to polygonal lines.

Type:

int

mirror(axis_endpoint=(1, 0), axis_origin=(0, 0))

Mirror this structure.

Parameters:
  • axis_endpoint (Sequence[float] | complex) – Mirror axis endpoint.

  • axis_origin (Sequence[float] | complex) – Mirror axis origin.

Returns:

This object.

Return type:

Circle

perimeter()

Structure perimeter.

Returns:

Perimeter of the structure.

Return type:

float

properties

Object properties.

Type:

Properties

radius

Circle radius.

Type:

ndarray

rotate(rotation, center=(0, 0))

Rotate this structure.

Parameters:
  • rotation (float) – Rotation angle (in degrees).

  • center (Sequence[float, float] | complex) – Center of rotation.

Returns:

This object.

Return type:

Circle

rotation

Rotation angle of an elliptical shape (in degrees).

Type:

float

scale(scaling, center=(0, 0))

Scale this structure.

Parameters:
  • scaling (float) – Magnification factor.

  • center (Sequence[float, float] | complex) – Center of scaling.

Returns:

This object.

Return type:

Circle

sector

Initial and final angles of a circular sector.

Type:

ndarray

to_polygon()

Create a Polygon from this structure.

Returns:

New polygon instance.

Return type:

Polygon

Examples

>>> rectangle = Rectangle((0, 0), (2, 1), rotation=45)
>>> polygon = rectangle.to_polygon()
>>> circle = Circle(5, (0, 0), inner_radius=3)
>>> polygon = circle.to_polygon()
>>> path = Path((0, 0), 0.5).s_bend((10, 2))
>>> polygon = path.to_polygon()
transform(translation=(0, 0), rotation=0, scaling=1, x_reflection=False)

Apply a transformation to this structure: self = translate(rotate(mirror(scale(self))))

Parameters:
  • translation (Sequence[float, float] | complex) – Translation vector.

  • rotation (float) – Rotation angle (in degrees).

  • scaling (float) – Magnification factor.

  • x_reflection (bool) – Mirror across the horizontal axis.

Returns:

This object.

Return type:

Circle

translate(translation)

Translate this structure.

Parameters:

translation (Sequence[float, float] | complex) – Translation vector.

Returns:

This object.

Return type:

Circle

x_max

Upper bound in the x axis.

Type:

float

x_mid

Bounding box center in the x axis.

Type:

float

x_min

Lower bound in the x axis.

Type:

float

y_max

Upper bound in the y axis.

Type:

float

y_mid

Bounding box center in the y axis.

Type:

float

y_min

Lower bound in the y axis.

Type:

float