We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Obtain length of a curveVertex
Page Index Toggle Pages: 1
Obtain length of a curveVertex (Read 224 times)
Obtain length of a curveVertex
Mar 11th, 2009, 3:07pm
 
Hey Processing community,

Short question, but with the knowledge I have of scripting a difficult one:
Can I somehow obtain the length of a curve, created with curveVertex.

My script is:
Code:

beginShape();
curveVertex(xcl, -0, 0);
for (int t=0; t<9; t++){
curveVertex(xcl, -(t*baseDepth)/8, zValueY(maxColumnHeight, (t*baseDepth)/8));
}
curveVertex(xcl, -baseDepth, 0);
endShape();


This generates a nice smooth curve, but I need to use the length of this curve. Is there a function within Processing for this, and if not: anybody got an idea how I could determine the length?

Thanks in advance!

Re: Obtain length of a curveVertex
Reply #1 - Mar 11th, 2009, 4:32pm
 
I believe it is a difficult problem, perhaps even insolvable, by mathematical means.
The best approach is to approximate the length by simulating the curve with lot of small line segments. Perhaps using the points you already use, if they are close enough and if the curve isn't too "curved" between them.
Re: Obtain length of a curveVertex
Reply #2 - Mar 11th, 2009, 4:39pm
 
Yes, I was already afraid of that.
The problem is that I need to make my gridmesh very dens to create the points close enough to eachother for the approximation to still be valid...
Page Index Toggle Pages: 1