mcneel / rhinocommon

RhinoCommon is the .NET SDK for Rhino5 / Grasshopper
http://wiki.mcneel.com/developer/rhinocommon
242 stars 92 forks source link

Possible Bug: RhinoMath.ToDegrees #107

Closed wortmann closed 12 years ago

wortmann commented 12 years ago

double angle = RhinoMath.ToDegrees(Math.Acos(Multiply(vec2D.Unify(vec1), vec2D.Unify(vec2))));

I have noticed that in above code sample, ToDegrees sometimes returns NaN ("not a number"). I think this is the case when the angle is super tiny, so it might be better to return 0 instead. I might also be a problem with Math.Acos, but that seems unlikely.

sbaer commented 12 years ago

I'm pretty sure the number you are passing to RhinoMath.ToDegrees is already NaN https://github.com/mcneel/rhinocommon/blob/master/dotnet/opennurbs/opennurbs_defines.cs#L98 ToDegrees just multiplies the input number by the constant of 180.0 / PI

Break your code up into multiple lines and you should be able to track down the root of the problem. I suspect that your vectors may be InValid