Download s3d_floorplan_eval/S3DLoader/poly_utils.py from Egrt/HEAT: direct link, hf CLI and curl.
- Browser
- Download file 520 Bytes
-
https://huggingface.co/spaces/Egrt/HEAT/resolve/main/s3d_floorplan_eval/S3DLoader/poly_utils.py
- Command line
-
hf download hf://spaces/Egrt/HEAT/s3d_floorplan_eval/S3DLoader/poly_utils.py
-
curl -L -o poly_utils.py https://huggingface.co/spaces/Egrt/HEAT/resolve/main/s3d_floorplan_eval/S3DLoader/poly_utils.py
520 Bytes
| import numpy as np | |
| def rotate_poly(poly, angle, flip_h): | |
| """ | |
| Rotate poly | |
| :param poly: | |
| :return: | |
| """ | |
| px, py = poly[:, 0], poly[:, 1] | |
| angle_rad = angle * np.pi / 180 | |
| qx = np.cos(angle_rad) * px - np.sin(angle_rad) * py | |
| qy = np.sin(angle_rad) * px + np.cos(angle_rad) * py | |
| if flip_h: | |
| qx = -qx | |
| rotated_poly = np.zeros_like(poly) | |
| rotated_poly[:, 0] = qx | |
| rotated_poly[:, 1] = qy | |
| # print("p", poly) | |
| # print("r", rotated_poly) | |
| return rotated_poly |