code: def rotmat2qvec(R):
      Rxx, Ryx, Rzx, Rxy, Ryy, Rzy, Rxz, Ryz, Rzz = R.flat
      K = (
          np.array(
              [
                  [Rxx - Ryy - Rzz, 0, 0, 0],
                  [Ryx + Rxy, Ryy - Rxx - Rzz, 0, 0],
                  [Rzx + Rxz, Rzy + Ryz, Rzz - Rxx - Ryy, 0],
                  [Ryz - Rzy, Rzx - Rxz, Rxy - Ryx, Rxx + Ryy + Rzz],
              ]
          )
          / 3.0
      )
      eigvals, eigvecs = np.linalg.eigh(K)
      qvec = eigvecs[[3, 0, 1, 2], np.argmax(eigvals)]
      if qvec[0] < 0:
          qvec *= -1
      return qvec
  
file_path: gaussian-splatting/scene/colmap_loader.py
imports: import numpy
  import collections
  import struct
label_desc: Use image node_id 2 for calling a global function with example usage: rotmat2qvec(R) and returns: qvec