# Vector2

## Overview

Vector2는 X, Y의 두 축 값을 통해 2차원 공간상의 벡터를 표현하는 데이터 타입으로, 위치, 방향, 속도, 힘과 같은 다양한 2D 데이터를 다루는 데 사용되며, 공간 내 좌표 및 이동 계산, 물리 연산 등 여러 시스템 전반에서 핵심적으로 활용됩니다.

## Constructors

### new

전달된 X, Y 값을 기반으로 새로운 벡터를 생성하여 반환합니다.

#### Parameters

| `number` x | X축 좌표 값입니다. |
| ---------- | ----------- |
| `number` y | Y축 좌표 값입니다. |

#### Return

| `Vector2` | 생성된 Vector2입니다. |
| --------- | --------------- |

#### Code Samples

```lua
local Vector = Vector2.new(3, 7)
print(Vector)
```

## Properties

### one

`Vector2`

모든 축 값이 1으로 구성된 벡터입니다. (1, 1)

#### Code Samples

```lua
local OneVector = Vector2.one
print(OneVector)
```

### X

`number`

X축 좌표 값입니다.

#### Code Samples

```lua
local Vector = Vector2.new(5, 10)
print(Vector.X)
```

### xAxis

`Vector2`

X축 방향으로만 1의 값을 가지며, 나머지 축 값은 모두 0으로 설정된 Vector2입니다. (1, 0)

#### Code Samples

```lua
local XAxis = Vector2.xAxis
print(XAxis)
```

### Y

`number`

Y축 좌표 값입니다.

#### Code Samples

```lua
local Vector = Vector2.new(5, 10)
print(Vector.Y)
```

### yAxis

`Vector2`

Y축 방향으로만 1의 값을 가지며, 나머지 축 값은 모두 0으로 설정된 Vector2입니다. (0, 1)

#### Code Samples

```lua
local YAxis = Vector2.yAxis
print(YAxis)
```

### zero

`Vector2`

모든 축 값이 0으로 구성된 벡터입니다. (0, 0)

#### Code Samples

```lua
local ZeroVector = Vector2.zero
print(ZeroVector)
```

## Methods

### Lerp

현재 벡터와 목표 벡터 사이를 선형 보간 방식으로 alpha 비율에 따라 계산한 위치를 새로운 벡터로 반환합니다.

#### Parameters

| `Vector2` GoalValue | 보간의 대상이 되는 목표 Vector2입니다. |
| ------------------- | ------------------------- |
| `number` Alpha      | 보간 비율을 나타내는 값입니다.         |

#### Return

| `Vector2` | 생성된 Vector2입니다. |
| --------- | --------------- |

#### Code Samples

```lua
local a = Vector2.new(0, 0)
local b = Vector2.new(10, 10)
print("Lerp:", a:Lerp(b, 0.3)) --> Output: 3, 3
```

### Slerp

현재 벡터와 목표 벡터 사이를 구면 선형 보간 방식으로 alpha 비율에 따라 계산한 위치를 새로운 벡터로 반환합니다.

Lerp는 직선 경로를 따라 보간하지만, Slerp는 단위 구면 위의 곡선을 따라 보간하기 때문에 회전 방향 변화가 더 부드럽고 일정합니다.

#### Parameters

| `Vector2` GoalValue | 보간의 대상이 되는 목표 Vector2입니다. |
| ------------------- | ------------------------- |
| `number` Alpha      | 보간 비율을 나타내는 값입니다.         |

#### Return

| `Vector2` | 생성된 Vector2입니다. |
| --------- | --------------- |

#### Code Samples

```lua
local a = Vector2.new(1, 0)
local b = Vector2.new(0, 1)
print("Slerp:", a:Slerp(b, 0.5)) --> Output: 0.707107, 0.707107
```

## Events


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overdare.com/korean/development/api-reference/datatype/vector2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
