# How can find the distance between two 3D objects in a 3D space?

**URL:** https://discourse.processing.org/t/how-can-find-the-distance-between-two-3d-objects-in-a-3d-space/37222
**Category:** Processing
**Created:** [May 30, 2022, 11:06am UTC](https://discourse.processing.org/t/how-can-find-the-distance-between-two-3d-objects-in-a-3d-space/37222 "2022-05-30T11:06:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ell](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@ell](https://discourse.processing.org/u/ell)
#### Post date: [May 30, 2022, 11:06am UTC](https://discourse.processing.org/t/how-can-find-the-distance-between-two-3d-objects-in-a-3d-space/37222/1 "2022-05-30T11:06:14Z")

</div>

Hello genius!  
I’m a beginner and I need your help.  
How can I find the distance between two 3D objects in a 3D space?

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [May 30, 2022, 11:26am UTC](https://discourse.processing.org/t/how-can-find-the-distance-between-two-3d-objects-in-a-3d-space/37222/2 "2022-05-30T11:26:14Z")

</div>

Hi,

you can also use [dist](https://processing.org/reference/dist_.html) or [PVector.dist](https://processing.org/reference/PVector_dist_.html) like in 2D for 3D coordinates.

Cheers  
— mnse

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [May 30, 2022, 12:09pm UTC](https://discourse.processing.org/t/how-can-find-the-distance-between-two-3d-objects-in-a-3d-space/37222/3 "2022-05-30T12:09:06Z")

</div>

Hello,

In addition to the helper functions it is good to know the math under the hood:

> **[Distance between 3D Points](https://www.engineeringtoolbox.com/distance-relationship-between-two-points-d_1854.html)**
>
> Distance between two points in a three dimension x, y and z coordinate system - online calculator.

Processing source for _dist()_ function:  
[https://github.com/processing/processing4/blob/master/core/src/processing/core/PApplet.java#L4750](https://github.com/processing/processing4/blob/master/core/src/processing/core/PApplet.java#L4750)

Give it a moment to open and find the line! Slow here for me in Google Chrome.

The PVector one is in here:  
[https://github.com/processing/processing4/blob/master/core/src/processing/core/PVector.java](https://github.com/processing/processing4/blob/master/core/src/processing/core/PVector.java)

`:)`
