You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Math.sqrt chokes on values above 46340, so the transporter fails to 'get a lock' when pointed at a second transporter far away. The solution is to use Math.hypot instead of Math.sqrt. I've fixed that and comitted it to my fork (release branch), but I don't know how to make a pull request with just that commit.
The text was updated successfully, but these errors were encountered:
Math.hypot() is way to slow (about 100x - 200x slower than the actual implementation).
The problem is actually not the Math.sqrt() method itself, it is rather the fact that an 32 bit integer can only hold numbers up to 2'147'483'647 (2^31-1), so given delta values bigger than 46340, the square surpasses the capacity of the data type and finally the method returns a wrong result.
The fix is as simple as to change the int datatype for the distance deltas to long as in the worst case the distance will not surpass 2^31 * 2^31 = 2^62, which still fits in a 64 bit integer (2^63).
Math.sqrt chokes on values above 46340, so the transporter fails to 'get a lock' when pointed at a second transporter far away. The solution is to use Math.hypot instead of Math.sqrt. I've fixed that and comitted it to my fork (release branch), but I don't know how to make a pull request with just that commit.
The text was updated successfully, but these errors were encountered: