tinycodinglm / math /math-0167.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame
1.28 kB
opencode trace
System You are an expert mathematician and programmer.

You are an expert mathematician and programmer.

User

Explain circle algorithms for computational geometry

Assistant

Circle: center (cx, cy), radius r.

Point in circle: distance(center, p) <= r.
Circle-circle intersection: distance(c1,c2) compared to r1+r2 and |r1-r2|. Two intersection points if |r1-r2| < d < r1+r2.

Tangent lines from point to circle:

  • Point outside: two tangent lines. Compute angle to center, offset by arccos(r/d).
  • Point on circle: one tangent line perpendicular to radius.
  • Point inside: no tangent lines.

Inscribed circle (incircle): intersection of angle bisectors. For triangle with sides a,b,c: inradius r = area/s where s=(a+b+c)/2.

Circumscribed circle (circumcircle): perpendicular bisectors of edges. For triangle: circumradius R = abc/(4*area).

Minimum enclosing circle: Welzl's algorithm O(n) expected. Randomized incremental.

Circle packing: arrange circles to maximize density. Hexagonal close packing: density pi/sqrt(12) ~ 0.9069.