05-19-2023 03:58 AM
Hello guys. Is it possible to find the coordinates of the point of intersection if I have two lines on the graph. The lines are formed by two arrays. How can this be done? I will be very glad for any answer. Thanks in advance!
Solved! Go to Solution.
05-19-2023 01:17 PM
Hi Wladyslaw,
@Vladyslav_Savchenko wrote:
Is it possible to find the coordinates of the point of intersection if I have two lines
Yes. It's (more or less) simple math to find intersections of lines…
05-19-2023 02:30 PM
The question is two ambiguous to answer clearly. Are these straight lines or complicated curves? There could be zero to an infinite number of intersections. Is the data noise-free?
It would help if you could show us your data to clarify the problem.
Since the points of both lines are given by arrays (i.e. quantized to integer indices), the intersection(s) could well be at fractional indices. What kind of interpolation should be used in that case?
05-20-2023 09:36 AM - edited 05-20-2023 09:42 AM
05-20-2023 12:30 PM
If these are straight lines, all you probably need is do a linear fit of each array dataset and apply this (taking care of special cases such as vertical lines (not possible for arrays, since x in the index and thus different for all points!), parallel lines, and two lines that are identical). The x of the intersection will be the fractional index and you can easily check if it is in the valid data range.
05-20-2023 01:28 PM
05-21-2023 01:42 PM - edited 05-22-2023 01:04 PM
@altenbach wrote:
If these are straight lines, all you probably need is do a linear fit of each array dataset and apply this (taking care of special cases such as vertical lines (not possible for arrays, since x in the index and thus different for all points!), parallel lines, and two lines that are identical). The x of the intersection will be the fractional index and you can easily check if it is in the valid data range.
Here's how that could look like (no external toolkit needed). Of course we still don't really know if the curves defined by the array data is linear. 😄
It would be trivial to check if the intersection is inside or outside the data range. You might also add additional validations as needed.
Since you have simple array data where X is the index, a plain waveform graph would be sufficient, of course.
05-30-2023 03:12 PM
Hi! Sorry, sorry and sorry again. I did this task in some other way without intersection and forgot about this page. I thank you and I thank to all, who has written here to help me. Thank you again)
Your variant is very interesting, but I am almost begginer in LabView, so сould you indicate where to connect the arrays in this scheme? In the implementation, I did without arrays, but I had two straight lines that intersected in one place. God bless you)
05-30-2023 03:28 PM
@Vladyslav_Savchenko wrote:
Your variant is very interesting, but I am almost begginer in LabView, so сould you indicate where to connect the arrays in this scheme? In the implementation,
Assuming the data is linear (even with some noise), you can substitute a linear fit of all your two datasets instead of a linear fit of the two cursor points for each curve. I even marked the location with a diagram comment. The rest can remain unchanged.
(Sorry, I don't have current access to LabVIEW, so this has to wait)