Sorry, but I would not suggest to use that solution ingame because this is just brute force.

If you want to have better results I would recommend to use this solution:
PDF here

They use a combination of quadratic minimization and newtons method.
I have implemented this method in 2012 and it works really well.

Last edited by Puppeteer; 07/20/14 16:28.

Formally known as Omega
Avatar randomness by Quadraxas & Blade
http://omegapuppeteer.mybrute.com