Generate a rectangular array of locations.
(self: T, xs: Real, ys: Real, nx: int, ny: int)
| 369 | # distribute locations |
| 370 | |
| 371 | def rarray(self: T, xs: Real, ys: Real, nx: int, ny: int) -> T: |
| 372 | """ |
| 373 | Generate a rectangular array of locations. |
| 374 | """ |
| 375 | |
| 376 | if nx < 1 or ny < 1: |
| 377 | raise ValueError(f"At least 1 elements required, requested {nx}, {ny}") |
| 378 | |
| 379 | locs = [] |
| 380 | |
| 381 | offset = Vector((nx - 1) * xs, (ny - 1) * ys) * 0.5 |
| 382 | for i, j in product(range(nx), range(ny)): |
| 383 | locs.append(Location(Vector(i * xs, j * ys) - offset)) |
| 384 | |
| 385 | if self._selection: |
| 386 | selection: Sequence[Union[Shape, Location, Vector]] = self._selection |
| 387 | else: |
| 388 | selection = [Vector()] |
| 389 | |
| 390 | return self.push( |
| 391 | (l * el if isinstance(el, Location) else l * Location(el.Center())) |
| 392 | for l in locs |
| 393 | for el in selection |
| 394 | ) |
| 395 | |
| 396 | def parray(self: T, r: Real, a1: Real, da: Real, n: int, rotate: bool = True) -> T: |
| 397 | """ |