# How to find the projection or vertical foot of a point on a line?

**URL:** <https://discourse.slicer.org/t/how-to-find-the-projection-or-vertical-foot-of-a-point-on-a-line/22323>\
**Category:** Development\
**Tags:** python\
**Created:** [March 5, 2022, 10:29am UTC](https://discourse.slicer.org/t/how-to-find-the-projection-or-vertical-foot-of-a-point-on-a-line/22323 "2022-03-05T10:29:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [March 5, 2022, 10:29am UTC](https://discourse.slicer.org/t/how-to-find-the-projection-or-vertical-foot-of-a-point-on-a-line/22323/1 "2022-03-05T10:29:04Z")

</div>

How to find the projection or vertical foot of a point on a line?  
by python

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [March 5, 2022, 11:40am UTC](https://discourse.slicer.org/t/how-to-find-the-projection-or-vertical-foot-of-a-point-on-a-line/22323/2 "2022-03-05T11:40:47Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/6/569493686a501452726b08c92aab48b130a9ab06.png)

好吧, 这其实是个简单的几何问题如图:  
可以先求出PA和PO\[1\]的长度,然后用勾股定理求出AO的长度,再用[Helper.p2pexLine()](https://github.com/jumbojing/PedicleScrewSimulator-1/blob/fda7d17841cb6b1a5dcb788fd8555f469010827b/PedicleScrewSimulatorWizard/Helper.py#L178-L198), 就可以求出来了. 方法有点笨…不知道谁还有更好的方法呢?

> Well, this is actually a simple geometric problem as shown in the figure: You can first find the lengths of PA and PO[1], then use the Pythagorean theorem to find the length of AO, and then use Helper.p2pexLine(), you can find it . The method is a bit stupid…do not know who has a better method?

* * *

1. [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#measure-distances-of-points-from-a-line)
