Find intersection point of two lines when I have their coordinates ?
이전 댓글 표시
I have four COORDINATES of two lines - [x1,y1], [x2,y2], [x3,y3], [x4,y4]. Now, how to get the coordinate of their intersecting point [x,y] ? Any help ??
댓글 수: 4
John D'Errico
2017년 5월 20일
Oh, come on. You need to make an effort.
https://en.wikipedia.org/wiki/Line–line_intersection
Roger Stafford
2017년 5월 21일
Suman, I would suggest you break your problem into three steps.
Step 1: Letting the intersection point have the unknown coordinates x0 and y0, write an equation that expresses the equality of the slope of a line connecting (x1,y1) and (x2,y2) to the slope of the line connecting (x1,y1) and (x0,y0). Similarly, write a second equation equating the slopes of lines involving (x3,y3), (x4,y4), and (x0,y0). This gives you two linear equations in two unknowns.
Step 2: Perform appropriate algebraic manipulation on these equations and then translate these into a single matrix equation - that is, for example, the unknown 1-by-2 vector, [x0,y0], multiplied by a 2-by-2 matrix of known coefficients that is to equal a known 1-by-2 vector.
Step 3: Use matlab’s slash “/” operator to solve this matrix equation for the unknown vector, [x0,y0]. (This is equivalent to finding the matrix inverse of the above 2-by-2 matrix.)
Suman Debnath
2017년 5월 22일
Jan
2017년 5월 22일
@Suman: Yes, there is a short form. Did you read the link posted by John? This is an exhaustive solution already. Making an effort means also, to ask an internet search engine.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!