Length of arc of spiral lines

Share your advanced PureBasic knowledge/code with the community.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Length of arc of spiral lines

Post by Psychophanta »

Everybody know how to calculate the lengh of a piece or circunference.
But when dealing with spirals there is another very different story.
After looking for length of arc of Arquimedean spirals all over web i didn't find it, so i had to solve the integral myself and here it is...

Code: Select all

;Calculations of lengths of arcs of spiral lines in a plane:
;Psychophanta (Albert) Jan 2008 (Free for use, but greeting me before, for example via email :)

;La longitud del arco de espiral logaritmica del tipo R=R0*e^(b*F) (siendo R el radio, R0 el radio inicial, e el numero e, b un numero real constante y F el angulo),
;es Sqr(b*b+1)/b*(R-R0)
;La longitud del arco de espiral logaritmica del tipo R=R0*b^F (siendo R el radio, R0 el radio inicial, b un numero real constante y F el angulo),
;es Sqr(Log(b)*Log(b)+1)/Log(b)*(R-R0)
;La longitud del arco de espiral de Arquimedes del tipo R=b*F (siendo R el radio, R0 el radio inicial, b un numero real constante, F el angulo y F0 el angulo inicial),
;es b/2*((F*Sqr(1+F*F)+ASinh(F))-(F0*Sqr(1+F0*F0)+ASinh(F0))) o bien: b/2*((R/b*Sqr(1+R*R/b/b)+ASinh(R/b))-(R0/b*Sqr(1+R0*R0/b/b)+ASinh(R0/b)))
Macro ASinh(x)
  Log(x#+Sqr(x#*x#+1))
EndMacro
Macro exp(x)
  (Pow(2,x#/Log(2)))
EndMacro
Macro ArchimedeanSpiralArcLengthByAngle(F0,F,b)
;Length of Arc of an Archimedean spiral, i.e. spiral polar equation form: R=b*F, where R is the Radius, b is a real number, F is the angle. F0 is an angle lower than F.
  (b#/2*((F#*Sqr(1+F#*F#)+ASinh(F#))-(F0#*Sqr(1+F0#*F0#)+ASinh(F0#))))
EndMacro
Macro ArchimedeanSpiralArcLengthByRadius(R0,R,b)
;Length of Arc of an Archimedean spiral, i.e. spiral polar equation form: R=b*F, where R is the Radius, R0 is a radius lower than R, b is a real number, and F is the angle.
  (b#/2*((R#/b#*Sqr(1+R#*R#/b#/b#)+ASinh(R#/b#))-(R0#/b#*Sqr(1+R0#*R0#/b#/b#)+ASinh(R0#/b#))))
EndMacro
Macro LogarithmicSpiralArcLengthByRadius(R0,R,b)
;Length of Arc of a Logarithmic spiral with polar equation form: R=R0*exp(b*F), where R is the Radius, R0 is the initial radius, b is a real number, F is the angle. Notice that F0 here (i.e. when R=R0) is 0.
  (Sqr(b#*b#+1)/b#*(R#-R0#))
EndMacro
;TEST:
b.f=1
F0.f=0
F.f=#PI
R0.f=0
R.f=1
Debug ArchimedeanSpiralArcLengthByAngle(F0,F,b)
Debug ArchimedeanSpiralArcLengthByRadius(R0,R,b)
Debug LogarithmicSpiralArcLengthByRadius(R0,R,b)
Anyway, i would be grateful if anyone here, @srod or so could simplify the expression:

Code: Select all

(F#*Sqr(1+F#*F#)+ASinh(F#))-(F0#*Sqr(1+F0#*F0#)+ASinh(F0#))
coz i am almost sure it can be simplified, over all if we know DeltaF=F-F0.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

A quick play and I really don't think you can simplify the expression Psychophanta. Even moving to logarithms doesn't really make things any simpler looking. It looks about as simple as it is going to get I reckon.
I may look like a mule, but I'm not a complete ass.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Thanks then! :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply