How to “relax” the circle equation to get a more attractive circle?

I need to write a program using java for assignment. The program needs to display a circle of a given radius in a given coordinate. So far I have created a for loop nested inside another for loop to scan all coordinates and print "#" whenever the coordinate satisfies the circle equation, which is: (xa) ^ 2 + (y- b) ^ 2 = r ^ 2

However, in my circle some coordinates are missing.

I believe this is because I did not take into account one of the hints included in the question.

Hint: The discrete world we must work with makes it difficult to express strict equality in equation 1 (equation 1 is the equation of a circle). Can you relax this equality to attract steeper circles?

I would really appreciate it if someone would give me any ideas on how to “relax” the circle equation to get a more complete circle.

enter image description here

Thanks!

+4
source share
2 answers

The problem is that integer arithmetic rounding affects your results.

The integer rounding is not really rounding, it truncates (all decimal parts are lost, i.e. (int) .9 = 0), so you can try adding .5 to each result first (or -5 if the number is negative), before allowing truncation.

, , , r +/-.5, "" .

, "" (, 4 ) ( 3 r +/- 1), , .

+1

, , int, 0.5, , , .

enter image description here

, "" :

enter image description here

0

All Articles