soravux / skylibs

Python library to handle 360° environment maps
GNU Lesser General Public License v3.0
86 stars 29 forks source link

New pixel transformation functions #32

Closed IanMaquignaz closed 1 year ago

IanMaquignaz commented 1 year ago

resolves #31

+-> added pixel2world() +-> added world2pixel() +-> fixed error in sunPosFromEnvmap()

IanMaquignaz commented 1 year ago

Proof:

Error case:

>>> n = 1024
>>> e = envmap.EnvironmentMap(n, 'skyangular')
>>> u = np.linspace(0,n-1, n)
>>> w_x, w_y, w_z, w_v = e.world2world(u/n, u/n)
>>> p_u, p_v = e.world2pixel(w_x, w_y, w_z)
>>> np.abs(u - p_u).sum()
3.0

Correct case:

>>> n = 1024
>>> e = envmap.EnvironmentMap(n, 'skyangular')
>>> u = np.linspace(0,n-1, n)
>>> w_x, w_y, w_z, w_v = e.pixel2world(u, u)
>>> p_u, p_v = e.world2pixel(w_x, w_y, w_z)
>>> np.abs(u - p_u).sum()
0.0
soravux commented 1 year ago

Thank you!