简体   繁体   中英

How to generate a random N dimensional rotation matrix using Python?

Can I find a specific function in Numpy or Scipy to generate a random N dimensional rotation matrix (or orthogonal matrix)? I need to move a vector on an ND sphere to another random point on this sphere.

https://math.stackexchange.com/questions/442418/random-generation-of-rotation-matrices

This may answer your question, at least as far as the strategy goes. As far as I know, there is no standard or library function from numpy that will do precisely what you need. A myriad of computational strategies are presented there, but I would prefer an extension of the quaternion approach since it can preserve a uniform distribution, which is what I'm assuming you're after.

EDIT: My original answer stated "roughly uniform," whereas after a bit more research I found that the quaternion approach, when sampled from a uniform distribution, will in fact preserve a uniform distribution in the rotations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM