3 ms·
Show HN: Implementing a trackball with rational numbers
- Willox 9y agoYour 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.
- grondilu 9y agoI 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.denom PS. yep, it does just that: https://github.com/peterolson/BigRational.js/blob/master/BigRational.js#L188 https://github.com/peterolson/BigRational.js/blob/master/Big...
- stuaxo 9y agoThe Matrix renders but once the page fully loads it is replaced with a horizontal black line. Browser: Firefox OS: Ubuntu
- stuaxo 9y agoDragging it around for a while the framerate has gone down to about 4fps Here is the output: a00 = 1432521999387336201000162233364364261412422778723249988532277223673502336434725335337083644796278416082366180670944929785069345/5986547728315893919428066873527575391908390247143416149511995033033437392431374342833088545303961365118098478697976518989268769 a00.valueOf() = 0.23929016595184258
- grondilu 9y agoI've updated the code to display more useful information on the values. A big framerate drop is to be expected after several rotations, as the numerators and denominators become very big.
- evincarofautumn 9y agoThis is one of the most frustrating problems to me about working with big rationals or intervals. It’s attractively “clean” compared to floating-point numbers, but if you’re not careful, you constantly accumulate more and more “precision” that isn’t really meaningful—you could discard most of the digits of those rationals and end up with the same result when it’s converted to a double.
- deleted 9y ago[deleted]