What is the initial coordinate for bresenhams line algo with equation of line given?
Answers
Answered by
2
Therefore,
d1-d2 = 2x - xi - xi+1
Since,
xi+1 = xi + 1
∴ d1-d2 = 2x - xi - xi - 1
= 2x - 2xi - 1
For each x,
yi+1 = mx + c
x = (yi+1-c)/m
∴ d1-d2 = 2((yi+1-c)/m) - 2xi - 1
= 2((yi + 1 -c )/m ) - 2xi - 1
= 2yi/m + 2/m -c/m - 2xi - 1
= 2yi/m - 2xi + k
where k = 2/m - c/m - 1
Replace m = dy/dx & multiply by dy
We get,
dy(d1-d2) = 2yidx - 2xidy + kdy
For slope > 1, dy is always positive and hence the sign of dy(d1-d2) is same as d1-d2 which determines the pixel position for i+1th pixel
∴ Decision variable is taken as Pi = dy(d1-d2)
Pi = 2yidx - 2xidy + kdy
Similarly, decision variable for i+1th pixel is :
Pi+1 = 2yi+1dx - 2xi+1dy + kdy
Subtracting Pi+1 and Pi, we get :
Pi+1 - Pi = 2dx(yi+1 - yi) - 2dy(xi+1 -xi )
Pi+1 = Pi + 2dx - 2dy(xi+1 - xi)
Decision variable for the initial pixel, say (x0, y0)
P = 2y0dx - 2x0dy + kdy
= 2y0dx - 2dy( y0 - c )/m + (2/m - 2c/m - 1)dy
= 2dx - dy
Now, if P < 0 ( i.e. d1-d2 < 0 ), then
xi+1 = xi
∴ Pi+1 = Pi + 2dx
if P > 0 ( i.e. d1-d2 > 0 ), then
Pi+1 = Pi + 2dx - 2dy
Hlp then mrk
d1-d2 = 2x - xi - xi+1
Since,
xi+1 = xi + 1
∴ d1-d2 = 2x - xi - xi - 1
= 2x - 2xi - 1
For each x,
yi+1 = mx + c
x = (yi+1-c)/m
∴ d1-d2 = 2((yi+1-c)/m) - 2xi - 1
= 2((yi + 1 -c )/m ) - 2xi - 1
= 2yi/m + 2/m -c/m - 2xi - 1
= 2yi/m - 2xi + k
where k = 2/m - c/m - 1
Replace m = dy/dx & multiply by dy
We get,
dy(d1-d2) = 2yidx - 2xidy + kdy
For slope > 1, dy is always positive and hence the sign of dy(d1-d2) is same as d1-d2 which determines the pixel position for i+1th pixel
∴ Decision variable is taken as Pi = dy(d1-d2)
Pi = 2yidx - 2xidy + kdy
Similarly, decision variable for i+1th pixel is :
Pi+1 = 2yi+1dx - 2xi+1dy + kdy
Subtracting Pi+1 and Pi, we get :
Pi+1 - Pi = 2dx(yi+1 - yi) - 2dy(xi+1 -xi )
Pi+1 = Pi + 2dx - 2dy(xi+1 - xi)
Decision variable for the initial pixel, say (x0, y0)
P = 2y0dx - 2x0dy + kdy
= 2y0dx - 2dy( y0 - c )/m + (2/m - 2c/m - 1)dy
= 2dx - dy
Now, if P < 0 ( i.e. d1-d2 < 0 ), then
xi+1 = xi
∴ Pi+1 = Pi + 2dx
if P > 0 ( i.e. d1-d2 > 0 ), then
Pi+1 = Pi + 2dx - 2dy
Hlp then mrk
Attachments:
Similar questions
Computer Science,
7 months ago