08-12-2015 07:47 AM - edited 08-12-2015 08:08 AM
hi all,
as the title says i want fill a figure, specifically one made out of bezier curves, in a xy graph with equidistand points.
in order to do this i thought i try to transform the xy graph to 2D boolean array and then floodfill all the points within the figure ... like this:
then i can transform the 2D boolean array back to get the xy values of the points where the LED are turned on.
i've already ask in another topic about (http://forums.ni.com/t5/LabVIEW/xy-graph-to-boolean-array/td-p/3172814) but realized that the solution doesnt work for me
because the x/y values of the figure have 5 decimal places but the used method above (via replace array subset) only takes the value before the decimal point.
so i've used a 2D raster scan, where i get a 2D array with all possible points in the xy graph as a x/y pair.
then i compare this raster-array with the xy-values of my figure via "In Range and Coerce" like this:
the problem is now that the axis of the 2D boolean array doesnt represent the x and y axis of the xy graph.
anybody got any idea how to make every point in the 2D boolean array representing the corresponding point of the xy graph?
kind regards
oli
08-12-2015 02:15 PM
This is silly. If you want to draw a picture based on Bezier curves, why not ... draw a picture based on Bezier curves? If you use the Draw Multiple Lines VI found on the Picture Functions Palette, you can even set "fill?" to True to automatically fill the interior.
Bob Schor
08-13-2015 05:03 AM - edited 08-13-2015 05:05 AM
hi bob,
thanks for the input!
you're right ... it's easier to draw the bezier curves your way, fill the interior, get the image data and unflatten the pixmap to convert the image data to a 2D boolean array.
the problem is thereby that no matter how many iteration points i choose to get the xy values of my bezier curves (based on de casteljau's algorithm)
the picture/image data and therefore the 2D boolean array stays the same. and that's not what i want. 🙂
the more precise the bezier curves are calculated the bigger the 2D boolean array should be.
that's why i used a 2D raster scan in my attempt above.
i've attached the VI to calculate the bezier curves so you can get an idea.
08-13-2015 11:45 AM
Yes, but you missed the key step. Here is your example, with 4 points connected by straight lines (instead of Bezier curves). Your points are in the array on the left. I add the first point on at the end so that I "close the loop", then use the Draw Lines VI and directly draw the picture. I'll leave it to you (if you need to do this, but I'm not sure that you do, really) to convert the array of Black or White pixels into an array of booleans. I also leave it to you to convert the straight lines into a series of shorter straight lines to approximate the Bezier curve.
Bob Schor
08-13-2015 04:40 PM
should be possible
08-14-2015 01:51 PM
here's my favorite approach from http://www.antigrain.com/research/bezier_interpolation/index.html
combined with the Cursors of a XY Graph
08-17-2015 05:37 AM
thx alex!
that's a nice way of creating instantaneous bezier curves. 🙂
i dont see how i can fill the figure with equidistand points with your method.
and i think it's not possible to create figures with square corners like the one in the first post of this thread.
but its alright ... i already solved my problem. 🙂
gonna attach the VI later ... have to clear it up first.
08-17-2015 11:32 AM
re-fuse wrote:
i dont see how i can fill the figure with equidistand points with your method.
and i think it's not possible to create figures with square corners like the one in the first post of this thread.
my post was meant to be combined with Bob's Vi:
I don't know what you mean by "equidistant" in this context, but nevermind
I'm looking forward your solution!
Regards,
Alex
08-17-2015 12:17 PM
If I combine Alex's excellent code for creating interactive Bezier curves with my Picture algorithm, I get something like the following (I've "shrunk" Alex's graph to 0 .. 100 in each dimension, have left the cursors but removed the lines between them, have creating 50 intermediate points (way too many, probably), and have joined the endpoints to get this (I made it Red) ...
Bob Schor