Computer Graphics (2nd edition in Wanbo Shuo) 45th page of the Bresenham algorithm has errors:
The book is supposed to be written in X as the step-by-step method, but he wrote a part of the Y is the step-by-step method (in fact, also write the wrong), and finally the X-step of the way to summarize.
The algorithm in the analysis book has to be:
L k Initial value <=0 draw is x=0;
L 0<k Initial value <1 draw a line of 1/k;
L k Initial value >=1 draw is y=x;
The following black lines are drawn using Moveto,lineto, the red ones are drawn on the book's program, the blue lines are my modified lines (with division), and the Purple ones are modified (no division).
The Green Line is the line that is 1/k when validating the 0<k initial value <1 (drawn with Moveto,lineto)
(500,-500), (0,0) k=-1 (0,0), (500,500) k=1 (0,0), (400,100) K=1/4
(0,0), (100,400) k=4
modified to: (Main display 0<=k<=1 )
(0,0), (400,100) K=1/4 (with multiplication)
(0,0), (400,100) K=1/4 (no multiplication)
No multiplication program:
Computer Graphics (2nd edition in Wanbo Shuo) 45th page of the Bresenham algorithm has errors