LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bezier curve app

Hi everybody,

I'd like to make an app to make Bézier Curve :

I want to change coordinate of point from the graph (with the mouse) and to check the way it changes the curve.
The challenge is that to find a easy way to reasign coordinate with mouse clic.

Is anybody did that before or have an idea to do it ?


In the other hands, I want to dump datas in MatLab what's the most elegant way ?

Many thanks
0 Kudos
Message 1 of 5
(4,507 Views)
Ok I made the GUI and I found the algorithm in order to make a bezier curve : De Casteljau algorithm

I not clever to understand pseudo code, someone can help me ?
struct point
{
float x;
float y;
};

// 4 points define the bezier-curve.. These are the points used
// for the example-images on this page.
point a = { 40, 100 };
point b = { 80, 20 };
point c = { 150, 180 };
point d = { 260, 100 };

// simple linear interpolation between two points
void lerp (point &dest, point &a, point &b, float t)
{
dest.x = a.x + (b.x-a.x)*t;
dest.y = a.y + (b.y-a.y)*t;
}

// evaluate a point on a bezier-curve. t goes from 0 to 1.0
void bezier (point &dest, float t)
{
point ab,bc,cd,abbc,bccd;
lerp (ab, a,b,t); // point between a and b (green)
lerp (bc, b,c,t); // point between b and c (green)
lerp (cd, c,d,t); // point between c and d (green)
lerp (abbc, ab,bc,t); // point between ab and bc (blue)
lerp (bccd, bc,cd,t); // point between bc and cd (blue)
lerp (dest, abbc,bccd,t); // point on the bezier-curve (black)
}

// small test program.. just prints the points
void main (void)
{
point p;
for ( int i=0; i<1000; i++ )
{
float t = (float)i/999.0;
bezier (p,t);
printf ("%f %f\n", p.x, p.y);
}
}
Many thx
0 Kudos
Message 2 of 5
(4,494 Views)
Hi Doyon,

attached you will find a LV6.1 version of your "pseudo" code...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 5
(4,479 Views)
Many thanks,

I was able to did it... finally
Take a look




Message Edité par Doyon le 11-23-2007 12:42 PM
0 Kudos
Message 4 of 5
(4,458 Views)
Hi Doyon,

did you attach anything here?

I changed the demo a little bit to allow playing with it Smiley Happy
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 5
(4,429 Views)