PI
A high-precision floating-point constant representing the mathematical constant π (approx. 3.14159), fundamental to all calculations involving angles, rotations, circles, and spheres.
Core Advantages
Provides convenient, high-precision access to the mathematical constant π, eliminating the need to manually type an error-prone, less accurate 'magic number' and significantly enhancing code readability and clarity of intent.
Common Uses
Angle and Radian Conversion: Converting between degrees and radians, e.g., `degrees * PI / 180`.
Periodic Functions & Rotation: Used as input for `sin` and `cos` functions to create rotations, oscillations, or wave effects.
Procedural Texturing: Generating circular shapes, radial gradients, or ripple patterns in UV space.
Physical Lighting Models: Used in PBR (Physically-Based Rendering) for energy conservation in diffuse lighting calculations (e.g., dividing by PI).
How to adjust
PI is a mathematical constant with a fixed value. It should not and cannot be adjusted. All calculations that rely on it are based on its universally accepted, high-precision value.
Code Examples
1// Convert 90 degrees to radians for subsequent sin/cos calculations
2const radians = 90.0 * TSL.PI / 180.0;