Circle
Circle( radius, center=(0, 0), inner_radius=None, sector=(0, 0), rotation=0, min_evals=0,)Circular primitives including circles, ellipses, rings and sectors.
Args
- 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 | None): 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.toleranceis enforced.
Example
>>> circle = pf.Circle(10, (-3, 4)) # Circular shape>>> elliptical_ring = pf.Circle(radius=(10, 8), inner_radius=(8, 6))>>> half_ring = pf.Circle(radius=9, inner_radius=6, sector=(0, 180))Methods
Section titled “Methods”| Method | Description |
|---|---|
add_gds_property | 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 | Mirror this structure. |
perimeter | Structure perimeter. |
rotate | Rotate this structure. |
scale | Scale this structure. |
to_polygon | Create a Polygon from this structure. |
transform | Apply a transformation to this structure: |
translate | Translate this structure. |
add_gds_property
Section titled “add_gds_property”add_gds_property(attribute, value)Add a custom property to this object compatible with GDSII files.
Args
- attribute (int): Property number.
- value (str): Property value.
area(self)Structure area.
Returns
float: Area of the structure.
bounds
Section titled “bounds”bounds(self)Calculate the structure bounds
Returns
tuple[ndarray, ndarray]: The lower-left and upper-right corners of
the bounding box of the structure:
((min_x, min_y), (max_x, max_y)).
Example
>>> polygon = pf.Polygon([(0, 1), (1, 2), (3, -1)])>>> bounds = polygon.bounds()>>> print(bounds)(array([ 0., -1.]), array([3., 2.]))copy(self)Create a copy of this structure.
Returns
Circle: New copy.
mirror
Section titled “mirror”mirror(self, axis_endpoint=(1, 0), axis_origin=(0, 0))Mirror this structure.
Args
- axis_endpoint (Sequence[float] | complex): Mirror axis endpoint.
- axis_origin (Sequence[float] | complex): Mirror axis origin.
Returns
Circle: This object.
perimeter
Section titled “perimeter”perimeter(self)Structure perimeter.
Returns
float: Perimeter of the structure.
rotate
Section titled “rotate”rotate(self, rotation, center=(0, 0))Rotate this structure.
Args
- rotation (float): Rotation angle (in degrees).
- center (Sequence[float, float] | complex): Center of rotation.
Returns
Circle: This object.
scale(self, scaling, center=(0, 0))Scale this structure.
Args
- scaling (float): Magnification factor.
- center (Sequence[float, float] | complex): Center of scaling.
Returns
Circle: This object.
to_polygon
Section titled “to_polygon”to_polygon(self)Create a Polygon from this structure.
Returns
Polygon: New polygon instance.
Examples
>>> rectangle = pf.Rectangle((0, 0), (2, 1), rotation=45)>>> polygon = rectangle.to_polygon()>>> circle = pf.Circle(5, (0, 0), inner_radius=3)>>> polygon = circle.to_polygon()>>> path = pf.Path((0, 0), 0.5).s_bend((10, 2))>>> polygon = path.to_polygon()transform
Section titled “transform”transform( self, translation=(0, 0), rotation=0, scaling=1, x_reflection=False)Apply a transformation to this structure:
self = translate(rotate(mirror(scale(self))))
Args
- 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
Circle: This object.
translate
Section titled “translate”translate(self, translation)Translate this structure.
Args
- translation (Sequence[float, float] | complex): Translation vector.
Returns
Circle: This object.
Attributes
Section titled “Attributes”| Attribute | Description |
|---|---|
center | ndarray: Center of the circle. |
inner_radius | ndarray: Inner radius of a ring. |
min_evals | int: Minimal number of points used to convert arcs in this shape to polygonal lines. |
properties | Properties: Object properties. |
radius | ndarray: Circle radius. |
rotation | float: Rotation angle of an elliptical shape (in degrees). |
sector | ndarray: Initial and final angles of a circular sector. |
x_max | float: Upper bound in the x axis. |
x_mid | float: Bounding box center in the x axis. |
x_min | float: Lower bound in the x axis. |
y_max | float: Upper bound in the y axis. |
y_mid | float: Bounding box center in the y axis. |
y_min | float: Lower bound in the y axis. |
center
Section titled “center”ndarray: Center of the circle.
inner_radius
Section titled “inner_radius”ndarray: Inner radius of a ring.
min_evals
Section titled “min_evals”int: Minimal number of points used to convert arcs in this shape to polygonal lines.
properties
Section titled “properties”Properties: Object properties.
radius
Section titled “radius”ndarray: Circle radius.
rotation
Section titled “rotation”float: Rotation angle of an elliptical shape (in degrees).
sector
Section titled “sector”ndarray: Initial and final angles of a circular sector.
float: Upper bound in the x axis.
float: Bounding box center in the x axis.
float: Lower bound in the x axis.
float: Upper bound in the y axis.
float: Bounding box center in the y axis.
float: Lower bound in the y axis.