geom.py 文件源码

python
阅读 54 收藏 0 点赞 0 评论 0

项目:l1dbproto 作者: lsst-dm 项目源码 文件源码
def rotation_matrix(a, b):
    """
    Create rotation matrix to rotate vector a into b.

    After http://math.stackexchange.com/a/476311

    Parameters
    ----------
    a,b
        xyz-vectors
    """

    v = np.cross(a, b)
    sin = np.linalg.norm(v)
    if sin == 0:
        return np.identity(3)
    cos = np.vdot(a, b)
    vx = np.mat([[0, -v[2], v[1]], [v[2], 0., -v[0]], [-v[1], v[0], 0.]])

    R = np.identity(3) + vx + vx * vx * (1 - cos) / (sin ** 2)

    return R
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号