Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,625 Bytes
947767a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import os
import numpy as np
from requests import Response
def list_dirs(root_dir):
dirs_to_return = []
with os.scandir(root_dir) as entries:
for entry in entries:
if entry.is_dir():
dirs_to_return.append(entry.name)
return dirs_to_return
def rotate_x(angle_degrees: int, c2w: np.ndarray) -> np.ndarray:
angle_radians = np.radians(angle_degrees)
rotation_matrix = np.array(
[
[1, 0, 0, 0],
[0, np.cos(angle_radians), -np.sin(angle_radians), 0],
[0, np.sin(angle_radians), np.cos(angle_radians), 0],
[0, 0, 0, 1],
]
)
return c2w @ rotation_matrix
def rotate_y(angle_degrees: int, c2w: np.ndarray) -> np.ndarray:
angle_radians = np.radians(angle_degrees)
rotation_matrix = np.array(
[
[np.cos(angle_radians), 0, np.sin(angle_radians), 0],
[0, 1, 0, 0],
[-np.sin(angle_radians), 0, np.cos(angle_radians), 0],
[0, 0, 0, 1],
]
)
return c2w @ rotation_matrix
def rotate_z(angle_degrees: int, c2w: np.ndarray) -> np.ndarray:
angle_radians = np.radians(angle_degrees)
rotation_matrix = np.array(
[
[np.cos(angle_radians), -np.sin(angle_radians), 0, 0],
[np.sin(angle_radians), np.cos(angle_radians), 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1],
]
)
return c2w @ rotation_matrix
def get_status_code_and_reason(response: Response | None) -> str:
if response is None:
return ""
return f"{response.status_code} - {response.reason}"
|