简体   繁体   English

通过使用向量作为参考点来计算向量之间的角度:

[英]Calculating the Angle Between Vectors by using a vector as a reference point:

I have been trying to find a fast algorithm of calculating all the angle between n vectors that are of length x. 我一直在尝试找到一种快速算法来计算长度为x的n个向量之间的所有角度。 For example if x=3 and n=4, my data would look something like this: 例如,如果x = 3和n = 4,我的数据将如下所示:

A: [1,2,3] 答:[1,2,3]
B: [2,3,4] B:[2,3,4]
C: [...] C: [...]
D: [...] D:[...]

I was wondering is it acceptable to find the the angle between all of be vectors (A,B,C,D) with respect to some fix vector (ie X:[100,100,100,100]) and then the subtract the angles of (A,B,C,D) found with respect to that fixed value, to find the angle between all of them. 我想知道是否可以找到相对于某个固定向量(即X:[100,100,100,100])的所有向量(A,B,C,D)之间的夹角,然后减去(A,B的夹角,C,D)相对于该固定值找到,以找出所有固定值之间的夹角。 I want to do this because I would only have to compute the angle once and then I can subtract angles all of my vectors to find the different between them. 我想这样做是因为我只需要计算一次角度,然后我就可以减去所有矢量的角度来找出它们之间的差异。 In short, I want to know is it safe to make this assumption? 简而言之,我想知道做这个假设是否安全?

angle_between(A,B) == angle_between(A,X) - angle_between(B,X) angle_between(A,B)== angle_between(A,X)-angle_between(B,X)

and the angle_between function is the Cosine similarity. 而angle_between函数是余弦相似度。

That approach will only work for 2-D vectors. 该方法仅适用于二维矢量。 For higher dimensions any two vectors will define a hyperplane, and only if the third (reference) vector also lies within this hyperplane will your approach work. 对于更高的尺寸,任何两个向量都将定义一个超平面,并且只有第三个(参考)向量也位于该超平面内时,您的方法才有效。 Unfortunately instead of only calculating n angles and subtracting, in order to determine the angles between each pair of vectors you would have to calculate all n choose 2 of them. 不幸的是,为了确定每对向量之间的角度,您不仅要计算n角度并进行减法运算,还必须计算所有n choose 2向量中的n choose 2个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM