The author of the question (Tony Morris) actually asked two different questions, and so people gave two different replies :)

To quote Tony:
"I may have misunderstood his problem (we were drawing in dirt) and actually, it is
the straight line between the two points on the circumference that are
known and not the specified 'b', but I figure I could derive one
solution from another if I have misunderstood him."

So, the solution to the drawing, where a is the radius and b is the arc:

x = a * (1 - cos(b/2a)) (because cosine = adjacent / hypotenuse)

The solution to the textual question, where a is the radius and b is the distance between the two points on the circumference:

(a-x)2 + (b/2)2  = a2  
 
=> x2 - 2ax + a2 + (b/2)2 = a2
=> x2 - 2ax + (b/2)2 = 0
=> x = a ± sqrt(4a2 - b2) / 2 (solution to quadratic)
=> x = a - sqrt(a2 - b2/4) (move /2 into sqrt, and can't be +sqrt because that would make x greater than a)

So in Haskell

sol1 a b = a * (1 - cos (b / (2*a)))
sol2 a b = a - sqrt (a*a - (b*b)/4)

Cheers,
Peter


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to