# How can i use bresemhan to any cases?

i have this bresenham's code, but actually this work only to some cases, how can i complete to any cases?

    this.dx = dx;
this.dy = dy;

int m = dy / dx;
if (dx >= 0 && dy >= 0) {
if (m < 1) {
stepX = 1;
stepY = 1;
d = 2 * dy - dx;
de = 2 * dy;
dne = 2 * (dy - dx);
} else {
stepX = 1;
stepY = 1;
d = dy + (2 * (-dx));
de = 2 * (-dx);
dne = 2 * (dy - dx);
de = -de;
dne = -dne;
}
}


will be that repeat this code 3 times over? to following cases?

if (dx > 0 && dy < 0)
if (dx <= 0 && dy <= 0)
if (dx < 0 && dy > 0)


actually only works for the first quadrant

       +
+   here worked
+
+++++++++++++++++
+
+

• Can you specify in which cases it works and in which cases it fails? What is the result if it fails? Those details might help to find the problem faster. – wychmaster Sep 2 '20 at 5:37
• @wychmaster i edited my question – hubman Sep 2 '20 at 5:41
• I currently don't have the time to double-check my claims and write a proper answer, but as far as I can remember, the algorithm is only supposed to work for the first octant starting at x=0 and y=+a where a is an arbitrary number. You can get the values for all other octants by abusing the symmetry of the circle. Have a look into this link. – wychmaster Sep 2 '20 at 7:11