Prometheus Posted February 26, 2019 Posted February 26, 2019 I have a grid through upon which a circle is drawn, as shown below. Now, for every square in the grid through which the circle runs, i want to calculate the proportion of the square covered by the circle. So one of the squares close up: I thought this would be relatively straightforward but i've ended up with a horribly convoluted way involving working at some angles where the circle crosses the squares, using that to find the area of the circle, then subtracting that from the area of a rectangle that contains that circle segment, and so on for other squares. Only need to do this for three squares as symmetry saves me a lot of work, but it's still a meandering method. Just seems to me there should be a much more simple method, but i can't figure it out. Does anybody know of a more elegant way of solving this problem?
StringJunky Posted February 26, 2019 Posted February 26, 2019 (edited) 29 minutes ago, Prometheus said: I have a grid through upon which a circle is drawn, as shown below. Now, for every square in the grid through which the circle runs, i want to calculate the proportion of the square covered by the circle. So one of the squares close up: I thought this would be relatively straightforward but i've ended up with a horribly convoluted way involving working at some angles where the circle crosses the squares, using that to find the area of the circle, then subtracting that from the area of a rectangle that contains that circle segment, and so on for other squares. Only need to do this for three squares as symmetry saves me a lot of work, but it's still a meandering method. Just seems to me there should be a much more simple method, but i can't figure it out. Does anybody know of a more elegant way of solving this problem? Wouldn't you be looking for the Area under a Curve? Look at each square as a quadrant in graph. Edited February 26, 2019 by StringJunky 1
Prometheus Posted February 26, 2019 Author Posted February 26, 2019 (edited) 4 minutes ago, StringJunky said: Wouldn't you be looking for the Area under a Curve? You may very well be right, thanks. I'll get back to you once i get a chance to give it a go. Yes, even at a cursory glance it seems obvious this will work. Edited February 26, 2019 by Prometheus
Sensei Posted February 26, 2019 Posted February 26, 2019 (edited) If it is the real work, not mathematical play, I would simply boolean one object from other object to get intersecting polygons, and use area calculation tool in 3D application on remaining polygons (eventually triangulate it). You might need to temporarily extend 2D shape to 3D because some boolean tools don't like to work in 2D (depending on application that you're using). Edited February 26, 2019 by Sensei
studiot Posted February 26, 2019 Posted February 26, 2019 Here are some thoughts. Use symmetry. That substantially reduces the workload. Then you can calculate the coordinates of the intercepts with the sides of the squares by calculating the offsets from the tangent. The four sides of the outer box are tangent to the circle as shown. The simple formula for perpendicular offsets from the tangent to a circular curve is Offset = (Length along the tangent)2 / twice radius 1
studiot Posted February 27, 2019 Posted February 27, 2019 I should perhaps add how to get the areas? Well in each square you have to add the area of a rectangle R, a triangle T and a circular segement S. You already have the circle radius and can easily find the chord length as the hypotenuse of a right angled triangle. So these are easily calculable from the intercepts, or you can use an online calculator for the segments. You haven't stated your mesh size, but with the size shown in the drawing you only need three sizes and to find these you only need two intercepts. Symmetry does the rest.
Prometheus Posted February 27, 2019 Author Posted February 27, 2019 (edited) Following String's hint and using studiot's notation for the squares, of which we need only 3, i've come up with: \( A = int_{0}^{1}(r^2 - x^2) dx - 2 \) \( B = int_{1}^{2}(r^2 - x^2) dx - 2 \) \( C = int_{2}^{3}(r^2 - x^2) dx - (A+B) \) Which give reasonable looking answers too. I'll give Studiot's method a go later, it looks like a more refined approach to the one i first described. Edited February 27, 2019 by Prometheus i seem to be getting worse at using latex
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now