JuliaGeometry / Meshing.jl

Meshing and isosurface extraction algorithms
Other
58 stars 13 forks source link

Order of points in triangles #78

Closed uchiiii closed 4 months ago

uchiiii commented 4 years ago

Hello. I am currently using MarchingCubes and MarchingTetrahedra.

I would like to know the order of points in a face. In order word, Is that counter-clock wise or clock wise with respect to normal vector?

Thank you for your time in advance.

sjkelly commented 4 years ago

The points will be ordered according to the right hand rule (so counter clockwise). By default the sign convention is such that the inside of the surface is negative or less than the iso level (normals pointing out of the surface). The normal orientation can be switched by setting `insidepositive=true, but the faces will still use the right hand sign convention.

If you would like left hand coordinates, it should be simple to support in MarchingCubes (the other tables are more complex, and MC is the only one I made an equivalency table for). This table will just need to modified to be left handed, and add a flag somewhere to use it: https://github.com/JuliaGeometry/Meshing.jl/blob/9af204e7815b61a666d4de1d0c5bdc64178445c0/src/lut/mc.jl#L581

uchiiii commented 4 years ago

Thank you very much for your precise explanation. In my case where the inside is positive, what I need to do is just insidepositive=true to get the right-hand rule (so counter-clockwise) with respect to normal orientation whose direction is to the outside. Is it correct?

sjkelly commented 4 years ago

Yes, in that case insidepositive=true will flip the triangle winding to point outside of the surface (works for all algos). It still uses right hand rule but the normal will flip to the opposite side of the face.

Somewhat tangential, but the naming isn't the clearest in retrospect, because you might have a grid 1 to 0 and want the iso at 0.5, but everything is positive! Really all the insidepositive flag does is flip the bits used to index into the triangle tables, which has the effect of flipping the point order. It really has nothing to do with sign conventions :(.

Also something that might be unclear is that Meshing does not generate the normals directly (yet). The ordering of the face points is how a visualization tools figures out the normal direction (which is used for lighting, etc)

I'll keep this open until I clarify the docs and add pictures.

The second part of this is winding order which is fixed to be right handed now, but we could support both conventions.

On Fri, Jul 10, 2020, 01:10 Ryosuke Horiuchi notifications@github.com wrote:

Thank you for your precise explanation. In my case where the inside is positive, what I need to do is just insidepositive=true to get the right-hand rule (so counter-clockwise) with respect to normal orientation. Is it correct?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JuliaGeometry/Meshing.jl/issues/78#issuecomment-656485856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP5MDFO5HTZ63RKHNPZZ7TR22PCRANCNFSM4OUGIVUQ .