The sin() and cos() functions seem to be using some kind of lookup table at ¼ the number resolution, with clamping. It is easy to use linear interpolation instead and improve the precision of these functions by calling them twice:
function trig(f,x) local a, b = f(x & 0x.fffc), f(x | 0x.0003) return a + (b - a) * (x << 14 & 0x.c) end function xsin(x) return trig(sin,x) end function xcos(x) return trig(cos,x) end |
@zep I think PICO-8 could very well do this internally, as the extra cost seems negligible. The same goes with atan2(), especially since in that case it is significantly more difficult to do in PICO-8 user land.
P#140387 2024-01-21 10:46 ( Edited 2024-01-21 10:54)
[Please log in to post a comment]