Circles of given radius through two points: Difference between revisions

→‎{{header|11l}}: make Error a non-fatal exception
(→‎{{header|11l}}: make Error a non-fatal exception)
Line 50:
.msg = msg
 
F circles_from_p1p2r(p1, p2, r) X(Error)
‘Following explanation at http://mathforum.org/library/drmath/view/53027.html’
I r == 0.0
X.throw Error(‘radius of zero’)
V (x1, y1) = p1
V (x2, y2) = p2
I p1 == p2
X.throw Error(‘coincident points gives infinite number of Circles’)
V (dx, dy) = (x2 - x1, y2 - y1)
V q = sqrt(dx ^ 2 + dy ^ 2)
I q > 2.0 * r
X.throw Error(‘separation of points > diameter’)
V (x3, y3) = ((x1 + x2) / 2, (y1 + y2) / 2)
V d = sqrt(r ^ 2 - (q / 2) ^ 2)
Line 81:
V (c1, c2) = circles_from_p1p2r(p1, p2, r)
print(" #.\n #.\n".format(c1, c2))
X.catchhandle Error v
print(" ERROR: #.\n".format(v.msg))</syntaxhighlight>
 
1,481

edits