# Distance of a face with Geometry Nodes

I have the 'Ground' object which is split into many faces to give relief.

I can calculate the distance between the wheel and the ground.

Now I would like to calculate the distance to the ground face closest to the wheel.

How can I select a specific face of the floor to calculate its distance?

My Geomtry Nodes

First of all, you can do it with the Sample Nearest Surface node and the setup is like this, you set the Sample Nearest Surface node to Vector. The Geometry you want to sample from is the "Ground" object, you add a Position node and plug it into the Value input to retrieve the surface positions. Then you need the Location of the "Wheel" object as Sample Position. Now this might not result in correct values, I'll explain below:

Just the way it is now is not yet working correctly and needs to be changed. The problem is you can either use Original or Relative position of the "Wheel" object, but it is off the world center. What you need to change depends on how you want to go on:

1. You have hidden the original wheel object and recreate it in Geometry Nodes from the Object Info node. This way you have to either move the "Ground" or the GN object "Main" to change the wheel's position over the surface. In this case you have to

• reset the original wheel to the world origin by unhiding it end clearing the location with Alt+G

Now you can hide the original wheel again and either move the "Main" object or the "Ground" to change the distance (and show the value over the wheel). This way you can leave the nodetree as I showed above.

2. Or you want to unhide the original wheel and have the ability to move this instead. In this case

• disconnect the Object Info node from the Join Geometry node (which you don't need then anymore)
• switch the Object Info node from Original to Relative

Now you can move the wheel (or the "Ground") outside of Geometry Nodes and leave the "Main" object stationary to calculate the distance (and show the value always in the same place). To do it this way, change the nodetree like this:

• Thanks Gordon for your extended explanation. It was really usefull to understand how to do it. :) May 16, 2023 at 20:04

you can do it with the raycast node like this:

NOTE: i calculate the "measuring" point as mean point from all vertices of your wheel with the attribute statistic node. Then i raycast downwards and get the distance to the "hit point" on the floor.

You measure just the origin point. So if you are just moving your origin point of your wheel, your distance won't change.

I hope this helps.

if you really want the "closest face", you can work with the proximity node.

• Thanks Chris for your solution- I don't know the Raycast node. May 16, 2023 at 20:06