points.py 文件源码

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

项目:pyhiro 作者: wanweiwei07 项目源码 文件源码
def transform_points(points, matrix, translate=True):
    '''
    Returns points, rotated by transformation matrix 
    If points is (n,2), matrix must be (3,3)
    if points is (n,3), matrix must be (4,4)

    Arguments
    ----------
    points: (n, 2|3) set of points
    matrix: (3|4, 3|4) rotation matrix
    translate: boolean, apply translation from matrix or not

    '''
    points = np.asanyarray(points)
    dimension   = points.shape[1]
    column      = np.zeros(len(points)) + int(bool(translate))
    stacked     = np.column_stack((points, column))
    transformed = np.dot(matrix, stacked.T).T[:,0:dimension]
    return transformed
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号