91 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Suman Debnath am 20 Mai 2017
Kommentiert: Dimitar Slavchev am 18 Mär. 2021
Akzeptierte Antwort: Roger Stafford
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 Kommentare 2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
John D'Errico am 20 Mai 2017
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/341125-find-intersection-point-of-two-lines-when-i-have-their-coordinates#comment_455375
Oh, come on. You need to make an effort.
https://en.wikipedia.org/wiki/Line–line_intersection
Roger Stafford am 21 Mai 2017
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/341125-find-intersection-point-of-two-lines-when-i-have-their-coordinates#comment_455533
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 am 22 Mai 2017
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/341125-find-intersection-point-of-two-lines-when-i-have-their-coordinates#comment_455737
John, I did it. But I think the equation is too long. So, I just wanted to know if there is any short form of that or not.
Jan am 22 Mai 2017
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/341125-find-intersection-point-of-two-lines-when-i-have-their-coordinates#comment_455755
@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.
Melden Sie sich an, um zu kommentieren.
Melden Sie sich an, um diese Frage zu beantworten.
Akzeptierte Antwort
Roger Stafford am 23 Mai 2017
Bearbeitet: Roger Stafford am 23 Mai 2017
In MATLAB Online öffnen
The result of the three steps I mentioned would be:
xy = [x1*y2-x2*y1,x3*y4-x4*y3]/[y2-y1,y4-y3;-(x2-x1),-(x4-x3)];
I don’t consider that too long or complicated an expression. The xy variable here is a 1-by-2 vector consisting of the x and y coordinates of the intersection.
1 Kommentar -1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Dimitar Slavchev am 18 Mär. 2021
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/341125-find-intersection-point-of-two-lines-when-i-have-their-coordinates#comment_1401067
For the edge cases:
Where the two lines are the same line you will get NaNs:
>> LineIntersect(0,0,1,1,0,0,1,1)
Warning: Matrix is singular to working precision.
> In LineIntersect (line 11)
ans =
NaN NaN
And for parallel lines, Infinity:
>> LineIntersect(0,0,1,1,0,1,1,2)
Warning: Matrix is singular to working precision.
> In LineIntersect (line 11)
ans =
-Inf -Inf
LineIntersect is just the above formula from Roger Stafford inside a function. The line is 11, because of comments.
Melden Sie sich an, um zu kommentieren.
Weitere Antworten (0)
Melden Sie sich an, um diese Frage zu beantworten.
Siehe auch
Kategorien
MATLABLanguage FundamentalsLoops and Conditional Statements
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Tags
- line
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Es ist ein Fehler aufgetreten
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asien-Pazifik
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Kontakt zu Ihrer lokalen Niederlassung