Get intersection point between 2 lines (4 vectors)

How can I get the intersection point between 2 lines which are represented by 4 vectors?

There is the node “Line/Plane intersection” and since I only need 2D intersection, I think I could just create a plane out of one of the lines, but there is not documentation about planes, and I really dont know how to create a plane.

3b8136dd0b.png

I guess W is Width, but what is X,Y,Z? If its a rotation, where do I set the location? If its a location, where do I set the rotation? I would really appreciate any help :slight_smile: Either how to do Line/Line intersection manually or how to use the Line/Plane intersection with just 2 lines…

I would say X/Y/Z is either World Location or the Width, Depth and height of the plane.

Hi John Alcatraz, you might remember me from the IRC channel. I tried to help you there, but as it turns out my solution was not correct. I’ve attached a blueprint containing a function that should contain a correct way of determining if there is an intersection between two given 2D lines. For good measure I’ve also included a screen-cap of the blueprint. For whatever reason, this site does not allow me to upload uasset files, so you will have to change the filetype back from .txt to .uasset before using it.
If you’re interested, the reference I used was the algorithm described on wikipedia: Wikipedia Article
Disclaimer: I haven’t actually tested it, so I can’t guarantee it will work.

Thanks, but would you explain me how to add a uasset file to a project? I cant import it, but just copying it into the project folder also doesn’t work ^^

Ok, problem was that I used 4.5.1, in 4.6 I can import it. But unfortunately your code seems to not work. It always return true, even if there cant be any collision between two lines.

Edit: I was wrong, it works. I just didn’t expected it to use lines which are infinite in every direction :slight_smile:

I’m currently making a simple plugin with a bunch of math-based functions that I use on my project which happens to include line to line intersection (both infinite and segments) so if you are interested and you know a bit C++ I can send you the functions, or you can wait until I release the plugin (I’m not entirely sure when I will do that, could be days, could be weeks… depending on how many more functions I decide to add :p)

At the moment I’m very happy with SomberSights solution, it works great and I also don’t know a bit C++ :o Anyway, math plugin sounds great, will probably help many people like me :slight_smile:

if anyone still needs this
This can be achieved by using

-> FMath::SegmentIntersection2D(SegmentStartA, SegmentEndA, SegmentStartB, SegmentEndB, out_IntersectionPoint);

You can also expose this function to bp through your custom C++ class

But remember those are segments not Lines!

1 Like