【问题标题】:How to rotate a point cloud in xy plane?如何在 xy 平面上旋转点云?
【发布时间】:2020-08-19 13:19:41
【问题描述】:

我想将给定的点云旋转到 xy 平面。因此,我通过点云安装了一架飞机。这样,我想计算需要旋转以获得平面以及 xy 平面中的点云的角度。平面的中心位于原点。所以我需要绕 x 轴和 y 轴旋转。但我不确定如何继续。有任何想法吗?

到目前为止,这是我的代码:

def fitPlaneLTSQ(df):
    (rows, cols) = df.shape
    G = np.ones((rows, 3))
    G[:, 0] = df['X']
    G[:, 1] = df['Z']
    Z = df['Y']
    (a, b, c),resid,rank,s = np.linalg.lstsq(G, Z)
    normal = (a, b, -1)
    nn = np.linalg.norm(normal)
    normal = normal / nn
    return (c, normal)

#load data
data = pd.read_csv('data.csv', sep=';')

# calc middle of cloud
meanx = np.mean(data['X'])
meany = np.mean(data['Y'])
meanz = np.mean(data['Z'])

#translate cloud to orign
data['X'] = data['X'] - meanx
data['Y'] = data['Y'] - meany
data['Z'] = data['Z'] - meanz

#calc plane 
maxx = np.max(data['X'])
maxz = np.max(data['Z'])
minx = np.min(data['X'])
minz = np.min(data['Z'])

c, normal = fitPlaneLTSQ(data)
point = np.array([0.0, 0.0, c])
d = -point.dot(normal)

# compute needed points for plane plotting
xx, yy = np.meshgrid([minx, maxx], [minz, maxz])
z = (-normal[0]*xx - normal[1]*yy - d)*1. / normal[2]

【问题讨论】:

    标签: python numpy math geometry rotation


    【解决方案1】:

    我会说它是将点云平面的法线与 XY 平面的法线(即 Z 或 -Z)对齐的旋转。

    结帐here 了解有关如何执行此操作的数学,并结帐here 了解一些python 代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-13
      • 2012-06-23
      • 2022-01-12
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多