Skip to main content

Midpoint circle: r=30, centre (10,20)

Short answer

Using midpoint circle algorithm with p0=-29, start at (0,30) relative to center, stop when x≥y, then shift by (10,20). First-octant pixels: (10,50), (11,50), (12,50), (13,50), (14,50), (15,50), (16,49), (17,49), (18,49), (19,49), (20,48), (21,48), (22,47), (23,47), (24,47), (25,46), (26,45), (27,45), (28,44), (29,43), (30,42), (31,41).

Calculate all pixels of a circle in the first octant, proceeding in positive X axis direction. The radius = 30 and center at (10, 20).

Given: radius r = 30, centre (10,20).

Start at (x0, y0) = (0, 30). Initial parameter p0 = 1 − r = -29.

p < 0 : next point (x+1, y),     p_new = p + 2x_new + 1
p ≥ 0 : next point (x+1, y−1),   p_new = p + 2(x_new − y_new) + 1
Stop when x ≥ y

Decision parameter table (circle centred at the origin; p_k decides the next point):

kp_k(x_k, y_k)next (x, y)
0-29(0,30)(1,30)
1-26(1,30)(2,30)
2-21(2,30)(3,30)
3-14(3,30)(4,30)
4-5(4,30)(5,30)
56(5,30)(6,29)
6-39(6,29)(7,29)
7-24(7,29)(8,29)
8-7(8,29)(9,29)
912(9,29)(10,28)
10-23(10,28)(11,28)
110(11,28)(12,27)
12-29(12,27)(13,27)
13-2(13,27)(14,27)
1427(14,27)(15,26)
156(15,26)(16,25)
16-11(16,25)(17,25)
1724(17,25)(18,24)
1813(18,24)(19,23)
196(19,23)(20,22)
203(20,22)(21,21)
214(21,21)(22,20)

Octant points about the origin: (0,30), (1,30), (2,30), (3,30), (4,30), (5,30), (6,29), (7,29), (8,29), (9,29), (10,28), (11,28), (12,27), (13,27), (14,27), (15,26), (16,25), (17,25), (18,24), (19,23), (20,22), (21,21).

Shift by (10,20) (add xc to x and yc to y):

k(x,y) in octantplotted (x+xc, y+yc)
0(0,30)(10,50)
1(1,30)(11,50)
2(2,30)(12,50)
3(3,30)(13,50)
4(4,30)(14,50)
5(5,30)(15,50)
6(6,29)(16,49)
7(7,29)(17,49)
8(8,29)(18,49)
9(9,29)(19,49)
10(10,28)(20,48)
11(11,28)(21,48)
12(12,27)(22,47)
13(13,27)(23,47)
14(14,27)(24,47)
15(15,26)(25,46)
16(16,25)(26,45)
17(17,25)(27,45)
18(18,24)(28,44)
19(19,23)(29,43)
20(20,22)(30,42)
21(21,21)(31,41)

Answer: first-octant pixels: (10,50), (11,50), (12,50), (13,50), (14,50), (15,50), (16,49), (17,49), (18,49), (19,49), (20,48), (21,48), (22,47), (23,47), (24,47), (25,46), (26,45), (27,45), (28,44), (29,43), (30,42), (31,41).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Graphics chapter 2 questions →