{"type": "session", "harness": "opencode", "id": "math-0169", "name": "Computational Geometry: Points and Vectors"} {"type": "message", "message": {"role": "system", "content": "You are an expert mathematician and programmer."}} {"type": "message", "message": {"role": "user", "content": "Explain point and vector operations for computational geometry"}} {"type": "message", "message": {"role": "assistant", "content": "Point: (x, y). Vector: (dx, dy). Same representation, different semantics.\n\nOperations:\n- Addition: (a.x+b.x, a.y+b.y)\n- Subtraction: (a.x-b.x, a.y-b.y) gives vector from b to a\n- Scalar multiply: (a.x*c, a.y*c)\n- Dot product: a.x*b.x + a.y*b.y = |a||b|cos(theta). 0=perpendicular, >0=acute, <0=obtuse.\n- Cross product: a.x*b.y - a.y*b.x = |a||b|sin(theta). >0=b left of a, <0=b right of a, 0=collinear.\n- Length: sqrt(dot(a,a)). Squared length: dot(a,a) (avoids sqrt for comparisons).\n- Distance: sqrt(dot(a-b, a-b)).\n- Normalize: divide by length. Zero vector: special case.\n- Rotate 90 deg CCW: (-y, x). CW: (y, -x).\n- Angle between vectors: atan2(cross(a,b), dot(a,b)).\n- Projection of a onto b: (dot(a,b)/dot(b,b)) * b."}}