Vector

Vector에 λŒ€ν•œ 정보λ₯Ό λ‹€λ£¨λŠ” κ°μ²΄μ—μš”.

μ—°μ‚°μž

Vector = Vector + Vector

두 벑터 값을 λ”ν•΄μ„œ κ·Έ 값을 λ¦¬ν„΄ν•΄μ€˜μš”.

Vector = Vector - Vector

μ•žμ— λ²‘ν„°μ—μ„œ λ’€μ˜ 벑터λ₯Ό λΊ€ 값을 λ¦¬ν„΄ν•΄μ€˜μš”.

Vector = Vector * Vector

두 벑터 값을 κ³±ν•΄μ„œ κ·Έ 값을 λ¦¬ν„΄ν•΄μ€˜μš”.

Vector = Vector * number

벑터와 number 값을 κ³±ν•΄μ„œ κ·Έ 값을 λ¦¬ν„΄ν•΄μ€˜μš”.

Vector = -Vector

λ²‘ν„°μ˜ 값을 λΆ€μ •μœΌλ‘œ λ§Œλ“€μ–΄μ„œ κ·Έ 값을 λ¦¬ν„΄ν•΄μ€˜μš”.

Vector = Vector + number

λ²‘ν„°μ˜ κ°’κ³Ό number값을 λ”ν•΄μ„œ κ·Έ 값을 λ¦¬ν„΄ν•΄μ€˜μš”.

Vector = Vector - number

λ²‘ν„°μ˜ κ°’μ—μ„œ number값을 λΊ€ 값을 λ¦¬ν„΄ν•΄μ€˜μš”.

Vector = Vector / number

λ²‘ν„°μ˜ κ°’μ—μ„œ number을 λ‚˜λˆˆ 값을 λ¦¬ν„΄ν•΄μ€˜μš”. (0μœΌλ‘œλŠ” λ‚˜λˆŒ 수 μ—†μ–΄μš”.)

속성

Size

λ²‘ν„°μ˜ ν¬κΈ°μ—μš”.

-- μƒ˜ν”Œ --

local pos = Vector.new(200, -100, 900)
print(pos.Size)

SqrSize

-- μƒ˜ν”Œ --

local pos = Vector.new(200, -100, 900)
print(pos.SqrSize)

X

X μ’Œν‘œμ—μš”.

Y

Y μ’Œν‘œμ—μš”.

Z

Z μ’Œν‘œμ—μš”.

-- μƒ˜ν”Œ --

local pos1 = Vector.new(1, 2, 3) --pos1.X = 1, pos1.Y = 2, pos1.Z = 3둜 ν• λ‹ΉλΌμš”.
local pos2 = Vector.new(3)       --pos2.X = 3, pos2.Y = 3, pos2.Z = 3둜 ν• λ‹ΉλΌμš”.
local pos3 = pos1 + pos2         --pos3.X = 4, pos3.Y = 5, pos3.Z = 6둜 ν• λ‹ΉλΌμš”.

local cube = Workspace.Cube
local cubeTransform = cube.Transform
cubeTransform.Location = Vector.new(400, 0, 100)
cube.Transform = cubeTransform --였브젝트의 μœ„μΉ˜λ₯Ό μ„€μ •ν•΄μš”.

local pos4 = Vector.new()        --pos4.X = 0,  pos4.Y = 0, pos4.Z = 0둜 ν• λ‹ΉλΌμš”.
pos4.X = 10                      --pos4.X = 10, pos4.Y = 0, pos4.Z = 0둜 ν• λ‹ΉλΌμš”.
pos4.Normalize()                 --pos4.X = 1,  pos4.Y = 0, pos4.Z = 0둜 ν• λ‹ΉλΌμš”.

μƒμ„±μž

Vector new(number X, number Y, number Z)

Vectorλ₯Ό X, Y, Z μ’Œν‘œκ°’μ„ μ΄μš©ν•΄μ„œ μƒμ„±ν•΄μ€˜μš”. (생성할 Xμ’Œν‘œ κ°’, 생성할 Yμ’Œν‘œ κ°’, 생성할 Zμ’Œν‘œ κ°’)

Vector new(number Value)

Vectorλ₯Ό Value값을 μ΄μš©ν•΄μ„œ μƒμ„±ν•΄μ€˜μš”. (생성할 Value κ°’)

Vector new()

Vector의 X, Y, Z μ’Œν‘œλ₯Ό 0μœΌλ‘œν•΄μ„œ μƒμ„±ν•΄μ€˜μš”.

-- μƒ˜ν”Œ --

local pos1 = Vector.new(200, -100, 900)
local pos2 = Vector.new(200) --X = 200, Y = 200, Z = 200으둜 ν• λ‹ΉλΌμš”.
local pos3 = Vector.new()    --μ „λΆ€ 0으둜 ν• λ‹ΉλΌμš”.

ν•¨μˆ˜

void Normalize()

λ‹¨μœ„λ₯Ό 1둜 μ •κ·œν™” μ‹œμΌœμ£ΌλŠ” ν•¨μˆ˜μ—μš”.

-- μƒ˜ν”Œ --

local pos = Vector.new(200, -100, 900)
print(pos)

pos:Normalize()
print(pos)

number CosineAngle2D(Vector Other)

두 λ²‘ν„°μ˜ XY ν‰λ©΄μ˜ μ‚¬μž‡κ°μ˜ cos 값을 λ¦¬ν„΄ν•΄μ€˜μš”. (μ‚¬μž‡κ°μ„ ꡬ할 벑터)

-- μƒ˜ν”Œ --

local cube = Workspace.Cube
local characterPos = character.Transform.Location
local targetPos = cube.Transform.Location

local angle = characterPos:CosineAngle2D(targetPos)
print(angle)

string ToString(Vector Other)

"R:κ°’ , G:κ°’ , B:κ°’, A:κ°’" ν˜•νƒœλ‘œ string 을 λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local vector = Vector.new(300, 0, 300)
print("Vector : " .. vector:ToString())

number Dot(Vector Other)

other vector μ™€μ˜ 내적값을 λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local vector = Vector.new(300, 0, 300)
local otherVector = Vector.new(600, 0, 300)

local result = vector:Dot(otherVector)
print("Vector:Dot : ", result)

vector Cross(Vector Other)

othervector μ™€μ˜ 외적값을 λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local vector = Vector.new(300, 0, 300)
local otherVector = Vector.new(600, 0, 300)

local result = vector:Cross(otherVector)
print("Vector:Cross : ", result)

number Distance(Vector Other)

othervector μ™€μ˜ 거리값을 λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local vector = Vector.new(300, 0, 300)
local otherVector = Vector.new(600, 0, 300)

local result = vector:Distance(otherVector)
print("Vector:Distance : ", result)

number SqrDistance(Vector Other)

othervector μ™€μ˜ 거리 μ œκ³±κ°’μ„ λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local vector = Vector.new(300, 0, 300)
local otherVector = Vector.new(600, 0, 300)

local result = vector:SqrDistance(otherVector)
print("Vector:SqrDistance : ", result)

number Angle(Vector Other)

othervector μ™€μ˜ 사이각을 λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local vector = Vector.new(300, 0, 300)
local otherVector = Vector.new(600, 0, 300)

local result = vector:Angle(otherVector)
print("Vector:Angle : ", result)

vector Reflect(Vector Normal)

normal 에 λΆ€λ”ͺνžˆλŠ” λ°˜μ‚¬κ°μ„ λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local vector = Vector.new(300, 0, 300)
local otherVector = Vector.new(600, 0, 300)

local result = vector:Reflect(otherVector)
print("Vector:Reflect : ", result)

vector Clone()

같은 벑터λ₯Ό μƒˆλ‘œ μƒμ„±ν•΄μ„œ λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local Vector1 = Vector.new(100, 100, 100)
local NewVector = Vector1:Clone(Vector1)
print("Clone Vector : ", NewVector)

void SizeLimit(number max)

λ²‘ν„°μ˜ 크기λ₯Ό max둜 μ œν•œν•΄μš”. ((X^2 + Y^2 + Z^2)^(1 / 2)) = Max

-- μƒ˜ν”Œ --

local Vector1 = Vector.new(100, 100, 100)
Vector1:SizeLimit(50)
print("Size Limit : ", Vector1)

vector RotateAxisX(number angle)

X좕을 κ³ μ •μœΌλ‘œ ν•΄μ„œ 벑터 νšŒμ „ν•œ λ‹€μŒ λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local RotateX = Vector1:RotateAxisX(10)
print("RotateAxisX : ", RotateX)

vector RotateAxisY(number angle)

Y좕을 κ³ μ •μœΌλ‘œ ν•΄μ„œ 벑터 νšŒμ „ν•œ λ‹€μŒ λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local RotateY = Vector1:RotateAxisY(10)
print("RotateAxisY : ", RotateY)

vector RotateAxisZ(number angle)

Z좕을 κ³ μ •μœΌλ‘œ ν•΄μ„œ 벑터 νšŒμ „ν•œ λ‹€μŒ λ¦¬ν„΄ν•΄μš”.

-- μƒ˜ν”Œ --

local RotateZ = Vector1:RotateAxisZ(10)
print("RotateAxisZ : ", RotateZ)

number SignedAngle2D(Vector othervector)

othervector μ™€μ˜ 사이각을 λ¦¬ν„΄ν•΄μš”. (음수 포함)

-- μƒ˜ν”Œ --

local Vector2 = Vector.new(100, 0, 100)
local Vector3 = Vector.new(0, 100, 100)
local SignedAngle = Vector2:SignedAngle2D(Vector3)
print("SignedAngle2D : ", SignedAngle)

vector zero()

zero 벑터λ₯Ό λ¦¬ν„΄ν•΄μš”. (0,0,0)

-- μƒ˜ν”Œ --

local Zero = Vector.zero()
print("Vector Zero : ", Zero)

vector one()

one 벑터λ₯Ό λ¦¬ν„΄ν•΄μš”. (1,1,1)

-- μƒ˜ν”Œ --

local One = Vector.one()
print("Vector One : ", One)

vector forward()

forward 벑터λ₯Ό λ¦¬ν„΄ν•΄μš”. (1,0,0)

-- μƒ˜ν”Œ --

local Forward = Vector.forward()
print("Vector Forward : ", Forward)

vector right()

right 벑터λ₯Ό λ¦¬ν„΄ν•΄μš”. (0,1,0)

-- μƒ˜ν”Œ --

local Right = Vector.right()
print("Vector Right : ", Right)

vector up()

up 벑터λ₯Ό λ¦¬ν„΄ν•΄μš”. (0,0,1)

-- μƒ˜ν”Œ --

local Up = Vector.up()
print("Vector Up : ", Up)

Last updated