如何根据参考点平移运动点的位置?

问题描述 投票:0回答:1

给出给定的波纹管,其两个移动点/粒子的笛卡尔坐标x,y,z随时间变化,我如何定心其中一个点并计算第二点的最终位置,同时保持它们的相对距离和方向常数?

# Given the absolute positions of point 1 (p1) and point 2 (p2): 
p1 = [
    [7.74, 9.48, 9.61],
    [7.02, 8.83, 9.42],
    [7.91, 9.08, 9.56],
    [8.61, 8.92, 9.50],
    [8.87, 9.35, 9.63],
    [7.77, 9.83, 9.86]
]

p2 = [
    [7.90, 10.48, 10.2],
    [8.30, 10.74, 9.59],
    [8.23, 10.24, 9.86],
    [8.15, 10.42, 9.91],
    [8.05, 10.44, 9.92],
    [8.4, 10.78, 10.04]
]

# Center p1. It does not necessarily have to be at (0, 0, 0). 
p1 = [
    [0, 0, 0], 
    [0, 0, 0], 
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0], 
    [0, 0, 0]
]

# Translate p2 so its relative position (distance & orientation) relative to p1 remains constant. 
p2 = []

直觉上,我会尝试查找转换的平移和旋转矩阵。我查看了scipy.spatial,但找不到解决问题的方法(至少我能理解)。

我将如何解决这个问题?

编辑1:据推测,两个点彼此独立地移动,因此它们的距离和方向不应恒定。我的目标是检验这种假设:这些点彼此之间是否有影响?具体来说,我想计算相对于点1的点2的密度,但是为了使计算有意义,我需要首先固定点1。希望这可以进一步澄清问题。

python numpy scipy linear-algebra scipy-spatial
1个回答
0
投票
如果您不熟悉线性代数,这可能有点神秘,但从本质上讲,您可以操纵向量以计算两点之间向量的长度和圆柱旋转。它会像这样:

import numpy as np from scipy import linalg p1 = [ [7.74, 9.48, 9.61], [7.02, 8.83, 9.42], [7.91, 9.08, 9.56], [8.61, 8.92, 9.50], [8.87, 9.35, 9.63], [7.77, 9.83, 9.86] ] p2 = [ [7.90, 10.48, 10.2], [8.30, 10.74, 9.59], [8.23, 10.24, 9.86], [8.15, 10.42, 9.91], [8.05, 10.44, 9.92], [8.4, 10.78, 10.04] ] # Transform lists to arrays a1, a2 = np.array(p1), np.array(p2) # Get vector from p1 to p2 v = a2 - a1 # Get the norm of all vectors p1p2, i.e. the distance between p1 and p2 n = linalg.norm(v, axis=1) # Normalize the vectors if need be unit_v = v / n[:, None] # Normalize the vectors in xy plane unit_v_xy = (v / linalg.norm(v[:, 0:2], axis=1)[:, None])[:, 0:2] # Get angles modulo pi in xy plane xy_angles = np.column_stack((np.arccos(unit_v_xy[:, 0]), np.arcsin(unit_v_xy[:, 1]))) # Get pitch angle, i.e. angle between vector and z axis pitch_angles = np.arccos(np.dot(unit_v, np.array([0, 0, 1])))

© www.soinside.com 2019 - 2024. All rights reserved.