비행기의 점과 선을 처리하는 방법에 관해서는 시프 팅 포인트와 선으로 투영되는 점에 관해서는 PCA, 에 대한 질문이 많지 않습니다. 은 여기 (이것의 기초를 들어, SO questions/tagged/2d+geometry, 통해보고하거나 해당 태그에 새로운 질문을 부탁드립니다.) 를 그 기초하지 않고, 그리고 약간의 파이썬이나 matlab에, 이 작은 파이썬 프로그램은 아무 의미, 하지 않습니다하지만 어쨌든 :
from __future__ import division
import numpy as np # http://www.numpy.org/
def pcabox(Pointcloud, Pca1, Pca2):
""" Lo1, Hi1, Lo2, Hi2 = pcabox(Pointcloud, Pca1, Pca2)
In: Pointcloud: an N x 2 array of points
In: Pca1, Pca2: unit vectors at right angles, from PCA
Out: Lo1, Hi1, Lo2, Hi2: midpoints of the sides of a bounding box
"""
# convert inputs to numpy arrays (if they aren't already) --
Pointcloud = np.asarray(Pointcloud)
Pca1 = np.asarray(pca1)
Pca2 = np.asarray(pca2)
# check N x 2 --
assert Pointcloud.ndim == 2 and Pointcloud.shape[1] == 2, Pointcloud.shape
C = np.mean(Pointcloud, axis=0) # the centre of all the points
Pointcloud = Pointcloud - C # shift the cloud to be centred at [0 0]
# distances along the long axis t * Pca1 --
Dist1 = np.dot(Pointcloud, Pca1)
Lo1 = Dist1.min() * Pca1
Hi1 = Dist1.max() * Pca1
# and along the short axis t * Pca2 --
Dist2 = np.dot(Pointcloud, Pca2)
Lo2 = Dist2.min() * Pca2
Hi2 = Dist2.max() * Pca2
return [Lo1, Hi1, Lo2, Hi2] + C # 4 points
나는 그가 PCL (pointcloud 라이브러리)을 사용하고 있으며 대답은 pcl 클래스/기능을 사용해야한다고 생각합니다. – NKN