So if you need to optimize for speed, don't do that. Note, I'm not saying don't ever do that as if it's only being run once it probably doesn't matter... but if it's inside a long loop it can start to matter a lot.
angle = Math.Atan2(small/large);
Should not be faster than:
angle = lookup[Math.floor(small * 640 / large)];
But it is. In most any compiled language, C, Pascal, Ada, etc, that lookup to an array should be faster since ATAN2 is a complex float operation, but with JS it’s faster to do math than it is to access arrays.
This stems from the simple fact JS arrays are not ACTUALLY what “real” programmers consider to be arrays. They are pointer based lists masquerading as Arrays. Hence why the bigger the array, the longer it takes to access higher indexed values.