length
이 페이지에서

length()

함수, 내장 함수 분류

length(v): Euclidean vector magnitude, |v|.

import { length } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

function length<K extends `vec${number}<f64>`>(v: ReadonlyNode<K>): Node<'f64'>;
function length<K extends `vec${number}<f32>`>(v: ReadonlyNode<K>): Node<'f32'>;

매개변수

v ReadonlyNode<K>

반환값

Node<'f64'>

설명

The return precision follows the operand: an f32 vector (vec2, vec3 or vec4) returns f32, and an emulated-double vec${N}<f64> returns f64, so an f64 operand keeps its precision without a cast.

예제

예제

import { fn, length, vec2, f32T } from 'typeshade'
const mag = fn('mag', { x: f32T, y: f32T }, ({ x, y }) => length(vec2(x, y)))

대상별 지원

대상지원비고
WGSL (WebGPU) 지원

length(v). Over f64 operands the fp64 pass rewrites it into its df64 helper.

GLSL ES 3.00 (WebGL2) 지원

length(v). Over f64 operands the fp64 pass rewrites it into its df64 helper.

CPU 오라클 지원

Evaluated in f64 by the oracle.

관련 가이드

함께 보기

소스

src/core/ir/node.ts, 1797행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고