I am looking for an equation for a basic version of the bresenham line algorithm that would allow me to calculate the position of the Y value if the X value is known.
The X is always positive and always larger then the Y. The loop just adds 1 to the X until the end is reached.
Here is my code:
int err = (Y << 1) - X;
for(i=0; i<=X; i++)
{
if(err > 0)
{
step++;
err = (err - (X << 1)) + (Y << 1);
}
else
{
err = err + (Y << 1);
}
printf("X=%d Y=%d\n", i, step);
}
What I am looking for is a way to figure out what the value of step(Y axis) is at a specific X value with out running the algorithm and with only integer math.
The reason for this is that I have a system that I can pause, but only returns the current X value (Not the Y) and I need to figure out the Y value when this happens.
Dave