C# Point to polyline distance with math

What math is used to calculate the distance from a point to a polyline in C# :thinking:
Hmmmmm…

:thinking: https://en.wikipedia.org/wiki/Altitude_(triangle)
Doing this but than for multiple segments of the polyline?
Is it possible to do it not iterate-able?

What about interpolated ones :thinking:

It is mysteriously moving without any disturbances of too much C# code (I used that component, I did not code that) :mage: :magnet: :star2: