Skip to content

Commit

Permalink
Merge pull request #1407 from simbilod/main
Browse files Browse the repository at this point in the history
add angle parameter to ring component
  • Loading branch information
joamatab committed Mar 10, 2023
2 parents 679b061 + 6c89e7a commit 8007092
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gdsfactory/components/ring.py
Expand Up @@ -5,7 +5,7 @@

import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.typings import LayerSpec
from gdsfactory.typings import LayerSpec, Optional


@gf.cell
Expand All @@ -14,6 +14,7 @@ def ring(
width: float = 0.5,
angle_resolution: float = 2.5,
layer: LayerSpec = "WG",
angle: Optional[float] = 360,
) -> Component:
"""Returns a ring.
Expand All @@ -22,12 +23,13 @@ def ring(
width: of the ring.
angle_resolution: number of points per degree.
layer: layer.
angle: angular coverage of the ring
"""
D = gf.Component()
inner_radius = radius - width / 2
outer_radius = radius + width / 2
n = int(np.round(360 / angle_resolution))
t = np.linspace(0, 360, n + 1) * pi / 180
t = np.linspace(0, angle, n + 1) * pi / 180
inner_points_x = (inner_radius * cos(t)).tolist()
inner_points_y = (inner_radius * sin(t)).tolist()
outer_points_x = (outer_radius * cos(t)).tolist()
Expand All @@ -39,5 +41,5 @@ def ring(


if __name__ == "__main__":
c = ring(radius=5)
c = ring(radius=5, angle=270)
c.show(show_ports=True)

0 comments on commit 8007092

Please sign in to comment.