Skip to content

NetFabric/NetFabric.Numerics / .agents/skills/vector-algebra

vector-algebra

Verified

Abstract math for vector algebra in 2D and 3D Euclidean space. USE FOR: implementing vector operations (add, subtract, negate, scalar multiply/divide); dot product and geometric interpretation; 3D cross product; 2D pseudo-cross product (scalar z-component); vector magnitude and normalization; angle between two vectors; linear interpolation; checking zero/unit/finite vectors. 2D is a special case of 3D with z=0. DO NOT USE FOR: quaternion operations (use quaternion-algebra); rotation representations (use 3d-rotation-theory); coordinate system conversions (use coordinate-system-conversions).

FileKindSize
SKILL.mdskill md2.5 KB
references/formulas.mdmarkdown2.0 KB
references/numerical-stability.mdmarkdown2.3 KB

references/formulas.md

View on GitHub
# Vector Algebra — Formulas

## Scalar (Dot) Projection

Projection of **a** onto **b**:
```
proj_b(a) = (a · b / ‖b‖²) · b        (vector projection)
scalar    = a · b / ‖b‖                (signed scalar length)
```

## Vector Rejection

Component of **a** perpendicular to **b**:
```
rej_b(a) = a − proj_b(a)
```

## Scalar Triple Product (3D)

```
a · (b × c) = det([a b c])
```

| Value | Meaning |
|-------|---------|
| > 0 | a, b, c form right-handed triple |
| = 0 | Vectors are coplanar |
| < 0 | Left-handed triple |

## Distance Between Points

```
d(P, Q)  = ‖Q − P‖  = √((Qₓ−Pₓ)² + (Qᵧ−Pᵧ)²[+ (Q_z−P_z)²])
d²(P, Q) = (Qₓ−Pₓ)² + (Qᵧ−Pᵧ)²[+ (Q_z−P_z)²]   (avoid sqrt for comparison)
```

## Cross Product Properties

```
a × a = 0
a × b = −(b × a)                    (anti-commutative)
a × (b + c) = a×b + a×c            (distributive)
(ka) × b = k(a × b)                 (scalar associative)
‖a × b‖² = ‖a‖²‖b‖² − (a·b)²       (Lagrange identity)
```

Right-hand rule: curl fingers from **a** toward **b**; thumb points in direction of **a**×**b**.

## Cross Product for Parallel Test

`a × b = 0` iff **a** and **b** are parallel (or one is zero).

## 2D Pseudo-Cross Product

```
a ⊗ b = aₓbᵧ − aᵧbₓ     (z-component of 3D cross product)
```

Sign interpretation:
- Positive: **b** is CCW from **a** (left turn)
- Negative: **b** is CW from **a** (right turn)
- Zero: **b** is parallel to **a**

## Angle Between Vectors (Full Formula)

The arccos formula gives ∈ [0, π] and cannot distinguish CCW from CW.

For a signed angle in 2D: `θ = atan2(a⊗b, a·b)` gives ∈ (−π, π].

## Normalization

```
v̂ = v / ‖v‖
```

Pre-condition: `‖v‖ ≠ 0`. Post-condition: `‖v̂‖ = 1` (within floating-point tolerance).

`IsNormalized(v, ε)`: `|‖v‖ − 1| < ε`

## Component-wise Clamp

```
clamp(v, min, max) = (clamp(vₓ, minₓ, maxₓ), clamp(vᵧ, minᵧ, maxᵧ)[, clamp(v_z, min_z, max_z)])
```

This is NOT the same as clamping the magnitude.
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall