N-dimensional geometric proximity - Grin with cat attached — LiveJournal
N-dimensional geometric proximity | Sep. 8th, 2005 02:46 pm | |
---|---|---|
For reasons likely to bore, I need to write an algorithm that includes finding the distance between two points in an N-dimensional geometric phase space. Now I know that in 2D the distance from x1,y1 to x2,y2 is sqrt((x1-x2)^2 + (y1-y2)^2), but all the maths they failed to teach me at Uni has drained away, meaning I can't remember the algorithm for higher dimensions. I have a vague memory that the 3D equivalent should be sqrt((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2). Is that right or do I need to deal in higher powers? Is it always square root(sum of squares)? | ||
Yes, that's right.
Yes. You can prove it iteratively a dimension at a time, unless I'm very much mistaken.
Indeed -- X is the distance you have in your "N dimensional space" and Y is the distance in your new orthoganal dimension.
(x^2 + y^2) ^ (1/2) is your new euclidean distance in N+1 dimensions giving the general formula
(\sum_{i=1}^n x_i ^ 2) ^ (1/2)
where n is the number of orthogonal dimensions and x_i is the distance in the ith dimension.
(x^2 + y^2) ^ (1/2) is your new euclidean distance in N+1 dimensions giving the general formula
(\sum_{i=1}^n x_i ^ 2) ^ (1/2)
where n is the number of orthogonal dimensions and x_i is the distance in the ith dimension.
From: bondagewoodelf Date: September 8th, 2005 - 02:06 pm (Link) |
You are correct! Unless the space is curved, but then 'distance' means something different.
Date: September 8th, 2005 - 01:54 pm (Link)