about Octants :
line coord (x1,y1)(x2,y2)
dx=|x1-x2|
dy=|y1-y2|
binary code
0=000 : y1<y2, x1<x2, dx<dy
1=001 : y1>y2, x1<x2, dx<dy
2=010 : y1<y2, x1>x2, dx<dy
3=011 : y1>y2, x1>x2, dx<dy
4=100 : y1<y2, x1<x2, dx>dy
5=101 : y1<y2, x1>x2, dx>dy
6=110 : y1>y2, x1<x2, dx>dy
7=111 : y1>y2, x1>x2, dx>dy
if dx>dy, the third octant bit is 1
octant is coded : Dxx with D = Delta X and Delta Y
dx>dy
0=000 : y1<y2, x1<x2
1=001 : y1>y2, x1<x2
2=010 : y1<y2, x1>x2
3=011 : y1>y2, x1>x2
dx<dy
4=100 : y1<y2, x1<x2
5=101 : y1<y2, x1>x2
6=110 : y1>y2, x1<x2
7=111 : y1>y2, x1>x2
octant is code 1AB or 0BA
A=1 if y1>y2 and B=1 if x1>x2
A=0 if y1<y2 and B=0 if x1<x2