06-25-2013 07:42 AM
Hi all,
in my project I used function Convex Polygon Intersection VI (new in LabView 2012) and it seems that it doesn't work correct. In some cases the result is not correct (see image). The result is correct when I re-type inputs from double to single (although this function inputs are defined as double) but I'm not sure whether this solution is guaranteed for every input values or not.
Anyone with the same problem? Maybe I made some stupid mistake or the function is really wrong? I'm able to make my own function instead but it's not a little work...
Thanks for your advices
Radek
06-25-2013 04:42 PM
I agree that the function is buggy. If you translate object 1 in X by 0.00001, then it gives the correct intersection. That could be why it works for SGL inputs - the values end up very slightly different when converted to DBL, and therefore work ok.
Apart from the bugs, it's disappointing that (1) the algorithm used is not mentioned or referenced in the help, and (2) none of the subVIs have any documentation whatsoever, even though I'm sure all of that information was part of the development. This means that if there is a bug, such as in this case, there's little hope of fixing it ourselves without starting over from scratch.
06-26-2013 03:28 PM
Math VIs shipping with LV can be very frustrating. Besides what Greg mentions as obvious shortcomings, it can seem that little testing is done. In computational geometry you have to check regular cases (colinearity, regular grids, etc.). Here a simple diamond pattern screws up, don't worry about DBL/SGL changes or thinking you have a random set, enclose the points [{1,0},{2,1},{1,2},{0,1},{1,0}] with a large polygon, does not matter what shape. It screws up and the culprit is Polygon Intersection_Rm Duplicated Vertices.vi. The point of the VI is to determine if three points are collinear and the middle one can be removed, but you can tell by inspection that it screws it up. It thinks move left one and up one, followed by move left one and down one is following the same line and removes the middle point.
I tend to roll my own Math VIs and swipe the NI icons. Do mine work better than NIs because I am some kind of math supergenius? Perhaps, but it is much more likely that my code starts out as bug ridden as theirs but I test mine early and often, and component by component. You have to understand how the game is played. Your computational geometry textbook is going to give you algorithms that often assume randomized data. They like to call this "real world" data. Unfortunately, a lot of "real world" data is entered by hand in nice round, regular numbers.
Good catch. What they may lack in catching these issues the first time around, they usually make up for by fixing them when you tell them exactly where to look and what to check for.
01-01-2020 12:06 PM
I have just released a couple of VIs for polygon clipping/growing/shrinking on VI package manager. The polygons are not restricted to convex polygons but can be arbitrary.
The VIs can be found on VIP by searching for 4SmartMachines.
03-29-2023 06:26 PM
In LabVIEW 2020 Convex Polygon Intersection VI returns extra vertice - first and last vertices are the same.