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

You are an expert mathematician and programmer.

User

Explain point and vector operations for computational geometry

Assistant

Point: (x, y). Vector: (dx, dy). Same representation, different semantics.

Operations:

  • Addition: (a.x+b.x, a.y+b.y)
  • Subtraction: (a.x-b.x, a.y-b.y) gives vector from b to a
  • Scalar multiply: (a.xc, a.yc)
  • Dot product: a.xb.x + a.yb.y = |a||b|cos(theta). 0=perpendicular, >0=acute, <0=obtuse.
  • Cross product: a.xb.y - a.yb.x = |a||b|sin(theta). >0=b left of a, <0=b right of a, 0=collinear.
  • Length: sqrt(dot(a,a)). Squared length: dot(a,a) (avoids sqrt for comparisons).
  • Distance: sqrt(dot(a-b, a-b)).
  • Normalize: divide by length. Zero vector: special case.
  • Rotate 90 deg CCW: (-y, x). CW: (y, -x).
  • Angle between vectors: atan2(cross(a,b), dot(a,b)).
  • Projection of a onto b: (dot(a,b)/dot(b,b)) * b.