How do I do this in .net topology suite or jts? Please see image.
Any other library that can I run on .NET is fine, or even a general algorithm if there is no option.
For example this answer is only for endpoints:
Check if line crosses a polygon
Right now I'm randomly experimenting and if i intersect and check
if (intersection.Boundary.ToString().Contains("EMPTY"))
it seems to work, but… yeah no idea why or if it's all cases.
Best Answer
From your drawings and the comments I think your requirements are that the line
Just combine the requirements. This is the method using JTS that should answer your question: