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_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   what's the length of a sine curve?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: what's the length of a sine curve?  (Read 651 times)
arielm

WWW
what's the length of a sine curve?
« on: Jul 17th, 2003, 5:55pm »

(one step before trying with sci.math...)
 
i need to compute the length of an arbitrary sine curve, which is actually not trivial...
 
after a bit of research, i found the following 2 clues:
 
length of a sine curve from 0 to PI / 2: 2 Sqrt(2) EllipticE(1/2)
 
length from 0 to PI: 4 Sqrt(2) EllipticE(1/2)
 
okay... the only problem is that "EllipticE" is a MathLab function!
 
we're in non-linear math here, so i guess what i'm looking for is an algorithm that can simulate it (hoping that it's easily transposable to java and that it gives a good approximation without too much processing...)
 
anyone? 10-x...
 

Ariel Malka | www.chronotext.org
v3ga

WWW Email
Re: what's the length of a sine curve?
« Reply #1 on: Jul 17th, 2003, 11:07pm »

Hello Ariel,
 
Why not subdividing your curve in segments ? Take n points along the curve, thus making n-1 segments. By taking the sum of their length, you could approximate the curve's one.
The more points, the more accurate.
That's what I used in a previous applet ("WordsTree") to compute spline's length.
Hope it helps !
 

http://v3ga.net
arielm

WWW
Re: what's the length of a sine curve?
« Reply #2 on: Jul 17th, 2003, 11:30pm »

thanks for the suggestion! i'll keep it as a "last chance" option, while hoping to find a less processing-heavy solution...
 
meanwhile, i found an algo that seems very "light", but it's written in... ADA, and when translating it, it's not working as intended (not sure if it's the algorithm which is not adapted or a translation error of mine...)
 

Ariel Malka | www.chronotext.org
arielm

WWW
Re: what's the length of a sine curve?
« Reply #3 on: Jul 20th, 2003, 4:08pm »

finally, i got an answer through the sci.math newsgroup!
 
Quote:
The length from 0 to x (if 0 < x < Pi/2) is sqrt(2) EllipticE(sin(x),sqrt(2)/2)
 
A pretty good approximation for this function on that interval is
-.00001229706 + 1.414903705*x - .00627989750*x^2 -.0969152367*x^3 - .03159483907*x^4 + .03655607844*x^5 -.005227295775*x^6

yay!
 

Ariel Malka | www.chronotext.org
Pages: 1 

« Previous topic | Next topic »