Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object ArcParabLen {
- def lenCurve(n: Int): Double = {
- val h=(1/n.toDouble)
- def helper(acc:Double=0, x:Double, h:Double ):Double={
- if(x<=1){
- if(x<1&&(x+h)<=1) {
- val x1 = x + h
- val dX = x1 - x
- val dY = x1 * x1 - x * x
- val acc1 = acc+Math.sqrt(dX*dX+dY*dY)
- helper(acc1,x1,h)
- }
- else{
- val dX =1-x
- val dY =1-x*x
- val acc1 = acc+Math.sqrt(dX*dX+dY*dY)
- acc1
- }
- }
- else acc
- }
- helper(0, 0, h)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement