Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Polygon sdf #406

Merged
merged 13 commits into from
Jun 27, 2023
Prev Previous commit
Next Next commit
rewrite Polygon sdf
  • Loading branch information
mrcangye committed Jun 26, 2023
commit c198648b5d5f702bf17206af89122b9c34302f80
4 changes: 2 additions & 2 deletions ppsci/geometry/geometry_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,14 +624,14 @@ def sdf_func(self, points: np.ndarray) -> np.ndarray:
distance_vector = vector_in - vector_ij * np.clip(np.dot(vector_in, vector_ij) / np.dot(vector_ij, vector_ij), 0.0, 1.0)
distance = np.minimum(distance, np.dot(distance_vector, distance_vector))
# Calculate the inside and outside using the Odd-even rule
Odd_even_rule_number= np.array(
odd_even_rule_number= np.array(
[
points[n][1] >= self.vertices[i][1],
points[n][1] < self.vertices[j][1],
vector_ij[0] * vector_in[1] > vector_ij[1] * vector_in[0],
]
)
if Odd_even_rule_number.all() or np.all(~Odd_even_rule_number):
if odd_even_rule_number.all() or np.all(~odd_even_rule_number):
inside_tag *= -1.0
sdf_value[n] = inside_tag * np.sqrt(distance)
return -sdf_value
Expand Down