Skip to content

Commit a73bda7

Browse files
authored
[MISC] Import math module instead of constants to avoid violating gstaichi pure checker. (#1812)
1 parent 699f8df commit a73bda7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

genesis/engine/solvers/rigid/support_field_decomp.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import TYPE_CHECKING
2-
from math import pi
1+
import math
32
from dataclasses import dataclass
3+
from typing import TYPE_CHECKING
44

5-
import numpy as np
65
import gstaichi as ti
6+
import numpy as np
77

88
import genesis as gs
99
import genesis.utils.geom as gu
@@ -36,8 +36,8 @@ def __init__(self, rigid_solver: "RigidSolver") -> None:
3636

3737
def _get_direction_grid(self):
3838
support_res = self._support_field_static_config.support_res
39-
theta = np.arange(support_res) / support_res * 2 * pi - pi
40-
phi = np.arange(support_res) / support_res * pi
39+
theta = np.arange(support_res) / support_res * 2 * math.pi - math.pi
40+
phi = np.arange(support_res) / support_res * math.pi
4141

4242
spherical_coords = np.zeros([support_res, support_res, 2])
4343
spherical_coords[:, :, 0] = theta[:, None]
@@ -162,8 +162,8 @@ def _func_support_mesh(
162162
v = ti.Vector([0.0, 0.0, 0.0], dt=gs.ti_float)
163163
vid = 0
164164

165-
ii = (theta + pi) / pi / 2 * support_res
166-
jj = phi / pi * support_res
165+
ii = (theta + math.pi) / math.pi / 2 * support_res
166+
jj = phi / math.pi * support_res
167167

168168
for i4 in range(4):
169169
i, j = gs.ti_int(0), gs.ti_int(0)
@@ -356,8 +356,8 @@ def _func_count_supports_mesh(
356356
support_res = gs.ti_int(support_field_static_config.support_res)
357357
dot_max = gs.ti_float(-1e20)
358358

359-
ii = (theta + pi) / pi / 2 * support_res
360-
jj = phi / pi * support_res
359+
ii = (theta + math.pi) / math.pi / 2 * support_res
360+
jj = phi / math.pi * support_res
361361

362362
count = gs.ti_int(0)
363363
for i4 in range(4):

0 commit comments

Comments
 (0)