conan/utils/util.py

32 lines
744 B
Python

import numpy as np
def sperical2equirec(theta, phi, img_w, img_h):
u = np.deg2rad(theta) / (2 * np.pi)
v = np.deg2rad(phi) / np.pi
x = u * img_w
y = v * img_h
return x, y
def equirec2spherical(x, y, img_w, img_h):
# Normalize coordinates
u = x / img_w
v = y / img_h
# Calculate spherical coordinates from normalized coordinates
# theta is horizontal angle, phi is polar angle
theta = u * 2 * np.pi
phi = v * np.pi
return np.rad2deg(theta), np.rad2deg(phi)
def get_circle(radius):
""" helper function returns circle to x, y coordinates"""
theta = np.linspace(0, 2 * np.pi, 100)
x = radius * np.cos(theta)
y = radius * np.sin(theta)
return np.array(x), np.array(y)