atan2
이 페이지에서

atan2

함수

Returns the arctangent of y/x (in radians), using the signs of both arguments to determine the quadrant, taking arguments in the order (y, x).

이름마다 붙은 시그니처와 설명은 커밋 26de7be8의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

declare function atan2<V extends vec2 | vec3 | vec4>(a0: V, a1: V): V
declare function atan2<P0 extends number, P1 extends number>(a0: P0, a1: P1): ([P0] extends [boolean] ? bool : typeof f32Tag extends keyof P0 ? f32 : typeof i32Tag extends keyof P0 ? i32 : typeof u32Tag extends keyof P0 ? u32 : typeof f64Tag extends keyof P0 ? f64 : ([P1] extends [boolean] ? bool : typeof f32Tag extends keyof P1 ? f32 : typeof i32Tag extends keyof P1 ? i32 : typeof u32Tag extends keyof P1 ? u32 : typeof f64Tag extends keyof P1 ? f64 : number))
declare function atan2<T extends Numeric>(a0: T, a1: T): T

매개변수나 반환 위치에 쓰인 number는 스칼라가 들어갈 자리입니다. 앰비언트 파일은 GPU 스칼라를 브랜드가 붙은 number로 선언하고 그 브랜드는 선택이라서, 리터럴도 브랜드가 붙은 스칼라도 이 자리에 들어갑니다.

type f32 = number & { readonly [f32Tag]?: true }

직접 쓰는 선언에는 여전히 너비가 필요합니다. 필드나 매개변수에 number만 적으면 거부되며, 그 행과 컴파일러가 낸 메시지는 TypeScript에서 페이지에 있습니다.

시그니처에는 앰비언트 파일이 스스로 쓰려고 선언한 타입이 나올 수 있습니다. 아래가 그 선언입니다.

Numeric
type Numeric = number | vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u

매개변수

a0, a1처럼 자리로만 붙은 매개변수 이름은 앰비언트 파일이 만들어 낸 것입니다. 호출은 인자를 순서대로 넘기고 이름은 쓰지 않습니다.

  • a0 VP0T
  • a1 VP1T

반환값

V([P0] extends [boolean] ? bool : typeof f32Tag extends keyof P0 ? f32 : typeof i32Tag extends keyof P0 ? i32 : typeof u32Tag extends keyof P0 ? u32 : typeof f64Tag extends keyof P0 ? f64 : ([P1] extends [boolean] ? bool : typeof f32Tag extends keyof P1 ? f32 : typeof i32Tag extends keyof P1 ? i32 : typeof u32Tag extends keyof P1 ? u32 : typeof f64Tag extends keyof P1 ? f64 : number))T

설명

Compiles to atan2(y, x) on WGSL and atan(y, x) on GLSL.

대상별 출력

WGSL
atan2(a, b)
GLSL ES 3.00
atan(a, b)

예제

함께 보기

이 페이지 편집 문제 보고