Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.
This repository was archived by the owner on May 29, 2026. It is now read-only.

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

Description

@052279

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

Activity

  1. changed the title [-]馃悰[BUG]: sdf calculation in Polygon geometry[/-] [+]馃悰[BUG]: Incorrect sdf calculation in Polygon geometry[/+] on Mar 27, 2024
  2. added
    0 - BacklogIn queue waiting for assignment
    and removed
    ? - Needs TriageNeed team to review and classify
    on Apr 11, 2025
  3. ktangsali commented on Apr 29, 2026

    @ktangsali
    Collaborator

    Closing as part of the archival of this repository. The key components have been upstreamed to NVIDIA/physicsnemo. Please refer to the v2.0 Migration Guide and feel free to re-open your issue there if it is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

0 - BacklogIn queue waiting for assignmentbugSomething isn't workingexternalIssues/PR filed by people outside the core team

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions