Find the Intersection of Two Line Segments in 2D (Easy Method)

  Рет қаралды 3,765

Edgar Programmator

Edgar Programmator

11 ай бұрын

In this video, I will show you how to find the intersection of two line segments in 2D. This is a simple but important concept in geometry, and it can be used in many different applications. I will explain the method step-by-step, and I will also provide some examples.
Points:
A(x1,y1)
B(x2,y2)
C(x3,y3)
D(x4,y4)
Given two line segments AB and CD, find the point of intersection P(x0, y0).
Solution:
Vectors:
A = (x1, y1)
B = (x2, y2)
C = (x3, y3)
D = (x4, y4)
AB = (x2 - x1, y2 - y1)
CD = (x4 - x3, y4 - y3)
A + αAB = C + βCD
α = ((x4 - x3)(y3 - y1) - (y4 - y3)(x3 - x1)) / ((x4 - x3)(y2 - y1) - (y4 - y3)(x2 - x1)) = a / b
β = ((x2 - x1)(y3 - y1) - (y2 - y1)(x3 - x1)) / ((x4 - x3)(y2 - y1) - (y4 - y3)(x2 - x1)) = c / b
P = (x0, y0)
x0 = x1 + α(x2 - x1) = x3 + β(x4 - x3)
y0 = y1 + α(y2 - y1) = y3 + β(y4 - y3)
/ edgardocpu

Пікірлер: 6
@glebickapimpin9852
@glebickapimpin9852 7 ай бұрын
Thank you for simple and fast explanation.
@GoalWalker
@GoalWalker 9 ай бұрын
Next video topic idea: If two line segments are collinear, how to find the overlap? Like defining the overlap as its own line segment and finding each endpoint.
@GoalWalker
@GoalWalker 9 ай бұрын
2:30 If a=b=0 means the line segments are collinear, does c=b=0 also mean the line segments are collinear?
@GoalWalker
@GoalWalker 9 ай бұрын
1:50 Can you go into more steps to work out equations for alpha? Each time I do, I get different order for numerator for alpha, like if the two multiplying parts were switched. As well as, I have the denominator for alpha and beta are different. I don't know where I am going wrong: (the workout below is from my handwork, the captions for each step were rewritten from chatGPT) alpha*(x2-x1) - beta*(x4-x3) = x3-x1 alpha*(y2-y1) - beta*(y4-y3) = y3-y1 Solve for alpha: # Solve for alpha in terms of beta: beta = (alpha*(x2-x1) - (x3-x1)) / (x4-x3) beta = (alpha*(y2-y1) - (y3-y1)) / (y4-y3) # Since both equations equal alpha, they must be equal to each other: [alpha*(x2-x1) - (x3-x1)] / (x4-x3) = [alpha*(y2-y1) - (y3-y1)] / (y4-y3) # Cross-multiply to eliminate fractions: (y4-y3)*(alpha*(x2-x1)-(x3-x1)) = (alpha*(y2-y1)-(y3-y1))*(x4-x3) # Expand and rearrange the equation to isolate alpha: (alpha*(x2-x1)*(y4-y3)) - (x3-x1)*(y4-y3) = (alpha*(x4-x3)*(y2-y1)) - (x4-x3)*(y3-y1) # Now, isolate alpha: (alpha*(x2-x1)*(y4-y3)) - (alpha*(x4-x3)*(y2-y1)) = (x3-x1)*(y4-y3) - (x4-x3)*(y3-y1) # Factor out alpha: alpha*[(x2-x1)*(y4-y3) - (x4-x3)*(y2-y1)] = (x3-x1)*(y4-y3) - (x4-x3)*(y3-y1) # Finally, solve for alpha: alpha = [(x3-x1)*(y4-y3) - (x4-x3)*(y3-y1)] / [(x2-x1)*(y4-y3) - (x4-x3)*(y2-y1)] As you can see from alpha, the two products in the numerator and denominator are switched from the alpha formula in the video. Why? Note 1: When I ask chatGPT, they just say my result is correct. Which to me seems wrong. Note 2: The equations for alpha and beta in video appear in a different order than to t and u from the wiki of "Given two points on each line segment"
@GoalWalker
@GoalWalker 9 ай бұрын
I got alpha as in the video by isolating alpha to the right side, rather than the left. But I got beta as in the video by isolating to the left. Weird, especially when doing by hand.
@jasonmakepeaceranchohs869
@jasonmakepeaceranchohs869 3 ай бұрын
I got his results by setting it up as a matrix equation and using Cramer's Rule. I subtracted x1 and y1 to the right and β(x4 - x3) and β(y4 - y3) to the left. Cramer's Rule for α and β worked pretty slick. Might have to adjust some of the commutative order on a few things to make it look the same, but it worked out for me.
How to Draw a Circle Through 3 Points
1:47
Edgar Programmator
Рет қаралды 245
Line Segment Intersection
5:55
EngineerNick
Рет қаралды 12 М.
Red❤️+Green💚=
00:38
ISSEI / いっせい
Рет қаралды 78 МЛН
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 74 МЛН
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 9 МЛН
Segment intersection formula explained
35:26
Radu Mariescu-Istodor
Рет қаралды 31 М.
Find the Intersection of Two Lines in the Plane: A Step-by-Step Guide
3:25
A Surprisingly Easy Functional Equation 🤯🤯🤯
2:35
Mathemadix
Рет қаралды 7 М.
How to Design the Perfect Shaped Wheel for Any Given Road
22:43
Morphocular
Рет қаралды 2,3 МЛН
The SAT Question Everyone Got Wrong
18:25
Veritasium
Рет қаралды 12 МЛН
Intersection of Two Lines in 3D Space | Intersecting Lines
6:51
Radford Mathematics
Рет қаралды 61 М.
Solve any equation using gradient descent
9:05
Edgar Programmator
Рет қаралды 52 М.
A simple algorithm for 2D Voronoi diagrams
3:27
Edgar Programmator
Рет қаралды 4 М.
Finding the intersection of two lines without graphing
8:16
Charlie Burrus
Рет қаралды 378 М.
Cheapest gaming phone? 🤭 #miniphone #smartphone #iphone #fy
0:19
Pockify™
Рет қаралды 4,3 МЛН
Самый тонкий смартфон в мире!
0:55
Не шарю!
Рет қаралды 91 М.
Красиво, но телефон жаль
0:32
Бесполезные Новости
Рет қаралды 1,5 МЛН
Здесь упор в процессор
18:02
Рома, Просто Рома
Рет қаралды 393 М.
Копия iPhone с WildBerries
1:00
Wylsacom
Рет қаралды 4,7 МЛН
Как удвоить напряжение? #электроника #умножитель
1:00
Hi Dev! – Электроника
Рет қаралды 968 М.