Skip to content

Compute cotangent weights correctly for integer mesh vertices - #40

Open
antonsoo wants to merge 1 commit into
nmwsharp:masterfrom
antonsoo:fix/integer-cotangent-laplacian
Open

antonsoo wants to merge 1 commit into
nmwsharp:masterfrom
antonsoo:fix/integer-cotangent-laplacian

Conversation

@antonsoo

Copy link
Copy Markdown

Integer mesh coordinates can produce incorrect cotangent weights because edge subtraction and products run in the input dtype. For example, a right triangle with vertices [[0, 0, 0], [30, 0, 0], [0, 40, 0]] has negative diagonal stiffness with int8 coordinates, while the same floating coordinates produce the expected matrix.

Promote integer storage before subtracting coordinates, then convert the exact edge differences to float before dot/cross products. This also preserves short edges at large 64-bit offsets. Floating inputs and sparse assembly keep their existing paths.

Validation:

  • Analytic right-triangle checks cover all integer widths, both windings, denominator regularization and large offsets; 27 subcases fail before the fix.
  • The complete project suite passes all 13 tests on Python 3.12/NumPy 2.5 with the current native Debug build and Python 3.9/NumPy 1.26 with the released native binding and current Python source.
  • On the recorded Bunny mesh, 24 incorrect integer stiffness/diffusion configurations now match an independent finite-element reference. All 16 previously working reports, including every step of the 12-step diffusion and eight floating controls, remain exact on both profiles.
  • This change merges cleanly with Compute mesh areas correctly for integer vertices #39; both recorded-mesh workloads retain all 80 complete result records, and the combined suite passes all 15 tests.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant