FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Suggestions
   Software Suggestions
(Moderator: fry)
   Bezier evaluation
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Bezier evaluation  (Read 380 times)
skloopy

WWW
Bezier evaluation
« on: Jul 5th, 2003, 10:33am »

A while ago someone suggested evaluation of points on a bezier curve should be in P5. Has that feature been added already? I couldn't find an info on it. I'm writing something right now where it would be really useful.
 
Is there some workaround to match points on curves that P5 draws? Does anyone know the right bezier equation given a 0 to 1 value and the control points?
 
ryan
 
skloopy

WWW
Re: Bezier evaluation
« Reply #1 on: Jul 5th, 2003, 10:58am »

Okay i found this equation
 
Code:
float bezierParm(float Ax,float Bx,float Cx,float Dx,float a) {
  float b = 1.0f - a;
  return Ax*a*a*a + Bx*3*a*a*b + Cx*3*a*b*b + Dx*b*b*b;
}

I'm gonna test it out to see if it works cuz it might not be the same as P5s, but it's OK for now until it's built in i guess. You just feed it all of the 4 X points and a 0 to 1 value to get X and etc with Y and Z.
 
fry


WWW
Re: Bezier evaluation
« Reply #2 on: Jul 8th, 2003, 2:56am »

coming soon.. it was supposed to be in 56 but didn't make the cut.. hopefully for 57.
 
fry


WWW
Re: Bezier evaluation
« Reply #3 on: Jul 31st, 2003, 2:23am »

bezierParm is the correct function, and the functionality, for both bezier() and curve(), has been added for release 57.
 
skloopy

WWW
Re: Bezier evaluation
« Reply #4 on: Aug 9th, 2003, 12:36am »

Just a suggestion, it might be a good idea to build in the ability to find the tangent of a certain bezier point.
 
Here's the code (I can't take credit for it cuz it's from v3ga's wordstree sketch) Except I modified it a little.
 
Code:
float t2,t3,t_1,t_12,t_13;
float getTangentX(float t)
{
  t2 = t*t; t_1 = 1-t; t_12 = t_1*t_1;
  return (-3*t_12*stalkX[0] + 3*(3*t2 - 4*t +1)*stalkX[1] + 3*t*(2-3*t)*stalkX[2] + 3*t2*stalkX[3]);
}
 
float getTangentY(float t)
{
  t2 = t*t; t_1 = 1-t; t_12 = t_1*t_1;
  return (-3*t_12*stalkY[0] + 3*(3*t2 - 4*t +1)*stalkY[1] + 3*t*(2-3*t)*stalkY[2] + 3*t2*stalkY[3]);
}
 
Pages: 1 

« Previous topic | Next topic »