acos
On this page

acos()

Function in Builtins

acos(x): arccosine of x, returning radians in [0, π], component-wise.

import { acos } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

const acos: <K extends FloatKey>(x: ReadonlyNode<K>) => Node<K>

Parameters

x ReadonlyNode<K>

Return value

Node<K>

Description

Like asin it is undefined outside x ∈ [-1, 1], so clamp the argument first when float error can push it a hair past ±1, as it can after a chain of floating-point operations.

Examples

Example

import { fn, acos, clamp, f32T } from 'typeshade'
const angle = fn('angle', { cosTheta: f32T }, ({ cosTheta }) => acos(clamp(cosTheta, -1, 1)))

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

acos(x).

GLSL ES 3.00 (WebGL2) Supported

acos(x).

CPU oracle Supported

Evaluated in f64 by the oracle.

See also

Source

src/core/ir/node.ts, line 1377, at commit 26de7be8

Edit this page Report a problem