Documentation / @interstellar-tools/constants / TWO_PI
Variable: TWO_PI
ts
const readonly TWO_PI: number;Defined in: math.ts:69
The circle constant τ (tau), equal to 2π (≈ 6.283185307179586). Useful for full rotations, radians-per-turn calculations, angular velocity, and other periodic math where factors of 2 arise naturally.
INFO
- Using τ often simplifies formulas that involve full cycles (e.g., Fourier analysis, rotations, oscillator phase), eliminating stray factors of 2.
TWO_PIis a runtime numeric constant; do not compare floating-point results using===when they involve trigonometric operations-prefer tolerance checks.
See
Examples
ts
import { TWO_PI } from '@interstellar-tools/constants';
// A quarter turn (π/2 radians)
const quarterTurn = 0.25 * TWO_PI; // ≈ 1.5707963267948966
// Point on the unit circle at 1/8 of a turn
const t = 1 / 8;
const angle = t * TWO_PI; // τ/8 = π/4
const x = Math.cos(angle); // ≈ 0.7071
const y = Math.sin(angle); // ≈ 0.7071ts
// Wrap any angle (radians) to [0, τ):
function wrapTau(theta: number): number {
const tau = TWO_PI;
return ((theta % tau) + tau) % tau;
}
// Convert turn fraction to radians:
const radiansFromTurns = (turns: number) => turns * TWO_PI;
// Angular frequency from frequency (Hz):
const omega = (f: number) => TWO_PI * f; // ω = τ f