Random rotate-flip-scale-shift a point cloud.
(*points: list[Point])
| 1274 | |
| 1275 | |
| 1276 | def random_rfss(*points: list[Point]) -> list[Point]: |
| 1277 | """Random rotate-flip-scale-shift a point cloud.""" |
| 1278 | # center point cloud. |
| 1279 | average = sum(points, Point(0.0, 0.0)) * (1.0 / len(points)) |
| 1280 | points = [p - average for p in points] |
| 1281 | |
| 1282 | # rotate |
| 1283 | ang = unif(0.0, 2 * np.pi) |
| 1284 | sin, cos = np.sin(ang), np.cos(ang) |
| 1285 | # scale and shift |
| 1286 | scale = unif(0.5, 2.0) |
| 1287 | shift = Point(unif(-1, 1), unif(-1, 1)) |
| 1288 | points = [p.rotate(sin, cos) * scale + shift for p in points] |
| 1289 | |
| 1290 | # randomly flip |
| 1291 | if np.random.rand() < 0.5: |
| 1292 | points = [p.flip() for p in points] |
| 1293 | |
| 1294 | return points |
| 1295 | |
| 1296 | |
| 1297 | def reduce( |
no test coverage detected