Generate a polar array of locations.
(self: T, r: Real, a1: Real, da: Real, n: int, rotate: bool = True)
| 394 | ) |
| 395 | |
| 396 | def parray(self: T, r: Real, a1: Real, da: Real, n: int, rotate: bool = True) -> T: |
| 397 | """ |
| 398 | Generate a polar array of locations. |
| 399 | """ |
| 400 | |
| 401 | if n < 1: |
| 402 | raise ValueError(f"At least 1 element required, requested {n}") |
| 403 | |
| 404 | locs = [] |
| 405 | |
| 406 | if abs(remainder(da, 360)) < TOL: |
| 407 | angle = da / n |
| 408 | else: |
| 409 | angle = da / (n - 1) if n > 1 else a1 |
| 410 | |
| 411 | for i in range(0, n): |
| 412 | phi = a1 + (angle * i) |
| 413 | x = r * cos(radians(phi)) |
| 414 | y = r * sin(radians(phi)) |
| 415 | |
| 416 | loc = Location(Vector(x, y)) |
| 417 | locs.append(loc) |
| 418 | |
| 419 | if self._selection: |
| 420 | selection: Sequence[Union[Shape, Location, Vector]] = self._selection |
| 421 | else: |
| 422 | selection = [Vector()] |
| 423 | |
| 424 | return self.push( |
| 425 | ( |
| 426 | l |
| 427 | * el |
| 428 | * Location( |
| 429 | Vector(0, 0), Vector(0, 0, 1), (a1 + (angle * i)) if rotate else 0 |
| 430 | ) |
| 431 | ) |
| 432 | for i, l in enumerate(locs) |
| 433 | for el in [ |
| 434 | el if isinstance(el, Location) else Location(el.Center()) |
| 435 | for el in selection |
| 436 | ] |
| 437 | ) |
| 438 | |
| 439 | def distribute( |
| 440 | self: T, n: int, start: Real = 0, stop: Real = 1, rotate: bool = True |