pmneila/PyMCubes

First example

RepRapLtd opened this issue · 2 comments

I think the first example creates a sphere with the surface normals pointing the wrong way. The definition should be:

u = -((X-15)**2 + (Y-15)**2 + (Z-15)2 - 82)

I think the first example creates a sphere with the surface normals pointing the wrong way. The definition should be:

u = -((X-15)**2 + (Y-15)**2 + (Z-15)2 - 82)

I do agree but, Python 3.10.2 gives this error:

    u = -((X-15)**2 + (Y-15)**2 + (Z-15)2 - 82)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

Hi,

It should be

u = -((X-15)**2 + (Y-15)**2 + (Z-15)**2 - 8**2)

Note that PyMCubes does not compute normals, as they can be computed in a post-processing step. The surface computed by PyMCubes is (or should be) agnostic to the sign of the distance function.

Following the standard approach of computing normals assuming counter-clockwise order of vertices, it is true that normals will point inwards or outwards depending on the sign of the distance function. This is, however, beyond the scope of this library (at least until normal computation is implemented inside PyMCubes). On top of that, whether the normals of a surface should point inwards or outwards is application-dependent, not an inherent property of the surface itself.

In any case, given that this is causing some confusion, I will update the example with an explanation about surface orientation in the next version.

Hope that clarifies the issue.

Best