# Distance between point and plane

**URL:** <https://discourse.slicer.org/t/distance-between-point-and-plane/22091>\
**Category:** Support\
**Created:** [February 21, 2022, 5:15pm UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091 "2022-02-21T17:15:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Annett](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@Annett](https://discourse.slicer.org/u/Annett)\
**Post date:** [February 21, 2022, 5:15pm UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/1 "2022-02-21T17:15:43Z")

</div>

how can i calculate the distance between a point and a plane?  
the segment that calculates the distance must be perpendicular to the plane and I’m not able to create it perpendicularly…  
Thanks!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [February 21, 2022, 5:25pm UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/2 "2022-02-21T17:25:39Z")

</div>

A very simple method is to transform the point in the plane’s coordinates system as it is shown in this [example in the script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#project-a-line-to-a-plane). The distance from the plane is the third coordinate of the point in the plane coordinate system (`point_Plane[2]`).

---

<div class="post-metadata">

**Author:** ![anasmh101](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anasmh101/32/80621_2.png) [@anasmh101](https://discourse.slicer.org/u/anasmh101)\
**Post date:** [September 29, 2024, 4:37am UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/3 "2024-09-29T04:37:27Z")

</div>

hi , could you please elaborate more on this , after copying the script and past it in the python console, how can I get the measurement? how can I define the point and the plane that I want to measure the distance between them ?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 29, 2024, 11:47am UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/4 "2024-09-29T11:47:35Z")

</div>

> [@anasmh101](#):
>
> how can I get the measuremen

```python
print(point_Plane[2])

```

> [@anasmh101](#):
>
> how can I define the point and the plane

You can place a point and plane markup using Markups module. Let us know if you have difficulty figuring out how to do it.

---

<div class="post-metadata">

**Author:** ![anasmh101](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anasmh101/32/80621_2.png) [@anasmh101](https://discourse.slicer.org/u/anasmh101)\
**Post date:** [October 1, 2024, 4:47am UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/5 "2024-10-01T04:47:44Z")

</div>

Thank you for your reply, but I still do not know how to apply this script on python console , so for example; in markups module, I establish a Plane named P and a Point named M . So the script on python console would be " print(point M \_Plane[P]) " ? is this the way to deal with python script ?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 1, 2024, 1:54pm UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/6 "2024-10-01T13:54:07Z")

</div>

You can see that the point list in the example is called `P`, so you either need to rename your point list in to `P` or change the name in the code from `P` to the actual name of your point list.

I added a code snippet to the script repository that prints the points-to-plane distances (`point_Plane[2]`) - see [here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#measure-distances-of-points-from-a-plane).

---

<div class="post-metadata">

**Author:** ![anasmh101](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anasmh101/32/80621_2.png) [@anasmh101](https://discourse.slicer.org/u/anasmh101)\
**Post date:** [October 2, 2024, 1:00pm UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/7 "2024-10-02T13:00:53Z")

</div>

Thank you so much , it works perfectly, appreciate your help.

May I ask , most of the time I make planes by defining points on specific anatomic land mark by " markups module" then use “Angle planes” module to construct the plane, is there a code snippet to do the same calculations as if the plane is constructed by " Markups Module "?

I tried the code snippet you added on planes constructed by " Angle planes" module, but it did not work

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 2, 2024, 1:16pm UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/8 "2024-10-02T13:16:52Z")

</div>

You can place a plane on anatomical landmarks by fitting it to points. It is available in Markups module / Plane settings / Type → Plane fit.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/e/ee71cb48b8e7d1b0e026b03bc46b0e2817f40dcc.png)

---

<div class="post-metadata">

**Author:** ![anasmh101](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anasmh101/32/80621_2.png) [@anasmh101](https://discourse.slicer.org/u/anasmh101)\
**Post date:** [October 2, 2024, 1:36pm UTC](https://discourse.slicer.org/t/distance-between-point-and-plane/22091/9 "2024-10-02T13:36:24Z")

</div>

Thank you so much , it works very well
