Skip to content

Instantly share code, notes, and snippets.

@Madsy
Created August 21, 2013 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Madsy/6294418 to your computer and use it in GitHub Desktop.
Save Madsy/6294418 to your computer and use it in GitHub Desktop.
//setup
x = startX;
y = startY;
float sX = s1*x; //s1 is 'a' for s
float sY = s2*y; //s2 is 'b' for s
float wX = w1*X; //w1 is 'a' for w
float wY = w2*Y; //w2 is 'b' for w
//optimized loop:
for(; y < yEnd; ++y){
for(; x < xEnd; ++x){
float sOverW = sX + sY + s3; //s3 is 'c' for s
float finalW = 1.0f / (wX + wY + w3); //w3 is 'c' for w
float finalS = sOverW * finalW;
sX += s1;
wX += w1;
}
sY += s2;
wY += w2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment