# Distance from point to segment

**URL:** <https://discourse.slicer.org/t/distance-from-point-to-segment/26277>\
**Category:** Support\
**Tags:** segmentation, dicom, python\
**Created:** [November 17, 2022, 9:09am UTC](https://discourse.slicer.org/t/distance-from-point-to-segment/26277 "2022-11-17T09:09:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NILV](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@NILV](https://discourse.slicer.org/u/NILV)\
**Post date:** [November 17, 2022, 9:09am UTC](https://discourse.slicer.org/t/distance-from-point-to-segment/26277/1 "2022-11-17T09:09:38Z")

</div>

Hello everyone.  
I have some problems when using the slicer.  
In my project,I want to get the distance from the center of GTV to the lung boundary,which means the distance to the apex of lung in SI direction and the distance to the chest wall in LR,AP direction.  
Now the problems is I can not markup the point I want.For example,in this image, I want get the two distances by scripts.

 ![1668676163342](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/f/9f95f0bc4a81306fef90ba6c1cf44a312f913463.png)

I checked all the slicer extension but no one can do that.So I wondeing if anyone can help me to solve it!  
Thanks a lot!

---

<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:** [December 1, 2022, 7:10am UTC](https://discourse.slicer.org/t/distance-from-point-to-segment/26277/2 "2022-12-01T07:10:58Z")

</div>

You can get the intersection of a line (starting point is the center, endpoint is a point far away in the desired direction) and a mesh ([obtained from the segment](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-a-representation-of-a-segment)) and use `IntersectWithLine` method of a `vtkModifiedBSPTree` locator to get the intersection point.
