Sorts objects into a list with order determined by the distance of their center projected onto the specified direction. Applicability: All Shapes.
| 375 | |
| 376 | |
| 377 | class CenterNthSelector(_NthSelector): |
| 378 | """ |
| 379 | Sorts objects into a list with order determined by the distance of their center projected onto the specified direction. |
| 380 | |
| 381 | Applicability: |
| 382 | All Shapes. |
| 383 | """ |
| 384 | |
| 385 | def __init__( |
| 386 | self, |
| 387 | vector: Vector, |
| 388 | n: int, |
| 389 | directionMax: bool = True, |
| 390 | tolerance: float = 0.0001, |
| 391 | ): |
| 392 | super().__init__(n, directionMax, tolerance) |
| 393 | self.direction = vector |
| 394 | |
| 395 | def key(self, obj: Shape) -> float: |
| 396 | return obj.Center().dot(self.direction) |
| 397 | |
| 398 | |
| 399 | class DirectionMinMaxSelector(CenterNthSelector): |