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

Function rotate_normalmap_by_angle

scripts/utils.py:98–106  ·  view source on GitHub ↗

rotate along y-axis normal_map: np.array, shape=(H, W, 3) in [-1, 1] angle: float, in degree

(normal_map: np.ndarray, angle: float)

Source from the content-addressed store, hash-verified

96 return mesh.verts_list()[0], mesh.faces_list()[0], mesh.textures.verts_features_packed()
97
98def rotate_normalmap_by_angle(normal_map: np.ndarray, angle: float):
99 """
100 rotate along y-axis
101 normal_map: np.array, shape=(H, W, 3) in [-1, 1]
102 angle: float, in degree
103 """
104 angle = angle / 180 * np.pi
105 R = np.array([[np.cos(angle), 0, np.sin(angle)], [0, 1, 0], [-np.sin(angle), 0, np.cos(angle)]])
106 return np.dot(normal_map.reshape(-1, 3), R.T).reshape(normal_map.shape)
107
108# from view coord to front view world coord
109def rotate_normals(normal_pils, return_types='np', rotate_direction=1) -> np.ndarray: # [0, 255]

Callers 2

rotate_normalsFunction · 0.85
change_bkgd_to_normalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected