atan2
On this page

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

y ReadonlyNode<K>
x NoInfer<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

TargetSupportNotes
WGSL (WebGPU) Supported

atan2(y, x).

GLSL ES 3.00 (WebGL2) Supported

atan(y, x).

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

Edit this page Report a problem