Coordinate System Conversions

SkillDev tools

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).

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Coordinate System Conversions skill

What this skill tells your AI

The instructions your AI receives, as published by netfabric/netfabric.numerics in .agents/skills/coordinate-system-conversions/SKILL.md and read by ahel’s review.

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

Signals

GitHub stars
36
Forks
1
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
coordinate-system-conversions
Source
github.com/netfabric/netfabric.numerics
Coordinate System Conversions: Skill · ahel