Home Forums Nazca Need to define periodic holes next to the waveguide Reply To: Need to define periodic holes next to the waveguide

#5622
paul
Member

Thanks Ronald,

I have found a quick and ugly way of doing it by calculating the line integral along the path. Whenever the distance gets bigger than an multiple of my desired spacing, I place the desired geometry. This works as long as the curve is defined with enough points.

xy = nd.curve2polyline(nd.sinebend_point, (100, 20, 0), 0.0001, (100, 20))
x, y = map(list, zip(*xy))

dl = 0  # element of length
lint = 0  # total integral
k = 1
spacing = 10  # desired spacing

for i in range(1, len(y)):
    dl = np.sqrt((x[i] - x[i - 1]) ** 2 + (y[i] - y[i - 1]) ** 2)
    lint += dl
    if lint > k * spacing:
        hole.put(x[i], y[i])
    k += 1

nd.export_plt()