From be3cc2af0854992aa0c3e00a8db6979f27cb7160 Mon Sep 17 00:00:00 2001 From: fbeutel Date: Wed, 2 Dec 2020 16:12:06 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Waveguide:=20Add=20convenience=20methods=20?= =?UTF-8?q?for=2090=C2=B0=20left=20and=20right=20turns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gdshelpers/parts/waveguide.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gdshelpers/parts/waveguide.py b/gdshelpers/parts/waveguide.py index 5fe7d81..59d792f 100644 --- a/gdshelpers/parts/waveguide.py +++ b/gdshelpers/parts/waveguide.py @@ -546,6 +546,18 @@ def add_straight_segment_until_level_of_port(self, port, **line_kw): self.add_straight_segment_to_intersection(port.origin, port.angle - np.pi / 2, **line_kw) return self + def add_left(self, bend_radius): + """ + Add a 90° left turn with the given bend radius + """ + return self.add_bend(0.5*np.pi, bend_radius) + + def add_right(self, bend_radius): + """ + Add a 90° right turn with the given bend radius + """ + return self.add_bend(-0.5*np.pi, bend_radius) + def _example(): from gdshelpers.geometry.chip import Cell From 7980cb8adf5e70f593b5a4eb65a2fbc76dcc1e63 Mon Sep 17 00:00:00 2001 From: fbeutel Date: Wed, 2 Dec 2020 17:10:42 +0100 Subject: [PATCH 2/2] Add optional angle parameter Co-authored-by: frank-bp <60472284+frank-bp@users.noreply.github.com> --- gdshelpers/parts/waveguide.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gdshelpers/parts/waveguide.py b/gdshelpers/parts/waveguide.py index 59d792f..a710b0a 100644 --- a/gdshelpers/parts/waveguide.py +++ b/gdshelpers/parts/waveguide.py @@ -546,17 +546,17 @@ def add_straight_segment_until_level_of_port(self, port, **line_kw): self.add_straight_segment_to_intersection(port.origin, port.angle - np.pi / 2, **line_kw) return self - def add_left(self, bend_radius): + def add_left_bend(self, radius, angle=np.pi/2): """ - Add a 90° left turn with the given bend radius + Add a left turn (90° or as defined by angle) with the given bend radius """ - return self.add_bend(0.5*np.pi, bend_radius) + return self.add_bend(angle, radius) - def add_right(self, bend_radius): + def add_right_bend(self, radius, angle=np.pi/2): """ - Add a 90° right turn with the given bend radius + Add a right turn (90° or as defined by angle) with the given bend radius """ - return self.add_bend(-0.5*np.pi, bend_radius) + return self.add_bend(-angle, radius) def _example():