Re:Show HN: Implementing a trackball with rational numbers
by Willox on Monday October 16, 2017 @03:14PM
(#15485845)
Your cube is disappearing for me after about 6 rotations in the same direction with Chrome 61.0.3163.100. Doesn't happen on the non-rational version.
[ Parent
| on HN ]
Re:Show HN: Implementing a trackball with rational numbers
by grondilu on Monday October 16, 2017 @03:26PM
(#15485963)
I had noticed the disappearance of the cube after a while indeed. With Firefox it happens much later than just six rotations though. Can't test it on chrome right now.
Apparently this happens when .valueOf() becomes NaN. I'll modify the code to display that value. Heck, I'll show the floating point approximation for the whole matrix.
.valueOf() becoming NaN is probably related to the behavior of big-rational.js. I suppose it does:
x => x.num.valueOf()/x.denom.valueOf()
instead of doing a custom division of x.num by x.denomPS. yep, it does just that:
https://github.com/peterolson/BigRational.js/blob/master/Big...