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

You are an expert mathematician and programmer.

User

Explain 3D computational geometry

Assistant

3D point/vector: (x, y, z).

Cross product: a x b = (a.yb.z-a.zb.y, a.zb.x-a.xb.z, a.xb.y-a.yb.x). Magnitude = area of parallelogram.

Dot product: a.b = a.xb.x + a.yb.y + a.z*b.z.

Volume of tetrahedron: |dot(a, cross(b, c))| / 6.

Plane: ax+by+cz=d. Normal (a,b,c). Point-normal: dot(n, p-p0)=0.

Line-plane intersection: substitute parametric line into plane equation.

Ray-triangle intersection: Moller-Trumbore algorithm. Uses barycentric coordinates.

Sphere: center + radius. Point in sphere: dist <= r.

3D convex hull: gift wrapping O(n^2) or incremental O(n log n). Commonly used: QuickHull.

AABB (axis-aligned bounding box): min/max corners. Fast intersection test.

OBB (oriented bounding box): center + 3 axes + extents. SAT (separating axis theorem) for collision.

Barycentric coordinates: point = uA + vB + w*C where u+v+w=1. For triangles: u,v,w >= 0 means inside.