MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / random_rfss

Function random_rfss

numericals.py:1276–1294  ·  view source on GitHub ↗

Random rotate-flip-scale-shift a point cloud.

(*points: list[Point])

Source from the content-addressed store, hash-verified

1274
1275
1276def 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
1297def reduce(

Callers 13

sketch_eq_quadrangleFunction · 0.85
sketch_eq_trapezoidFunction · 0.85
sketch_eqdia_quadrangleFunction · 0.85
sketch_isosFunction · 0.85
sketch_pentagonFunction · 0.85
sketch_quadrangleFunction · 0.85
sketch_r_trapezoidFunction · 0.85
sketch_r_triangleFunction · 0.85
sketch_rectangleFunction · 0.85
sketch_risosFunction · 0.85
sketch_isquareFunction · 0.85
sketch_trapezoidFunction · 0.85

Calls 4

cosMethod · 0.80
rotateMethod · 0.80
flipMethod · 0.80
PointClass · 0.70

Tested by

no test coverage detected