Today, I am going to try to optimize Math.atan2(y,x), atan2 is very useful when working with polar coordinates. Here the definition of atan2: Based on the definition, we will have to deal with multiple quadrants, but here some useful maths we can use: atan(-x) = -atan(x) atan(1/x) = PI/2 – atan(x) for x>0 =-PI/2 – […]

~ read more ~## Posts tagged LUT

# Math.exp Math.pow(2,x) 2^x optimizations and tricks , **updated **

In my previous posts, I presented optimizations for e bunch of Maths functions, so lets continue and see whats next in the list ! Today I am going to explore ways to optimize Math.pow(2,x) or 2^x , as well as Math.exp One easy trick to fast perform 2^i for integers is to use bit shifting, […]

~ read more ~# Math.sin tricks

Math.sin is slow, we have many options to optimize it, a good post from Jackson dunstan “Even Faster Trig Through Inlining” show lots of methods (http://jacksondunstan.com/articles/1213) But there is a major problem with all the proposed methods : it only works for a certain range of angle, and if you want to use those functions […]

~ read more ~# Log2(n) tricks

How to fast compute log2(n) ? We are going to explore few methods. 1)The obvious: var log2:int = Math.log(n)*Math.LOG2E This is going to be incredibly slow, due to the function call, so lets try other methods described in http://graphics.stanford.edu/~seander/bithacks.html, and add some salt to them. 2)Log2 with branch One idea is to divide the number […]

~ read more ~
## Recent Comments