# Geometry Nodes: How the nearest face/edge is found?

I created a cube, aligned with axes, going from world origin to 1;1;5, and moved vertex 0 to the nearest face:

The vertex moved to the center of the nearest face, described by vertices 0154. It moved $$\sqrt{0.5^2 + 2.5^2} = 2.55...$$.

If it instead moved to the center of the face described by vertices 0462, it would move much less, $$\sqrt{0.5^2 + 0.5^2} = 0.707...$$.

Apparently my understanding, that the nearest face is the face with the nearest center was wrong. But then what makes a face the nearest face?

• I guess you have applied the scale of the cube so that this is not the issue? Because if it was just a cube scaled on the Z axis, then I wouldn't even know what center should be preferred by this, as the centers of 0154, 0132 and 0264 would all be the same distance away. Jan 29, 2022 at 13:22
• @GordonBrinkmann the scale is applied, let me upload the file... Uploaded. Jan 29, 2022 at 13:23
• just a guess: the nearest vertex? or the average of all vertices distances? Jan 29, 2022 at 14:07
• Face that has nearest point. you have 3 since 0 nearest itself. so real q: how break tie. prob random. Jan 29, 2022 at 14:12
• @Chris the description says "using face and edge centers for distance computation" Jan 29, 2022 at 14:52

Thanks to Crantisz I think I finally understand:

The nearest face is the face built on an edge that is the nearest to the Source Position.

• not a face with the nearest center to s.p.
• not a face with the nearest vertex to s.p.
• not a face that could have a point on its surface closer to the s.p. than any possible point on any other face.

But what is the nearest edge then?

The nearest edge is an edge, on which you could place a point closer to the s.p. than any point you could place on any other edge.

• not an edge with the nearest center to s.p.
• not an edge with the nearest vertex to s.p.

Below I spawn an icosphere on the nearest edge to vertex #0:

Below I spawn an icosphere on the nearest face to vertex #0 (I positioned vert #0 to lay on the surface of the big face):

Now I stretch and move the small face along X, so neither its vertices nor centers of its edges are closer to s.p. than the top vertex (#2) of the big face) - and yet it still spawns the icosphere, because the top and bottom edges come closer to vert #0 than any other edge:

I think transfer attribute works in a slightly different way - it gets face nearest to face. This works only when you try to transfer data from face to face. I don't know how it works under the hood then you use vertexes instead of faces, but from my point of view, it doesn't have any sense. So I decided to convert face to points and then try to find the closest.

Now it works as expected:

UPD.

A, gotcha!

Look at this example:

Then you use faces as point, Blender gets the middle from faces connected to point. As you see this middle point much closer to one of the long faces

• The update doesn't make sense though 😜 Capture attribute is redundant there, and I don't get the explanation. But "Mesh to Points" as you used it in the first part is exactly what I should use to find the center of a face nearest by its center. Jan 29, 2022 at 15:30