After Effects distance between two points
Hate to spoil all your good work, but it's a lot easier to use the built-in length() function:

length(pointa, pointb)


e.g. 

length(thisComp.layer(1).position, thisComp.layer(2).position)


or

length([682, 617], [310, 342]); //raw vector values as an array
length(thisComp.layer("foo").anchorPoint, [310, 342]); //a spatial property and an array
length([123,456,789], [10,9,8]); //works in 3D too. 


It's in vector math in the expressions drop-down panel.