I want to get the shortest distance from a line to an attractor/point node in Anylogic. In all the available references, I found the function to calculate point to point distance. Is there any function/suggested way to calculate a line to point distance in Anylogic? (Please let me know if my question is not clear enough)
Asked
Active
Viewed 168 times
1 Answers
1
Best use a Path
element from the "Space Markup" library, not a Line
.
This allows you to call getNearestPoint
as below:

Benjamin
- 10,603
- 3
- 16
- 28
-
Thanks a lot Ben! I will try this one. – Tariq Oct 06 '20 at 06:36
-
Hi Ben! I have one additional question. I tried your method. You can see I need to put one point type "output". I am not sure, what point it is referring to. As I am giving my path markup & Xaxis, Yaxis values, can you please guide me what additional argument it is asking for? I am not getting the sense of Point out in the last part. Your help is greatly appreciated. Thanks. – Tariq Oct 07 '20 at 03:32
-
not sure tbh, try experimenting a little yourself to figure it out :) Might not be possible after all since this "getNearestPoint" method is designed for the parent class of NetworkMarkupElements... You may have to resort coding this yourself – Benjamin Oct 07 '20 at 08:17
-
1Thanks Ben! actually that problem was sorted out. For "type out" I referenced the endpoint of the path markup & it's working fine. – Tariq Oct 08 '20 at 05:44