Hi all,
The suddenly disappeared rope when creating it was found due to a very interesting floating point number calculation issue in computers: the 'NaN', not a number value.
C# defines a valid value called float.NaN for float data type. Under some circumstances, a math calcualtion would get a NaN result,
e.g.,
The additions ∞ + (−∞), (−∞) + ∞ and equivalent subtractions
The square root of a negative number.
In our project, the calcualtion for the rotation angle, rotationAngle = -(float)Math.Acos(Vector3.Dot(rotationAxis, previousAxis)), sometimes returns a NaN as well, this is the root of the problem.
This bug has been fixed by doing---
if (rotationAngle != rotationAngle)
rotationMatrix = Matrix.Identity;
else
rotationMatrix = Matrix.CreateFromAxisAngle(rotationAxis, rotationAngle);
A new StringGeometry.cs file with the fix will be sent out soon.
Kindest regards,
Jun
The suddenly disappeared rope when creating it was found due to a very interesting floating point number calculation issue in computers: the 'NaN', not a number value.
C# defines a valid value called float.NaN for float data type. Under some circumstances, a math calcualtion would get a NaN result,
e.g.,
The additions ∞ + (−∞), (−∞) + ∞ and equivalent subtractions
The square root of a negative number.
In our project, the calcualtion for the rotation angle, rotationAngle = -(float)Math.Acos(Vector3.Dot(rotationAxis, previousAxis)), sometimes returns a NaN as well, this is the root of the problem.
This bug has been fixed by doing---
if (rotationAngle != rotationAngle)
rotationMatrix = Matrix.Identity;
else
rotationMatrix = Matrix.CreateFromAxisAngle(rotationAxis, rotationAngle);
A new StringGeometry.cs file with the fix will be sent out soon.
Kindest regards,
Jun
No comments:
Post a Comment