Jump to content

Smallest enclosing circle problem: Difference between revisions

Line 16:
{{trans|Go}}
 
<lang 11l>T Point = (Float, Float)
Float x, y
 
F (x, y)
.x = x
.y = y
 
F String()
R ‘(’(.x)‘, ’(.y)‘)’
 
T Circle
Line 36 ⟶ 28:
F String()
R ‘Center ’(.c)‘, Radius ’(.r)
 
F distSq(Point a, b)
R (a.x - b.x) ^ 2 + (a.y - b.y) ^ 2
 
F dist(Point a, b)
R sqrt(distSq(a, b))
 
F getCircleCenter(Float bx, by, cx, cy)
Line 50 ⟶ 36:
 
F contains(Circle ci, Point p)
R distSqsqlen(ci.c, - p) <= ci.r ^ 2
 
F encloses(Circle ci, [Point] ps)
Line 62 ⟶ 48:
i.x += a.x
i.y += a.y
R Circle(i, distdistance(i, a))
 
F circleFrom2(Point a, b)
V c = Point((a.x + b.x) * 0.5, (a.y + b.y) * 0.5)
R Circle(c, distdistance(a, b) / 2)
 
F secTrivial([Point] rs)
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.