Skip to content

NetFabric/NetFabric.Numerics / .agents/skills/coordinate-system-conversions

coordinate-system-conversions

Verified

Abstract math for converting between 2D and 3D coordinate systems. USE FOR: Cartesian to/from polar (r, θ); Cartesian to/from spherical (r, azimuth, polar/colatitude); azimuth vs. elevation vs. colatitude conventions; canonical range enforcement after conversion; precision near the origin and poles; choosing azimuth reference direction. DO NOT USE FOR: angle unit conversions (use angles-and-circular-arithmetic); geodetic (lat/lon) coordinates (use geodetic-coordinate-bounds); rotation representations (use 3d-rotation-theory).

Coordinate System Conversions

2D: Cartesian ↔ Polar

DirectionFormulas
Cartesian → Polarr = √(x²+y²); θ = atan2(y, x)
Polar → Cartesianx = r cos θ; y = r sin θ
  • r ≥ 0 always; r = 0 at origin (θ undefined)
  • θ ∈ (−π, π] from atan2; reduce to [0, 2π) for canonical polar form
  • Azimuth measured CCW from positive x-axis

3D: Cartesian ↔ Spherical

Physics convention (ISO 80000-2): r, polar angle θ from z-axis (colatitude), azimuth φ from x-axis

DirectionFormulas
Cartesian → Sphericalr = √(x²+y²+z²); θ = arccos(z/r); φ = atan2(y, x)
Spherical → Cartesianx = r sin θ cos φ; y = r sin θ sin φ; z = r cos θ

Canonical ranges: r ≥ 0, θ ∈ [0, π], φ ∈ [0, 2π) or (−π, π]

Convention Table (3D)

Name1st angle2nd angleUsed in
Physics (ISO)θ = colatitude from zφ = azimuth from xMath, physics
Geographylat = elevation from equatorlon = azimuth from meridianMaps, geodesy
This codebasepolar = colatitude from zazimuth = CCW from xSpherical coords

⚠ Azimuth and polar are always named explicitly — never assume which is which.

Singular Points

PointConditionIssue
Originr = 0θ and φ undefined
North/South poleθ = 0 or θ = πφ undefined (infinite azimuths map to same point)

3D: Cartesian ↔ Cylindrical (reference)

ρ = √(x²+y²);   φ = atan2(y, x);   z = z
x = ρ cos φ;    y = ρ sin φ;        z = z

Reference Files

FileLoad When
references/formulas.mdDerivations, Jacobians, differential area/volume elements
references/numerical-stability.mdNear-origin, near-pole precision, atan2 edge cases, r near zero
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall