dmurdoch/rgl

`addNormals` warnings

stla opened this issue · 1 comments

stla commented

Hello,

I have this mesh (you can read it with Rvcg::vcgPlyRead).

When I do addNormals(mesh), I have some warnings:

1: In acos(dot/veclen(a)/veclen(b)) : NaNs produced
2: In acos(dot/veclen(a)/veclen(b)) : NaNs produced
......

I find it's strange because I don't see what is bad in this mesh.

When I do addNormals(mesh, angleWeighted = FALSE), there's no warning.

There's also an angle weighted method in the Rvcg package (Rvcg::vcgUpdateNormals(mesh, type=1)), it works without errors/warnings.

I think that's caused by rounding error. In the first case, the dot/veclen(a)/veclen(b) value comes out to 1 + 2e-16, and acos gives NaN as the answer. I'll force the values to the range -1 to 1.

Thanks for the report.