(
self,
func: Callable[[np.ndarray], np.ndarray],
about_point: Vect3 | None = None,
about_edge: Vect3 = ORIGIN,
works_on_bounding_box: bool = False
)
| 277 | |
| 278 | @affects_family_data |
| 279 | def apply_points_function( |
| 280 | self, |
| 281 | func: Callable[[np.ndarray], np.ndarray], |
| 282 | about_point: Vect3 | None = None, |
| 283 | about_edge: Vect3 = ORIGIN, |
| 284 | works_on_bounding_box: bool = False |
| 285 | ) -> Self: |
| 286 | if about_point is None and about_edge is not None: |
| 287 | about_point = self.get_bounding_box_point(about_edge) |
| 288 | |
| 289 | for mob in self.get_family(): |
| 290 | arrs = [] |
| 291 | if mob.has_points(): |
| 292 | for key in mob.pointlike_data_keys: |
| 293 | arrs.append(mob.data[key]) |
| 294 | if works_on_bounding_box: |
| 295 | arrs.append(mob.get_bounding_box()) |
| 296 | |
| 297 | for arr in arrs: |
| 298 | if about_point is None: |
| 299 | arr[:] = func(arr) |
| 300 | else: |
| 301 | arr[:] = func(arr - about_point) + about_point |
| 302 | |
| 303 | if not works_on_bounding_box: |
| 304 | self.refresh_bounding_box(recurse_down=True) |
| 305 | else: |
| 306 | for parent in self.parents: |
| 307 | parent.refresh_bounding_box() |
| 308 | return self |
| 309 | |
| 310 | # Others related to points |
| 311 |
no test coverage detected