# comp.graphics.algorithms

## Subject: Re: nearest neighbour of a point

I was wondering if I could use some method that uses vectors & dot
products.

So, say we have 3D points:
a = {x1, y1, z1}
b = {x2, y2, z2}

The distance between a & b is given by: (x1-x2)^2 + (y1-y2)^2 +
(z1-z2)^2, which on expanding gives:
x1*x1 + x2*x2 - 2*x1*x2 + y1*y1 + y2*y2 - 2*y1*y2 + z1*z1 + z2*z2 -
2*z1*z2

I can always pre-compute x1*x1, x2*x2, y1*y1, .... and so on.
However, I can not pre-compute x1*x2, y1*y2, .... and so on.

But, I do realize that x1*x2+y1*y2+z1*z2 is the dot product of the 2
vectors. So, is there any way I can compute the dot product vector
efficiently. Again, if I have the cosine of the angle between them, the
dot product would be trivial to implement.

This brings me to another question:
What is the significance of THETA(the angle in the dot product
expression) in n-dimensions.
If in n-dimensions, 2 vectors have angles T1 & T2 from a reference
vector, say: {1, 1, 1}, then can we perform addition & subtraction on
the 2 angles? And say that the 2 vectors are separated by an angle of
either T1+T2 or abs(T1-T2)?