File size: 1,230 Bytes
d517dc9 | 1 2 3 4 5 | {"type": "session", "harness": "opencode", "id": "math-0171", "name": "Computational Geometry"}
{"type": "message", "message": {"role": "system", "content": "You are an expert mathematician and programmer."}}
{"type": "message", "message": {"role": "user", "content": "Explain computational geometry for competitive programming"}}
{"type": "message", "message": {"role": "assistant", "content": "Point/vector: struct with x,y. Operations: +, -, dot (a.x*b.x+a.y*b.y), cross (a.x*b.y-a.y*b.x).\nCross product: |a||b|sin(theta). Positive=left turn, negative=right, zero=collinear.\nDot product: |a||b|cos(theta). Zero=perpendicular.\n\nConvex hull: Graham scan O(n log n). Sort by angle, maintain stack, pop on right turn.\nLine intersection: solve 2x2 system. Two forms: point-slope or parametric.\nPolygon area: shoelace formula. Area = 0.5*|sum(x_i*y_{i+1} - x_{i+1}*y_i)|.\nPoint in polygon: ray casting or winding number.\nClosest pair: divide and conquer O(n log n).\nRotating calipers: diameter, width, min bounding rectangle of convex polygon.\nHalf-plane intersection: intersect n half-planes, O(n log n).\nCircle-circle intersection: up to 2 points.\nLine-circle intersection: substitute line into circle equation."}}
|