No. Just wanting to see the performance between the 2 and I ended up getting free tips on performance.
Here is my revised algorithm.
* 1/1e3 due to numerical issues. (Overflow)
Math proof:
y = dy/dx * x + c; c = 0
*dx => dx.y = dy.x
solve for dy and dx:
dy = dx.dy / x
dx = dy.dx/y
m = dy/dx
Sub:
m = y^2.dx / x^2.dy
Numerically to avoid floating point computations, break apart the fraction.
Code:
[B]int yi = y1;
int dx = x2 - x1;
int dy = y2 - y1;
int ySqr = dy * dy;
int xSqr = dx * dx;
int topFract = (ySqr*dx) / 1000;
int fraction = (xSqr*dy) / 1000;
yi /= 1000;
for (int x = x1; x < x2; x++) {
image.getRaster().setPixel(x, yi/fraction, data);
yi += topFract;
}[/B]
It's slower than the last 2 algorithms. :/
I thought itneger division was faster than that.