game-vector-math-primitives
Apply vector math primitives for game rendering, collision, orientation, lighting, steering, and geometry predicates. Use when working with dot products, cross products, triple products, normals, projections, signed areas, signed volumes, facing checks, or vector normalization.
- License 许可
- MIT
- 最近更新
- 2026-06-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- game-vector-math-primitives
- license
- MIT
- metadata
- { "tags": "game-dev,game-geometry,vectors,rendering,collision", "version": "0.1.0", "category": "Game Development", "displayName": "Game Vector Math Primitives" }
- description
- Apply vector math primitives for game rendering, collision, orientation, lighting, steering, and geometry predicates. Use when working with dot products, cross products, triple products, normals, projections, signed areas, signed volumes, facing checks, or vector normalization.
- compatibility
- Codex, Claude Code, and other Agent Skills-compatible clients.
03 SKILL.md 正文
Game Vector Math Primitives
Use this skill when game code depends on vector operations whose geometric meaning matters. Prefer clear primitives and named intent over opaque formula paste.
Primary source: Geometry for Programmers by Oleksandr Kaleniuk (https://www.manning.com/books/geometry-for-programmers), transformed and paraphrased, especially chapters 2 and 9.
Core Workflow
- Identify the geometric question: angle, projection, side, area, normal, volume, distance, facing, or interpolation.
- Choose the primitive that answers that question directly.
- Check the input assumptions: dimensionality, coordinate space, units, handedness, normalization, and zero-length vectors.
- Preserve sign when orientation or sidedness matters. Discard sign only when the caller truly needs magnitude.
- Name intermediate values by meaning:
normal,signed_area2,light_factor,plane_distance,facing,projection_t. - Add tests that exercise orientation, reversed winding, orthogonal vectors, parallel vectors, and zero-length inputs.
Primitive Guide
Dot Product
Use dot products for:
- Projection onto a direction.
- Angle/facing tests.
- Lambert-style lighting coefficients.
- Distance along a ray or segment.
- Checking orthogonality: dot equals zero under the numeric policy.
If both vectors are normalized, the dot product is the cosine of the angle between them. Clamp before inverse cosine if a display angle is needed.
Cross Product And 2D Cross Scalar
Use cross products for:
- Surface normals from two triangle edges.
- Signed 2D orientation tests.
- Twice the signed area of a 2D triangle.
- Detecting parallel vectors through near-zero magnitude.
- Building tangent frames with a known handedness.
For 2D, use the scalar a.x * b.y - a.y * b.x instead of constructing fake 3D
vectors unless the codebase already uses a 3D type.
Triple Product
Use the scalar triple product for:
- Signed volume.
- Point side relative to an oriented plane.
- Point-to-plane distance when divided by the plane normal length.
- Tetrahedron orientation and containment-style predicates.
Keep the sign when side matters. Take absolute value only for unsigned volume or distance.
Guardrails
- Never normalize before checking vector length.
- Distinguish a direction vector from a point vector in naming and APIs.
- Keep normals in the same space as the vectors they are compared with.
- Recompute or transform normals correctly after nonuniform scale.
- Decide whether clockwise or counterclockwise winding is canonical.
- Use squared length when comparing distances and no square root is needed.
- Avoid inverse trigonometric functions in hot paths unless a real angle is required. Dot thresholds are usually cheaper.
Common Mistakes
- Treating every vector as normalized because examples used unit vectors.
- Losing useful sign information by taking absolute values too early.
- Mixing coordinate spaces in one dot or cross operation.
- Using angle calculations where a dot-product threshold would be simpler.
- Flipping triangle winding without updating normals, culling, or orientation predicates.
04 同仓库更多 Skills
android-emulator-qa
Use when validating Android feature flows in an emulator with adb-driven launch, input, UI-tree inspection, screenshots, and logcat capture.
supabase-postgres-best-practices
Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
sentry
Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.
render-workflows
Sets up, develops, tests, and deploys Render Workflows. Covers first-time scaffolding (via CLI or manual), SDK installation (Python or TypeScript), task patterns (retries, subtasks, fan-out), local development, Dashboard deployment, and troubleshooting. Use when a user wants to set up Render Workflows for the first time, scaffold a workflow service, add or modify workflow tasks, test workflows locally, or deploy workflows to Render.
render-web-services
Configures Render web services—port binding, TLS, health checks, custom domains, auto-deploy, PR previews, persistent disks, and deploy lifecycle. Use when the user needs to set up a web service, fix health check failures, add a custom domain, configure zero-downtime deploys, or troubleshoot port binding issues.
render-static-sites
Deploys and configures static sites on Render's global CDN—build commands, publish paths, SPA routing, redirects, custom headers, and PR previews. Use when the user needs to deploy a static site, set up a React/Vue/Hugo/Gatsby frontend, configure SPA fallback routing, add redirect rules, customize response headers, or choose between a static site and a web service for their frontend. Trigger terms: static site, CDN, SPA, single-page app, React deploy, Vue deploy, Hugo, Gatsby, Docusaurus, Jekyll, staticPublishPath.