Sybsc - IT Computer Graphics
Sybsc - IT Computer Graphics
dx = abs(x2 - x1)
dy = abs(y2 - y1)
slope = dy > dx
if slope:
x1, y1 = y1, x1
x2, y2 = y2, x2
if x1 > x2:
x1, x2 = x2, x1
y1, y2 = y2, y1
dx = abs(x2 - x1)
dy = abs(y2 - y1)
error = 0
derror = dy * 2
y = y1
if slope:
draw_point(y, x)
else:
draw_point(x, y)
error += derror
y += 1 if y2 > y1 else -1
error -= dx * 2
print(f"({x}, {y})") # You can replace this with your preferred method of
drawing
# Example usage:
draw_line(1, 1, 8, 5)
1. Initialization: Choose the center of the circle (x_center, y_center) and the radius r.
2. Plotting Points: Begin by plotting the points (x, y) on the circumference of the circle, where x
varies from 0 to r and y is determined based on the circle equation.
3. Decision Parameter: At each step, determine the next point to plot based on a decision
parameter. The decision parameter is calculated based on the circle equation and the distance
of the midpoint from the true circle.
4. Incremental Calculations: Use incremental calculations to update the decision parameter and
efficiently move along the circumference of the circle.
5. Symmetry: Exploit the symmetry of the circle to minimize computations. Plot points in one
octant of the circle and mirror them to other octants to complete the circle.
6. Repeat: Continue plotting points until reaching the maximum symmetry point, ensuring that the
entire circumference of the circle is covered.
By following these steps, Bresenham's circle drawing algorithm efficiently draws circles with
minimal computational overhead. It's particularly useful in scenarios where performance is
crucial, such as real-time graphics rendering or embedded systems.
This explanation is in line with the teachings of computer graphics and animation courses,
providing a practical and efficient method for drawing circles that students can understand and
implement.
https://mu.ac.in/wp-content/uploads/2022/03/USIT-405-Computer-Graphics-and-
Animation.pdf
1. Initialization: Choose the center of the circle (x_center, y_center) and the radius r.
2. Initial Decision Parameter: Calculate the initial decision parameter d based on the selected
point (0, r) and the circle equation.
3. Plotting Points: Begin plotting the points on the circumference of the circle. Start from the
topmost point (0, r) and move along the circumference using symmetry properties.
4. Incremental Calculations: Use incremental calculations to update the decision parameter and
efficiently move along the circumference of the circle. Update the decision parameter based on
the current midpoint and the next potential pixel to be plotted.
5. Symmetry: Exploit the symmetry of the circle to minimize computations. Plot points in one
octant of the circle and mirror them to other octants to complete the circle.
6. Decision Parameter Update: At each step, update the decision parameter to determine
whether to choose the next pixel along the same y-coordinate or to move to the next y-
coordinate.
7. Repeat: Continue plotting points until reaching the maximum symmetry point, ensuring that the
entire circumference of the circle is covered.
By following these steps, the midpoint circle drawing algorithm efficiently draws circles with
minimal computational overhead. It's particularly useful in scenarios where performance is
crucial, such as real-time graphics rendering or embedded systems.
1. Start with a Center: You pick a point in the middle of your paper. This is the center of your
circle.
2. Think about Distance: You think about how far away you want the circle's edge to be from the
center. This distance is called the radius.
3. Plot Points: Now, you start plotting points on your paper. You start from the top of the circle
(let's say at 12 o'clock) and move around the circle.
4. Make Decisions: As you move around, you have to make decisions. These decisions are like
guessing which point comes next based on where you are and how far you are from the center.
5. Keep Going: You keep making decisions and plotting points until you reach the starting point
again. This way, you draw the entire circle!
6. Use Symmetry: You don't have to draw every single point. You can be smart and use the fact
that a circle is symmetrical. So, you draw only a part of it, and then just copy that part to fill the
rest.
So, even if you don't have a fancy compass, you can still draw a perfect circle using the midpoint
circle drawing algorithm!
https://mu.ac.in/wp-content/uploads/2022/03/USIT-405-Computer-Graphics-and-
Animation.pdf
def draw_circle(radius):
x=0
y = radius
d = 3 - 2 * radius
draw_points(x, y)
while y >= x:
# Increment x
x += 1
if d > 0:
y -= 1
d = d + 4 * (x - y) + 10
else:
d=d+4*x+6
draw_points(x, y)
# Example usage:
radius = 4