create.py 文件源码

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

项目:Sverchok 作者: Sverchok 项目源码 文件源码
def rotation_matrix(theta, axis):
    """
    Return the rotation matrix associated with counterclockwise rotation about
    the given axis by theta radians.
    Adapted from
    http://stackoverflow.com/questions/6802577/python-rotation-of-3d-vector
    """
    axis = axis[:3]
    axis = axis/math.sqrt(np.dot(axis, axis))
    a = math.cos(theta/2.0)
    b, c, d = -axis*math.sin(theta/2.0)
    aa, bb, cc, dd = a*a, b*b, c*c, d*d
    bc, ad, ac, ab, bd, cd = b*c, a*d, a*c, a*b, b*d, c*d
    return np.array([[aa+bb-cc-dd, 2*(bc+ad), 2*(bd-ac), 0],
                     [2*(bc-ad), aa+cc-bb-dd, 2*(cd+ab), 0],
                     [2*(bd+ac), 2*(cd-ab), aa+dd-bb-cc, 0],
                     [0,         0,         0,           1]])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号