# Is it possible to calculate the distance between the vertices of two objects in Geometry Nodes?

If I have two cubes (with the same vertices and indices) and they are animated to move on their own paths, can I calculate the distance between v0 of one cube and v0 of the other cube to drive something like vertex color of the original for v0? Ideally I'd like to do it for all 8 vertices by indexed pair (v0 to v0, v1 to v1, etc...).

The only thing I could think of was to capture the Position Attribute of two Object Info nodes and then do a Vector Math Distance on those. This seems to just result in the distance of the vertices from one cube to 0,0,0. I get the Position node is based on the geometry downstream, but I feel like that is limiting in this case as I want two uniques sets of geometry to be compared.

It is super simple in Animation Nodes. Just use some mesh input nodes for each object, grab the Vertex locations and then calculate the list of distances. Would love to have that same simple functionality in Geometry Nodes.

UPDATED Example with Solution

Based on the selected answer from Robin Betts I'd like to share an example of how I was planning on using the feature. Here's a simple example of transferring the 'Distance' between vertices of two frame offset Alembics (should probably work on rigs and FBX files as well) over by an attribute to the Shader. Then I just ran the attribute through a ColorRamp to give shading based on the 'Speed' of the individual vertices. I left the offset copy of the Alembic in the scene in wireframe view if that helps to see where the colors are coming from.

• Great stuff! I guess if that was a Vector Subtract instead of Distance , (in World Space,) you could encode direction, too, to get a vector velocity? You could always recover the float speed from that in the shader, if you wanted to dispense with some of the information. Commented Dec 21, 2021 at 8:24
• Good idea, the door is open now to explore other mesh compare operations. Next is to replicate mesh tension in GN (compare face area to an original static mesh) that has been available in AN and other scripts/addons. github.com/harisreedhar/an_bluefox_extension#mesh-nodes blenderartists.org/t/revised-mesh-tension-add-on/1239091 Commented Dec 21, 2021 at 19:15

You can Transfer the vertex position, (in the modified object's space) from the target object to the modified object by Index, and subtract it in place, as an attribute of the modified object:
This shows the view of the attribute of the modified object (here, output as Vertex Distance,) against actual example measurements on vertex 1 and vertex 6: