LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Circle to Line Intersection

Hi.
 
I have this VI which I want to know if the diameter of the circle intersects with the line. Kindly see the attached VI. If you run the VI, there is a green line (Line 1) which it shows the LED lit which means it intersects. But the blue line (Line 2), even it shows it intersects in the graph including all the other calculation, it doesnt lit the LED. I am not sure how can i correct the conditions when to lit the LED.
 
If i make the lines at vertical (Line 1 and Line 2), i will have no problem making the LED lit. But otherwise, the LED will not lit.
Any advise I would great appreciate.
 
Thank you very much.
0 Kudos
Message 1 of 8
(5,501 Views)

Hi

Just by looking briefly at your vi, I must tell you, that it obviously does not indicate intersections properly. Just by comparing some ranges you probably will never get the correct state.

You have to do some maths. The line is defined: y = mx+b. You can calculate m and b because you have two given points. The circle is also defined: y = yc +/- sqrt(r^2 - (x - xc)^2). So basically you have to solve an equation to get the intersection points. Maybe there is already something available in LV.

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 8
(5,497 Views)

Thank you for your kind reply.

Actually the first VI i made is from math. I took the equation of a circle and line as what you indicated. Please find the attached VI. Kindly run this VI and input the following coordinates points to see two case;

1st. case, P1 (4,6) P2 (6,-3)

2nd case, P1 (2,8) P2 (3,5)

On the first case, if you will increase the slide bar (radius of a circle) and touches the line, we can see that it actually intersects the line through the LED. But on the second case, if you slowly increase the radius, because of the characteristic of a line which extends to infinity, even if its not touching the line, it will show it intersects through the LED.

This is my problem. I want to show that even if the radius is equal or greater than the perpendicular distance to the line, but actually not touching the line, it should not show it intersects. It will only show it intersects if it touches the line.

Kindly help me please. I would appreciate any advise from your experience. Thank you very much.

0 Kudos
Message 3 of 8
(5,484 Views)

Maybe this thread.

http://forums.ni.com/ni/board/message?board.id=170&message.id=136882&requireLogin=False

Or use the limit testing vi's. Make the circle the limit line and the line your data. See this example.

C:\Program Files\National Instruments\LabVIEW 7.0\examples\measure\maxmpl.llb\Limit Testing Measurement.vi

C:\Program Files\National Instruments\LabVIEW 7.0\examples\measure\maxmpl.llb\Limit Testing for Unevenly Sampled Data Measurement.vi

If you are using array data, I have some limit vi's for array data rather than waveform datatypes.

0 Kudos
Message 4 of 8
(5,478 Views)
Thank you for the reply and the examples.
I am trying to study each of them. Can I request for the limit's VI for array data too because I cant realize yet how can I apply my data into wafeform data type? Thank you for bearing with me. 
0 Kudos
Message 5 of 8
(5,475 Views)
Hi
 
I had a breif look at your second vi. It is also based on comparison. What I suggested was to solve an equation.
Both geometrical forms are defined:
Circle: (x-xc)^2+(y-yc)^2=r^2, where (xc/yc) is the center of the circle
Line: y = mx+b
 
Now you have to subsitute, which means replace y of the circle formula with the line formula: (x - xc)^2 + ((mx + b) - yc)^2 = r^2.
 
m and b can be calculated, as you have two points: m = (y1 - y0) / (x1 - x0), b = y0 - m*x0
 
In the end you can replace all variables with values, except x - this is what your are looking for.
 
So basically you will have to solve a quadratic equation. I can't give you a finished vi (I don't have enough time to create something), but that's the way to go. Due to the fact the it is a quadratic equation you will get two results (like sqrt(4) really is 2 and -2) if the line intersects. To check if it really intersects, you then can compare if the two resulting x values are within x0 and x1, which specify the line.
 
Hope this helps.
 
Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 6 of 8
(5,462 Views)

You have a couple of options to make array data into a waveform datatype. There is a resample waveform vi that can take in an array of XY pairs or multiple arrays of pairs and turn this into a waveform.

C:\Program Files\National Instruments\LabVIEW 7.0\vi.lib\measure\maresamp.llb\Resample Array of Pairs (single shot).vi

If you have evenly spaced array data, you can use the Build Waveform function by specifying the t0, dt, Y array as inputs.

Attached is a 7.0 format file that has the array based limit testing vi's inside the .llb file.

Message 7 of 8
(5,452 Views)

Here it is. I had to make this solution for one of my projects. Feel free to use it. the following link helped me much:

http://mathworld.wolfram.com/Circle-LineIntersection.html

The example is in LV 2010 including NI Vision, but the calculations are pure in LV.

 

0 Kudos
Message 8 of 8
(4,235 Views)