Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add radial arrays to documentation? #232

Open
andrgeri opened this issue Jan 20, 2024 · 1 comment
Open

Add radial arrays to documentation? #232

andrgeri opened this issue Jan 20, 2024 · 1 comment

Comments

@andrgeri
Copy link

I don't know if this may be useful, but I was wondering if there is an easy way to realize a radial array.
For instance, given the number of copies $N$ and the rotation angle $\theta$, obtain something like the following:

radial_array

While it can be done using a repetition, it isn't exactly straightforward (at least to me).
Would it be possible to provide an example in the documentation?

@nmz787-intel
Copy link

I think this accomplishes what you want?

import math
import gdstk

lib = gdstk.Library()

# Create a cell with collection of shapes that is used repeatedly
triangle = gdstk.regular_polygon((0, 6), 2, 3, rotation=math.pi)
single_triangle_cell = lib.new_cell("TRIANGLE_SINGLE")
single_triangle_cell.add(triangle)

def add_array(input_cell, output_cell, degrees_sweep, total_triangles):
    number_repetitions = total_triangles
    num_extra_triangles_from_full_rotation_sweep = degrees_sweep//360
    degrees_separation = degrees_sweep/(number_repetitions-1+num_extra_triangles_from_full_rotation_sweep)
    print(num_extra_triangles_from_full_rotation_sweep)
    assert number_repetitions>0
    for i in range(number_repetitions):
        rotated_ref = gdstk.Reference(input_cell, (0, 0), rotation=-math.radians(degrees_separation*i))
        output_cell.add(rotated_ref)
    return output_cell

triangle_array_4_over_90_deg = add_array(single_triangle_cell, lib.new_cell("4_TRIANGLE_ARRAY"), 90, 4)
triangle_array_3_over_90_deg = add_array(single_triangle_cell, lib.new_cell("3_TRIANGLE_ARRAY"), 90, 3)
triangle_array_8_over_360_deg = add_array(single_triangle_cell, lib.new_cell("8_TRIANGLE_ARRAY"), 360, 8)

lib.write_gds("testissue.gds")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants