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

How do I translate the position of a moving point according to a reference point?

给定两个移动 points/particles,其位置在笛卡尔坐标 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: 据推测,这两个点彼此独立移动,因此它们的距离+方向不应该是恒定的。我的目标是检验这个假设:这些点是否会相互影响。
具体来说,我想计算点 2 相对于点 1 的密度,但为了使此计算有意义,我需要先固定点 1。希望这进一步澄清了问题。

如果您不熟悉线性代数,这可能有点神秘,但本质上您可以操纵向量来计算向量在两点之间的长度和圆柱旋转。它会是这样的:

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])))