| File was renamed from src/slam/slam.py |
| | |
| | | import numpy as np |
| | | import os, sys |
| | | # add python path of src to sys.path |
| | | src_path = os.path.join(__file__, *(['..'] * 2)) |
| | | src_path = os.path.abspath(src_path) |
| | | sys.path.insert(0, src_path) |
| | | # # add python path of src to sys.path |
| | | # src_path = os.path.join(__file__, *(['..'] * 2)) |
| | | # src_path = os.path.abspath(src_path) |
| | | # sys.path.insert(0, src_path) |
| | | |
| | | from utils.tools import read_ply |
| | | from ..utils.tools import read_ply |
| | | from tqdm import tqdm |
| | | |
| | | |
| | |
| | | """ |
| | | |
| | | # 平移 |
| | | moved_data = current + np.array([x,y,z]) |
| | | moved_data = data + np.array([x,y,z]) |
| | | # 旋转 |
| | | rotation_matrix = get_rotation_matrix(-alpha,-beta,-gamma) |
| | | rotated_data = np.matmul(moved_data,rotation_matrix) |
| | |
| | | return rotated_data |
| | | |
| | | |
| | | def compose_ply(muti_ply_with_angle: list): |
| | | def merge_ply(muti_ply_with_angle: list): |
| | | |
| | | ply_nums = len(muti_ply_with_angle) |
| | | composed_ply_array = None |
| | | merged_ply_array = None |
| | | |
| | | print ("rotating the ply ...") |
| | | for i, ply_with_angle in enumerate(tqdm(muti_ply_with_angle)): |
| | |
| | | # np.matmul(rotation_matrix,ply.transpose()).transpose() == np.matmul(ply,rotation_matrix) |
| | | rotated_ply = np.matmul(ply,rotation_matrix) |
| | | if i == 0: |
| | | composed_ply_array = rotated_ply.copy() |
| | | merged_ply_array = rotated_ply.copy() |
| | | else: |
| | | composed_ply_array = np.concatenate((composed_ply_array,rotated_ply),axis= 0 ) |
| | | merged_ply_array = np.concatenate((merged_ply_array,rotated_ply),axis= 0 ) |
| | | |
| | | composed_ply_array = np.array(composed_ply_array).reshape(-1,3) |
| | | return composed_ply_array |
| | | merged_ply_array = np.array(merged_ply_array).reshape(-1,3) |
| | | return merged_ply_array |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | current = np.array([[1,1,1],[1,3,9],[4,8,5]]) |
| | | print(current) |
| | | target = transferTo(current,1,1,1,0,0,0,True) |
| | | print(target) |
| | | |
| | | |