LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find the coordinates of the point of intersection of the lines

Solved!
Go to solution

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! 

0 Kudos
Message 1 of 9
(1,055 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(995 Views)

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?

0 Kudos
Message 3 of 9
(984 Views)

 

you may take a look at

 

https://www.vipm.io/package/mgi_lib_mgi_coordinates/

 

especially:

https://gitlab.com/mgi/labview-tools-network/mgi-library/coordinates/-/blob/master/Find%202D%20Inter...

 

Spoiler

 

Message 4 of 9
(949 Views)

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.

Message 5 of 9
(929 Views)

intersection_mgi_demo.png

Message 6 of 9
(919 Views)
Solution
Accepted by topic author Vladyslav_Savchenko

@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.

 

altenbach_0-1684694473817.png

 

Since you have simple array data where X is the index, a plain waveform graph would be sufficient, of course.

 

Message 7 of 9
(876 Views)

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)

0 Kudos
Message 8 of 9
(767 Views)

@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)

0 Kudos
Message 9 of 9
(763 Views)