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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰[BUG]: Incorrect sdf calculation in Polygon geometry #140

Open
052279 opened this issue Mar 27, 2024 · 0 comments
Open

馃悰[BUG]: Incorrect sdf calculation in Polygon geometry #140

052279 opened this issue Mar 27, 2024 · 0 comments
Assignees
Labels
? - Needs Triage Need team to review and classify bug Something isn't working external Issues/PR filed by people outside the core team

Comments

@052279
Copy link

052279 commented Mar 27, 2024

Version

22.09

On which installation method(s) does this occur?

Docker

Describe the issue

When calculating the sdf of the polygon geometry, the sign of the sdf outside the polygon is reversed if there is only one (or an odd number) of points on the polygon whose y-coordinates match those of the point for which the sdf is calculated.

Minimum reproducible example

import numpy as np
from modulus.geometry.primitives_2d import Polygon

geo = Polygon([(0, 0), (1, 1), (1, -1)]) # triangle
point1 = {'x': np.array([[-1]], 'y': np.array([[0]])} # The y coordinate is the same as one point of the triangle
point2 = {'x': np.array([[0]], 'y': np.array([[2]])} # The x coordinate is the same as one point of the triangle
point3 = {'x': np.array([[0.01]], 'y': np.array([[2]])} # The x or y coordinates do not coincide with any point in the triangle

print(sdf.geo(point1, params={}) # sdf should be negative, but it is positive
print(sdf.geo(point2, params={})
print(sdf.geo(point3, params={})

geo = Polygon([(0, 0), (1, 1), (1, 0), (1, -1)]) # add dummy point to make 2 points with y-coordinate equal to point1

print(sdf.geo(point1, params={}) # sign of sdf becomes negative
print(sdf.geo(point2, params={})
print(sdf.geo(point3, params={})

Relevant log output

No response

Environment details

No response

Other/Misc.

No response

@052279 052279 added ? - Needs Triage Need team to review and classify bug Something isn't working labels Mar 27, 2024
@052279 052279 changed the title 馃悰[BUG]: sdf calculation in Polygon geometry 馃悰[BUG]: Incorrect sdf calculation in Polygon geometry Mar 27, 2024
@prem-krishnan prem-krishnan added the external Issues/PR filed by people outside the core team label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
? - Needs Triage Need team to review and classify bug Something isn't working external Issues/PR filed by people outside the core team
Projects
None yet
Development

No branches or pull requests

3 participants