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

Zero values end up as non-zero after meshing #246

Closed
therealprof opened this issue Feb 23, 2022 · 1 comment
Closed

Zero values end up as non-zero after meshing #246

therealprof opened this issue Feb 23, 2022 · 1 comment
Labels
status: duplicate This issue or pull request already exists

Comments

@therealprof
Copy link
Contributor

Trying to debug a misrendering of the star example with lots of tips, I checked the input and the output vertices after meshing. I was expecting to find lots of funky problems but instead I found one very noticeable one.

The input values are all over the map:


[[2.0, 0.0], [4.8296291314453415, 1.2940952255126037], [1.7320508075688774, 0.9999999999999999], [3.5355339059327378, 3.5355339059327373], [1.0000000000000002, 1.7320508075688772], [1.2940952255126048, 4.829629131445341], [1.2246467991473532e-16, 2.0], [-1.2940952255126033, 4.8296291314453415], [-0.9999999999999996, 1.7320508075688776], [-3.5355339059327373, 3.5355339059327378], [-1.732050807568877, 1.0000000000000007], [-4.829629131445341, 1.294095225512605], [-2.0, 2.4492935982947064e-16], [-4.829629131445342, -1.2940952255126017], [-1.7320508075688776, -0.9999999999999996], [-3.5355339059327395, -3.5355339059327355], [-1.0000000000000009, -1.7320508075688767], [-1.2940952255126073, -4.829629131445341], [-3.6739403974420594e-16, -2.0], [1.2940952255126015, -4.829629131445342], [0.9999999999999986, -1.732050807568878], [3.5355339059327373, -3.5355339059327386], [1.7320508075688767, -1.0000000000000009], [4.829629131445341, -1.2940952255126077]]

The output vertices look a lot cleaner and more unified with one notable exception:

[Vertex { position: [-2.0, 2.4492937e-16, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [1.2246469e-16, 2.0, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-1.7320508, 1.0, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [1.0, -1.7320508, 0.0], normal: [0.0, -0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [1.7320508, -1.0, 0.0], normal: [0.0, -0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-1.0, -1.7320508, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-3.6739403e-16, -2.0, 0.0], normal: [0.0, -0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-1.0, 1.7320508, 0.0], normal: [-0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [2.0, 0.0, 0.0], normal: [0.0, -0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [1.0, 1.7320508, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [1.7320508, 1.0, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-1.2940953, 4.829629, 0.0], normal: [0.0, -0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [1.2940953, 4.829629, 0.0], normal: [-0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-4.829629, 1.2940953, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-3.535534, 3.535534, 0.0], normal: [0.0, -0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-1.2940953, -4.829629, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [3.535534, 3.535534, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [4.829629, -1.2940953, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [4.829629, 1.2940953, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-4.829629, -1.2940953, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [-1.7320508, -1.0, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [1.2940953, -4.829629, 0.0], normal: [-0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }, Vertex { position: [3.535534, -3.535534, 0.0], normal: [0.0, 0.0, 1.0], color: [1.0, 0.0, 0.0, 1.0] }]

Some x/y values which are supposed to be 0 are a very tiny number unequal to 0 like 2.4492937e-16.

@hannobraun
Copy link
Owner

hannobraun commented Feb 24, 2022

I've been thinking about this. I don't think it's a problem in and of itself.

That second piece of output you show is from graphics data. Any inaccuracies there (like the weird zero values) won't matter, because no one will notice or care that the edges of two triangles are not perfectly aligned at the sub-pixel level. This also wouldn't explain the kind of issues we're seeing in #143.

I don't know how these weird zero values come to be, and they might very well point to a bug somewhere. I'm just saying, they shouldn't be a problem in and of itself.


The screenshots in #143 show whole triangles that shouldn't be there. This is most likely a problem in the triangulation code or the approximation code that feeds it data. More specifically, I suspect that it might be a problem with the point-in-polygon testing that's necessary as part of the triangulation ([1] and [2]), which has known issues (#105).

A word of warning: That triangulation code is pretty gnarly, and overdue for a cleanup. See #105.


Since I don't think what's reported here is a problem in and of itself, maybe not at all, I'm closing this issue and will add a reference to it from #143. I suggest continuing the discussion there.

@hannobraun hannobraun added the status: duplicate This issue or pull request already exists label Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants