acos()
Function in Builtins
acos(x): arccosine of x, returning radians in [0, π], component-wise.
import { acos } from 'typeshade/core/ir'
This export returns an IR node. A "use typeshade" file calls the builtin itself: acos()
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
const acos: <K extends FloatKey>(x: ReadonlyNode<K>) => Node<K>Parameters
xReadonlyNode<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/core/ir'
const angle = fn('angle', { cosTheta: f32T }, ({ cosTheta }) => acos(clamp(cosTheta, -1, 1)))Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| CPU oracle | Supported | Evaluated in |
See also
Source
src/core/ir/node.ts, line 1148, at commit af54ddad5