LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fill a figure in a xy graph with equidistant points

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:

 

lv3.png

 

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:

 

lv2.png

 

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

 

0 Kudos
Message 1 of 9
(5,235 Views)

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

0 Kudos
Message 2 of 9
(5,172 Views)

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.

0 Kudos
Message 3 of 9
(5,141 Views)

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.

Bezier Draw.png

Bob Schor

0 Kudos
Message 4 of 9
(5,110 Views)
0 Kudos
Message 5 of 9
(5,084 Views)

here's my favorite approach from http://www.antigrain.com/research/bezier_interpolation/index.html

 

combined with the Cursors of a XY Graph

 

2015-08-14_bezier-bernstein-front.PNG

 

2015-08-14_bezier-bernstein.png

 

 

 

 

 

Message 6 of 9
(5,041 Views)

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.

0 Kudos
Message 7 of 9
(4,969 Views)

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:

 

2015-08-17_rect+spline.PNG

 

 

 

 

 

I don't know what you mean by "equidistant" in this context, but nevermind

 

I'm looking forward your solution!

 

 

Regards,
Alex

 

0 Kudos
Message 8 of 9
(4,942 Views)

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

Bezier.png

Bob Schor

Message 9 of 9
(4,932 Views)