Determining whether grid coordinates lie within a circle

AI Thread Summary
To determine if a grid cell lies within a circle, the distance from the cell's coordinates to the circle's center must be compared to the circle's radius. The discussion highlights the challenge of calculating this distance without using a square root, as it can be computationally expensive. It suggests leveraging the monotonic nature of the square root function to simplify the calculation. The conversation also touches on the ambiguity of defining "within" a circle, especially regarding grid cells that may partially intersect the circle's boundary. Overall, the focus is on finding an efficient method to assess the relationship between grid coordinates and a defined circular area.
STENDEC
Messages
21
Reaction score
0
I have a grid and want to determine whether a point lies within (our outside of) a circle.

asXctUw.png


The grid cells simply have integer coordinates, e.g. x = 5, y = 7. The circle's radius is known, and also an integer value.

I wrote a program that can place points in a (quantized) circle using sin/cos, but I can't seem to wrap my head around how to check whether a grid cell lies within a circle of a given radius. Maybe someone can guide me into the right direction. Thanks.
 
Mathematics news on Phys.org
What is your definition of "within"? Surely that blue square in your picture has a part outside the circle.
 
If you think of the border being derived from the sin/cos values describing the circle, rounded to the nearest integer; A blocky ring if you will.

It doesn't have to be accurate to the single cell if there's some ambiguity about that. X and Y coordinates and 2 states per cell (on/off) is all that's being processed.
 
Do you know the x and y coordinates of the center of the circle, the x and y coordinates of your point and the radius of the circle? If so, compute the distance from the point to the center of the circle and compare that to the radius.

Naively, that computation requires evaluating a square root. Can you think of a way to avoid that?

Hint: The square root function is strictly monotone increasing.
 
That's the help I needed. I'll think about your hint on whether/how sqrt can be avoided in this scenario. I'm not solid in math as is evident I think :shy:
 
Thread 'Video on imaginary numbers and some queries'
Hi, I was watching the following video. I found some points confusing. Could you please help me to understand the gaps? Thanks, in advance! Question 1: Around 4:22, the video says the following. So for those mathematicians, negative numbers didn't exist. You could subtract, that is find the difference between two positive quantities, but you couldn't have a negative answer or negative coefficients. Mathematicians were so averse to negative numbers that there was no single quadratic...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Thread 'Unit Circle Double Angle Derivations'
Here I made a terrible mistake of assuming this to be an equilateral triangle and set 2sinx=1 => x=pi/6. Although this did derive the double angle formulas it also led into a terrible mess trying to find all the combinations of sides. I must have been tired and just assumed 6x=180 and 2sinx=1. By that time, I was so mindset that I nearly scolded a person for even saying 90-x. I wonder if this is a case of biased observation that seeks to dis credit me like Jesus of Nazareth since in reality...
Back
Top