๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ“– Theory/Computer Vision

์ง๊ฐ์ขŒํ‘œ๊ณ„ & ๊ตฌ๋ฉด์ขŒํ‘œ๊ณ„ | ์ขŒํ‘œ ๋ณ€ํ™˜

by ๋ญ…์ฆค 2024. 3. 29.
๋ฐ˜์‘ํ˜•

์ง๊ฐ ์ขŒํ‘œ๊ณ„์™€ ๊ตฌ๋ฉด ์ขŒํ‘œ๊ณ„๋Š” ์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ ๋ฐ ๋ถ„์„์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์ขŒํ‘œ ์‹œ์Šคํ…œ์ด๋‹ค.

 


์ง๊ฐ ์ขŒํ‘œ๊ณ„(Rectangular Coordinates)

  • ์ด๋ฏธ์ง€๋ฅผ ๋‹ค๋ฃฐ ๋•Œ ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ์ขŒํ‘œ ์‹œ์Šคํ…œ
  • ์ด๋ฏธ์ง€๋Š” ํ”ฝ์…€๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์œผ๋ฉฐ, ๊ฐ ํ”ฝ์…€์€ ํ–‰(row)๊ณผ ์—ด(column)์˜ ์ธ๋ฑ์Šค๋กœ ํ‘œํ˜„
  • ์ผ๋ฐ˜์ ์œผ๋กœ ์™ผ์ชฝ ์ƒ๋‹จ ๋ชจ์„œ๋ฆฌ๊ฐ€ (0, 0)์œผ๋กœ ์‹œ์ž‘ํ•˜์—ฌ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๊ฐˆ์ˆ˜๋ก ์—ด(column)์ด ์ฆ๊ฐ€ํ•˜๊ณ  ์•„๋ž˜๋กœ ๊ฐˆ์ˆ˜๋ก ํ–‰(row)์ด ์ฆ๊ฐ€

 

 

๊ตฌ๋ฉด ์ขŒํ‘œ๊ณ„(Spherical Coordinates)

  • ๊ตฌ๋ฉด ์ขŒํ‘œ๊ณ„๋Š” ์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉ๋˜์ง€๋Š” ์•Š์ง€๋งŒ, ์ปดํ“จํ„ฐ ๋น„์ „์˜ ํŠน์ • ๋ถ„์•ผ์—์„œ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Œ
  • ์ฃผ๋กœ 3D ๊ณต๊ฐ„์—์„œ ์‚ฌ์šฉ๋˜๋ฉฐ, ์œ„๋„(latitude), ๊ฒฝ๋„(longitude), ๊ณ ๋„(altitude)์™€ ๊ฐ™์€ ์ขŒํ‘œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ง€๊ตฌ ํ‘œ๋ฉด์„ ๋‚˜ํƒ€๋ƒ„
  • ํšŒ์ „ ๋ฐ ๋ฐฉํ–ฅ์„ ๋‹ค๋ฃจ๋Š” ๋ฐ ์œ ์šฉํ•˜๋ฉฐ, ์นด๋ฉ”๋ผ์˜ ์œ„์น˜ ๋ฐ ๋ฐฉํ–ฅ์„ ์ •ํ™•ํ•˜๊ฒŒ ์ถ”์ ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Œ
  • ์˜ˆ๋ฅผ ๋“ค์–ด, ์ด๋ฏธ์ง€์˜ ํŠน์ง•์ ์„ ๊ฐ์ง€ํ•˜๊ณ  ์ถ”์ ํ•˜๋Š” ์ž‘์—…์—์„œ๋Š” ์ง๊ฐ ์ขŒํ‘œ๊ณ„๊ฐ€ ์ฃผ๋กœ ์‚ฌ์šฉ๋˜์ง€๋งŒ, 3D ๊ฐ์ฒด์˜ ์œ„์น˜ ๋ฐ ๋ฐฉํ–ฅ์„ ์ถ”์ •ํ•˜๋Š” ์ž‘์—…์—์„œ๋Š” ๊ตฌ๋ฉด ์ขŒํ‘œ๊ณ„๊ฐ€ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Œ

์ง๊ฐ์ขŒํ‘œ๊ณ„ → ๊ตฌ๋ฉด์ขŒํ‘œ๊ณ„ ์ขŒํ‘œ ๋ณ€ํ™˜

 

 

๊ตฌ๋ฉด์ขŒํ‘œ๊ณ„ → ์ง๊ฐ์ขŒํ‘œ๊ณ„ ์ขŒํ‘œ ๋ณ€ํ™˜

 

 

์ฝ”๋“œ ์˜ˆ์‹œ

import math

# ์ง๊ฐ ์ขŒํ‘œ๊ณ„์—์„œ ๊ตฌ๋ฉด ์ขŒํ‘œ๊ณ„๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
def rectangular_to_spherical(x, y, z):
    # ๊ตฌ์˜ ๋ฐ˜์ง€๋ฆ„ ๊ณ„์‚ฐ
    r = math.sqrt(x**2 + y**2 + z**2)
    # ์œ„๋„ ๊ณ„์‚ฐ
    phi = math.acos(z / r)
    # ๊ฒฝ๋„ ๊ณ„์‚ฐ
    theta = math.atan2(y, x)
    return phi, theta

# ๊ตฌ๋ฉด ์ขŒํ‘œ๊ณ„์—์„œ ์ง๊ฐ ์ขŒํ‘œ๊ณ„๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
def spherical_to_rectangular(phi, theta, r):
    # ์ง๊ฐ ์ขŒํ‘œ x, y, z ๊ณ„์‚ฐ
    x = r * math.sin(phi) * math.cos(theta)
    y = r * math.sin(phi) * math.sin(theta)
    z = r * math.cos(phi)
    return x, y, z

# ์˜ˆ์‹œ: ์ง๊ฐ ์ขŒํ‘œ (1, 1, 1)๋ฅผ ๊ตฌ๋ฉด ์ขŒํ‘œ๋กœ ๋ณ€ํ™˜
rectangular_x = 1
rectangular_y = 1
rectangular_z = 1
phi, theta = rectangular_to_spherical(rectangular_x, rectangular_y, rectangular_z)
print("๊ตฌ๋ฉด ์ขŒํ‘œ (phi, theta):", phi, theta)

# ์˜ˆ์‹œ: ๊ตฌ๋ฉด ์ขŒํ‘œ (pi/4, pi/4)๋ฅผ ์ง๊ฐ ์ขŒํ‘œ๋กœ ๋ณ€ํ™˜
spherical_phi = math.pi / 4  # 45๋„
spherical_theta = math.pi / 4  # 45๋„
radius = 1  # ์˜ˆ์‹œ๋กœ ๋ฐ˜์ง€๋ฆ„์„ 1๋กœ ๊ฐ€์ •
x, y, z = spherical_to_rectangular(spherical_phi, spherical_theta, radius)
print("์ง๊ฐ ์ขŒํ‘œ (x, y, z):", x, y, z)
๋ฐ˜์‘ํ˜•