仿射变换

    xiaoxiao2021-04-12  33

    仿射变换含义

    仿射变换是指在几何中,一个向量空间(vector space)进行一次线性变换(linear transformation)并拼上一个平移(Translation )。所以,本质上仿射变换针对的是某一向量空间(当然该空间中的任一向量)。

    其矩阵表达形式(matrix formal)为:

    A控制旋转与缩放,b控制平移:

    我们使用Python语言对之进行演示:

    import numpy as np x = np.array((1, 2, 3)) b = np.ones(2) A = np.random.rand(2, 3) y1 = np.dot(A, x) + b # array([ 4.17327185, 4.0755495 ]) A_aug = np.hstack((A, b.reshape((-1, 1)))) A_aug = np.vstack((A_aug, np.hstack(np.zeros(3), 1).reshape((1, -1)))) y2 = np.dot(A_aug, np.hstack((x, 1)).reshape((-1, 1))) # array([[ 4.17327185], # [ 4.0755495 ], # [ 1. ]]) # 上述构造的方式仍稍显繁琐,这里再提供一种方式 A_aug = np.zeros((A.shape[0]+1, A.shape[1]+1)) A_aug[-1, -1] = 1 A_aug[:-1, :-1] = A A_aug[:-1, -1] = b np.dot(A_aug, np.hstack((x, 1)).reshape((-1, 1)))
    转载请注明原文地址: https://ju.6miu.com/read-667656.html

    最新回复(0)