mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-11 10:34:29 +08:00
parent
c68d622bbc
commit
3214fcfeb5
@ -80,12 +80,12 @@ def components_from_spherical_harmonics(
|
||||
components[..., 16] = 2.5033429417967046 * x * y * (xx - yy)
|
||||
components[..., 17] = 1.7701307697799304 * y * z * (3 * xx - yy)
|
||||
components[..., 18] = 0.9461746957575601 * x * y * (7 * zz - 1)
|
||||
components[..., 19] = 0.6690465435572892 * y * (7 * zz - 3)
|
||||
components[..., 19] = 0.6690465435572892 * y * z * (7 * zz - 3)
|
||||
components[..., 20] = 0.10578554691520431 * (35 * zz * zz - 30 * zz + 3)
|
||||
components[..., 21] = 0.6690465435572892 * x * z * (7 * zz - 3)
|
||||
components[..., 22] = 0.47308734787878004 * (xx - yy) * (7 * zz - 1)
|
||||
components[..., 23] = 1.7701307697799304 * x * z * (xx - 3 * yy)
|
||||
components[..., 24] = 0.4425326924449826 * (xx * (xx - 3 * yy) - yy * (3 * xx - yy))
|
||||
components[..., 24] = 0.6258357354491761 * (xx * (xx - 3 * yy) - yy * (3 * xx - yy))
|
||||
|
||||
return components
|
||||
|
||||
|
||||
16
tests/utils/test_math.py
Normal file
16
tests/utils/test_math.py
Normal file
@ -0,0 +1,16 @@
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from nerfstudio.utils.math import components_from_spherical_harmonics
|
||||
|
||||
|
||||
@pytest.mark.parametrize("components", list(range(1, 5 + 1)))
|
||||
def test_spherical_harmonics(components):
|
||||
torch.manual_seed(0)
|
||||
N = 1000000
|
||||
|
||||
dx = torch.normal(0, 1, size=(N, 3))
|
||||
dx = dx / torch.linalg.norm(dx, dim=-1, keepdim=True)
|
||||
sh = components_from_spherical_harmonics(components, dx)
|
||||
matrix = (sh.T @ sh) / N * 4 * torch.pi
|
||||
torch.testing.assert_close(matrix, torch.eye(components**2), rtol=0, atol=1e-2)
|
||||
Loading…
Reference in New Issue
Block a user