Knowee
Questions
Features
Study Tools

Given a line AB from (3,3) to (14,20). Plot all possible points using Bresenham linedrawing algorithm

Question

Given a line AB from (3,3) to (14,20).

Plot all possible points using Bresenham linedrawing algorithm.

🧐 Not the exact question you are looking for?Go ask a question

Solution

The Bresenham line algorithm is an algorithm that determines the points of an n-dimensional raster that should be selected in order to form a close approximation to a straight line between two points. Here's how you can use it to plot all possible points from (3,3) to (14,20):

  1. Start from the point (3,3). This is your initial point.

  2. Calculate the difference in x and y coordinates. dx = 14 - 3 = 11 dy = 20 - 3 = 17

  3. Initialize two variables, p as 2dy - dx = 217 - 11 = 23 and two times of dy and dx as 2dy = 217 = 34 and 2dx = 211 = 22.

  4. Now, start a loop from i = 0 to dx.

  5. For each step in the loop, check if p < 0. If it is, the next point is (x+1, y) and p = p + 2dy. If p >= 0, the next point is (x+1, y+1) and p = p + 2dy - 2dx.

  6. Repeat the loop until you reach the point (14,20).

Following these steps, the points you get are: (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (10,10), (11,11), (12,12), (13,13), (14,14), (15,15), (16,16), (17,17), (18,18), (19,19), (20,20).

Please note that the Bresenham algorithm is used for integer grid locations and it may not give the exact line on a continuous plane.

This problem has been solved

Similar Questions

Bresanham circle algorithm uses the approach ofMidpointPointLineNone of theseView answer

Derive the formula for initial decision parameter of Bresenham’s Line Drawingalgorithm.

Find the midpoint of a segment AB is (5, 3).  What is the missing coordinates.  A = (2, 5) and B = (8, y)Group of answer choicesy = 3y = -2y = 1y = 5

If the point P (2, 1) lies on the line segment joining points A (4, 2) and B (8, 4),then(A) AP = 13 AB (B) AP = PB (C) PB = 13 AB (D) AP = 12 AB

A line passes through the points (–2,–1) and (19,14). Write its equation in slope-intercept form.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.