---
title: "atan2(): typeshade/core/ir의 IR 빌더 함수, TypeShade 컴파일러 API"
description: "atan2, typeshade/core/ir의 IR 빌더 함수입니다. atan2(y, x): 인수가 두 개인 아크탄젠트입니다. (y, x) 쌍에서 [-π, π] 범위의 전체 각을 구합니다."
url: https://typeshade.dev/ko/api/atan2/
language: ko
---

# `atan2()`

함수, 내장 함수 분류

`atan2`(y, x): 인수가 두 개인 아크탄젠트입니다. (y, x) 쌍에서 \[-π, π\] 범위의 전체 각을 구합니다.

`import { atan2 } from 'typeshade/core/ir'`

이 export는 IR 노드를 반환합니다. `"use typeshade"` 파일에서는 내장 함수 자체를 부릅니다: [`atan2()`](https://typeshade.dev/ko/reference/functions/atan2/)

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

```ts
function atan2<K extends FloatKey>(y: ReadonlyNode<K>, x: NoInfer<ArithArg<K>>): Node<K>;
function atan2(y: number, x: ReadonlyNode<'f32'>): Node<'f32'>;
```

## 매개변수

**`y` `ReadonlyNode<K>`**

**`x` `NoInfer<ArithArg<K>>`**

## 반환값

`Node<K>`

## 설명

`x`의 부호가 사분면 정보를 담고 있으면 단일 인수 형태인 [`atan`](https://typeshade.dev/ko/api/atan/) 대신 이 함수를 써야 합니다. 예를 들어 2차원 오프셋에서 방향을 구할 때가 그렇습니다. WGSL에서는 `atan2`로, GLSL에서는 두 인수를 받는 `atan(y, x)`로 씁니다.

## 예제

### 예제

```ts
import { fn, atan2, f32T } from 'typeshade/core/ir'

const heading = fn('heading', { dy: f32T, dx: f32T }, ({ dy, dx }) => atan2(dy, dx))
```

## 대상별 지원

| 대상 | 지원 | 비고 |
| --- | --- | --- |
| WGSL (WebGPU) | 지원 | `atan2(y, x)`. |
| GLSL ES 3.00 (WebGL2) | 지원 | `atan(y, x)`. |
| CPU 오라클 | 지원 | 오라클이 `f64`로 계산합니다. |

## 함께 보기

- [`atan2()`](https://typeshade.dev/ko/reference/functions/atan2/)
- [`atan`](https://typeshade.dev/ko/api/atan/)

## 소스

[`src/core/ir/node.ts`, 1383행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1383), 커밋 af54ddad5 기준
