Line Segment Intersection

preview_player
Показать описание
Understanding the formula for computing line segment intersection.
- I forget to mention that you need to check the value of t1 and t2 are between 0 and 1.
- Thanks to @gi4nnni for pointing out that at 4:11, I the bottom cross product is wrong, -ABy * ACx + ABx * ACy should be AB x AC

Рекомендации по теме
Комментарии
Автор

Good explanation. Thanks!
P.S. For everyone wandering how on 3:17 this formula is appeared. This is the definition formula of 2x2 matrix Inverse. Determinant (number) multiply by reorganized matrix. Determinant formula is a1b2 - a2b1 which is exactly the 2d cross product

Re_murr
Автор

I've been searching about this for hours and your video was the one that actually explains what's going on. Thanks :)

Andre-LA
Автор

Came from radu's video and came and met this thanks guys for doing a great job

onlychrist
Автор

Hi, thanks for this!
Just so you know, I've linked to this video in my most recent one (in the description) because I think you do a really good job!

Radu
Автор

This channel deserves 1 million subscribers and more! Excellent explanation and excellent (very neat) coding!

___dp
Автор

I really wish you wouldn't have fast forwarded parts. It made things harder to follow.

versacebroccoli
Автор

thanks for starting the video straight to the point

Roule_n_Scratche
Автор

This will help me a lot with my 2D game pathfinding implementation! Thanks a lot!

legendguitargamer
Автор

Thanks Nick. I hope you could clarify the following

At 2:05, doesn't that equation mean vector OB = vector OD, where O is a point at the origin. I can't get my head around how can you conclude that if the above eq is satisfied, then it implies that AB & CD intersect at point P ?

Thanks you for the effort.

aazimlakhani
Автор

Came from Radu video. Loved your approach. Thanks a lot for the video!
Just an observation
At 4:11, I think the bottom cross product is wrong, shouldn't -ABy * ACx + ABx * ACy be equal to AB x AC ? I know you could invert it (AC x AB = - AB x AC) but then the negative in t2 would be gone.
And wasn't the negative you added to t2 at the final formula also not needed?

ginnni
Автор

I suppose that your entire logic would also apply in 3D (that makes sense to me) but for some reason it doesn't work on my side. Any idea? (The code below assumes a line with a fixed large distance).

Vector3 a = Start;
Vector3 b = Start + distance * Direction;
Vector3 c = other.Start;
Vector3 d = other.Start + distance * other.Direction;

Vector3 ac = c - a;
Vector3 ab = b - a;
Vector3 cd = d - c;

Vector3 t = Vector3.Cross(ac, cd) / Vector3.Cross(ab, cd);
Vector3 point = c + cd * t;

woudjee
Автор

ACxCD will be a vector, , , , ?? while t is a scalar?

waqasahmad
Автор

hey, in what app are you drawing all this?
Thanks!

leonardolopez
Автор

Everything was understandable until he decided to put them inside in a matrix :'(

bawbak
Автор

Thanks mate! I was looking for the linear algebra treatment of line intersection, and this video captured all the essential details in a very concise way.

technokicksyourass