LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Intersection points of lines

Solved!
Go to solution

Hi guys, I have a little problem. I have two sets of points, that defines two rectangles. I have to find out how big is the area they share. Any idea how to do that? 

 

Ukazka.PNG

 

I have found function "Polygon Area.vi". but for this function I need points of intersection of these two rectangles to calculate inner area. 

 

Thanks for any advice. 

0 Kudos
Message 1 of 7
(6,875 Views)

There are two VIs that need to be used. First, you need to use the Convex Polygon Intersection.vi to find the intersection points. Then you need the Polygon Area.vi to calculate the area from that polygon returned from the Convex Polygon Intersection.vi.  You can find these two VIs in the Computational Geometry Palette. See attached.

 

Front Panel.png

 

Block Diagram.png

Message 2 of 7
(6,858 Views)

I am really sorry, I forget to write it, I am running LV 2011... I am using Student Edition, so I am not sure, if I can update to LV 2012. Another problem is, that I have already finished the other parts of the project in LV 2011... 

 

But thank you very much for your answer.

0 Kudos
Message 3 of 7
(6,843 Views)
Solution
Accepted by Groover

I justs did a quick check and did not see the Convex Polygon Intersection VI in LV 2011.

 

It should not be too difficult to write your own.  You need to consider several possible cases: The polygons do not intersect.  The polygons have exactly one point in common (vertex of one is on an edge or vertex of the other). The polygons have segments of one or more edges in common. One polygon is completely contianied within the other. And the case you showed where the polygons overlap but do not share an edge or vertex.  If the polygons can be concave, some additional complexity may be involved.

 

Some straightforward analytic geometry will allow you to locate the intersections of the two straight lines formed by edges of the polygons. Then you need to determine whether the intersections are on an edge or outside the polygon. Once you have located the 4 (or zero) points of intersection which are relevant, you can use the Poylgon Area.vi, which is in LV 2011, to calculate the desired area.

 

Since you are using the student editon, is this a school assignment?  If so, most of the participants on the Forums will not do your work for you as you do not learn anything that way, but we will help you to learn LV.

 

The steps I would take are: 1. Define the possible polygon cases for your situation. 2. Do the analytic geometry by hand so that you understand the issues. 3. Define the program, possibly with a flow chart or state diagram, in terms of items 1 and 2. 4. Write the LabVIEW code to implement 3.

 

Lynn

Message 4 of 7
(6,828 Views)

Hi, 

 

yes, I am student, but this is only one part of my diploma thesis. It is not a whole thesis, neither the most important part of it. I just want to show some solution made in LV. 🙂 

 

 

0 Kudos
Message 5 of 7
(6,823 Views)

I also checked and the Convex Polygon Intersection VI is not part of LV2011.

 

Another approach would be to use the Point in Polygon.vi to verify if the vertex of one polygon are inside the other one. You have to do it both ways ( Polygon A in B and B in A) because a polygon can be included in the other one. Once you have determined wich vertex are included in the other polygon you can use the classic analytical geometry methods to find your answer.

 

Ben64

0 Kudos
Message 6 of 7
(6,811 Views)

Computational Geometry VIs were added in LV12.  I believe they were popular MathScript functions which were reimplemented in G.

0 Kudos
Message 7 of 7
(6,807 Views)