@@ -0,0 +1,1288 @@
+# Copyright 2020 The Kubric Authors%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#    https://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Aimport numpy as np%0Aimport sklearn.utils%0A%0A%0Adef mm3hash(name):%0A  %22%22%22 Compute the uint32 hash that Blenders Cryptomatte uses.%0A  https://github.com/Psyop/Cryptomatte/blob/master/specification/cryptomatte_specification.pdf%0A  %22%22%22%0A  hash_32 = sklearn.utils.murmurhash3_32(name, positive=True)%0A  exp = hash_32 %3E%3E 23 & 255%0A  if (exp == 0) or (exp == 255):%0A    hash_32 %5E= 1 %3C%3C 23%0A  return hash_32%0A%0A%0Adef random_rotation(rnd=np.random.RandomState()):%0A  %22%22%22 Compute a random rotation as a quaternion that is uniform over orientations.%22%22%22%0A%0A  z = 2%0A  while z %3E 1:%0A    x, y = rnd.rand(2)%0A    z = x*x + y*y%0A%0A  w = 2%0A  while w %3E 1:%0A    u, v = rnd.rand(2)%0A    w = u*u + v*v%0A%0A  s = np.sqrt((1-z) / w)%0A  return x, y, s*u, s*v%0A

add a method for sampling random rotations