pynbody.util.random_rotation_matrix

pynbody.util.random_rotation_matrix#

pynbody.util.random_rotation_matrix()[source]#

Return a random rotation matrix (Haar measure for 3x3 case), using fast algorithm from Graphics Gems III

Returns:

A 3x3 rotation matrix

Return type:

array-like

Notes

This is a Python implementation of the algorithm from Graphics Gems III, by Ken Shoemake. The original code was available at http://tog.acm.org/resources/GraphicsGems/gemsiii/rand_rotation.c, but was removed. An archived version is available at https://web.archive.org/web/20120621201232/http://tog.acm.org/resources/GraphicsGems/gemsiii/rand_rotation.c