Calculating distance between XYZ coordinates

Hannes Arvid Andersson's icon

Hi folks,

I am receiving position trackings from sensors in the form of XYZ coordinates, and I would like to calculate the distance between them to map that to some sound happenings, but I am not sure about the math to use.
I initially thought of adding up the differences between the Xs Ys & Zs, but then realised that is not going to work.

Any ideas on how to do it?
Or is there perhaps a max object that would do this for me?

Much appreciated!

11OLSEN's icon

Euclidean distance!

Hannes Arvid Andersson's icon

@11OLSEN

Ok, quick search on this concept seems to confirm that this could be a way to go, but I am afraid my math is not very advanced, do you mind giving me some pointers about how to do that?

11OLSEN's icon

11euclidean_distance.maxpat
text/plain 7.00 KB
Here it is with 4 dimensions but you can simply change the list length

Hannes Arvid Andersson's icon
Marijn C's icon

Hey this is great,

Any idea how to get the angle between the two points for azimuth and elevation?

Roman Thilenius's icon

cartopol/poltocar?

Oni Shogun's icon

euclidian dist

vector1 vector2
| |
vexpr pow($f1-$f2,2)
|
expr sqrt($f1+$f2+$f3)
|
distance