MCPcopy Create free account
hub / github.com/AiuniAI/Unique3D / rotate

Function rotate

scripts/normal_to_height_map.py:66–81  ·  view source on GitHub ↗
(matrix: np.ndarray, angle: float)

Source from the content-addressed store, hash-verified

64
65
66def rotate(matrix: np.ndarray, angle: float) -> np.ndarray:
67 h, w = matrix.shape[:2]
68 center = (w / 2, h / 2)
69
70 rotation_matrix = cv.getRotationMatrix2D(center, angle, 1.0)
71 corners = cv.transform(
72 np.array([[[0, 0], [w, 0], [w, h], [0, h]]]), rotation_matrix
73 )[0]
74
75 _, _, w, h = cv.boundingRect(corners)
76
77 rotation_matrix[0, 2] += w / 2 - center[0]
78 rotation_matrix[1, 2] += h / 2 - center[1]
79 result = cv.warpAffine(matrix, rotation_matrix, (w, h), flags=cv.INTER_LINEAR)
80
81 return result
82
83
84def rotate_vector_field_normals(normals: np.ndarray, angle: float) -> np.ndarray:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected