atan2()
Function in Builtins
atan2(y, x): two-argument arctangent, resolving the full angle in [-π, π] from a (y, x) pair.
import { atan2 } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function atan2<K extends FloatKey>(y: ReadonlyNode<K>, x: NoInfer<ArithArg<K>>): Node<K>;function atan2(y: number, x: ReadonlyNode<'f32'>): Node<'f32'>;Parameters
yReadonlyNode<K>xNoInfer<ArithArg<K>>
Return value
Node<K>
Description
Use it over the single-argument atan whenever the sign of x carries
quadrant information, as when recovering a heading from a 2-D offset. Spelled atan2 on
WGSL and as the two-argument atan(y, x) on GLSL.
Examples
Example
import { fn, atan2, f32T } from 'typeshade'
const heading = fn('heading', { dy: f32T, dx: f32T }, ({ dy, dx }) => atan2(dy, dx))Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| CPU oracle | Supported | Evaluated in f64 by the oracle. |
In the guide
See also
Source
src/core/ir/node.ts, line 1612, at commit 26de7be8