Log in

View Full Version : [SOLVED:] Calculate the remaining area of a quadrant with two non overlapping half circles



Aussiebear
07-02-2025, 01:57 PM
Just trying to fill in some time .....:jail:.

I have a quadrant with a radius of 6m, which contains two non overlapping half circles. One half circle with a radius of 3m adjoins the horizontal leg of the Quadrant, and the other half circle adjoins the vertical leg of the Quadrant, but starts at the top of the leg and we currently do not know its radius. I am trying to find the balance of the area remaining within the quadrant after calculating the Area of the two half circles.

Briefly speaking:
Step 1. Calculate the Area of the Quadrant

= (Pi()*6^2)/4)
Step 2. Calculate the area of the HC1 circle (the half circle adjoining the horizontal leg)

=(Pi()*3^2)/2)
Step 3. Calculate the area of the HC2 circle (the half circle adjoining the vertical leg)
' This is where it gets a little messy. I created a triangle from the center point of the Quadrant to the mid point of HC1 to the mid point of HC2 and returning to the center point of the Quadrant. From this I calculated the length of the upright leg of the triangle and thus the radius of the HC2 circle.

Step 4. Area remaining = Area of Quadrant -(Sum(HC1 Area & Hc2 Area).

Providing i got that right (and its up for debate), I decided to push on and attempt to construct a Function.


Function CalculateQuadrantRemainingArea(QuadrantRadius As Double, HalfCircle1Radius As Double) As Double
' Calculates the remaining area of a quadrant with two non-overlapping half-circles.
' Half-circle 1 (HC1) is on the horizontal leg from the origin.
' Half-circle 2 (HC2) is on the vertical leg from the top of the quadrant.
Const PI As Double = 3.14159265358979
Dim AreaQuadrant As Double
Dim AreaHC1 As Double
Dim RadiusHC2 As Double
Dim AreaHC2 As Double
Dim RemainingArea As Double
' Input validation (optional but recommended)
If QuadrantRadius <= 0 Or HalfCircle1Radius <= 0 Then
CalculateQuadrantRemainingArea = CVErr(xlErrValue)
' Return #VALUE! error for invalid input
Exit Function
End If
If HalfCircle1Radius > QuadrantRadius / 2 Then
' This scenario implies HC1 diameter is larger than the quadrant radius or it cannot fit fully on the leg from the origin.
CalculateQuadrantRemainingArea = CVErr(xlErrValue)
' Indicate an impossible scenario
Exit Function
End If
' Step 1: Calculate the area of the quadrant
AreaQuadrant = (1 / 4) * PI * (QuadrantRadius ^ 2)
' Step 2: Calculate the area of the first half-circle (HC1)
' Assuming its diameter spans 2 * HalfCircle1Radius along the leg.
AreaHC1 = (1 / 2) * PI * (HalfCircle1Radius ^ 2)
' Step 3: Determine the radius of the second half-circle (HC2)
' Using the non-overlapping (tangency) condition
' (r2^2 - 12r2 + 45 = 9 + 6r2 + r2^2) simplifies to 36 = 18r2 --> r2 = 2
' In the general case, where C1=(r1,0) and C2=(0,R-r2), we solve:
' Sqrt(r1^2 + (R-r2)^2) = r1 + r2
' r1^2 + (R-r2)^2 = (r1+r2)^2
' r1^2 + R^2 - 2*R*r2 + r2^2 = r1^2 + 2*r1*r2 + r2^2
' R^2 - 2*R*r2 = 2*r1*r2
' R^2 = 2*R*r2 + 2*r1*r2
' R^2 = r2 * (2R + 2r1)
' r2 = R^2 / (2 * (R + r1))
RadiusHC2 = (QuadrantRadius ^ 2) / (2 * (QuadrantRadius + HalfCircle1Radius))
' Step 4: Calculate the area of the second half-circle (HC2)
AreaHC2 = (1 / 2) * PI * (RadiusHC2 ^ 2)
' Step 5: Calculate the Remaining Area
RemainingArea = AreaQuadrant - AreaHC1 - AreaHC2
CalculateQuadrantRemainingArea = RemainingArea
End Function

p45cal
07-03-2025, 03:18 AM
From your function:
CalculateQuadrantRemainingArea(QuadrantRadius As Double, HalfCircle1Radius As Double) As Double
requiring 2 arguments I'm guessing that HalfCircle1Radius is not always equal to half the QuadrantRadius otherwise the calculation would be a simple
(QuadrantRadius^2) /4.583662361
so when the HalfCircle1Radius is not half the QuadrantRadius:
1. Can it be bigger than half the QuadrantRadius?
2. Where along the horizontal leg of the quadrant does it sit?

(I'm not promising I've got lots of time to put aside for this!)

Aussiebear
07-03-2025, 03:49 AM
Hey welcome back to VBAX P45cal. The major half circle sits mid way on the horizontal axis of the quadrant (since the radius of the quadrant is 6m and the radius of the major half circle HC1 is 3 m there is no other position for it to occupy. The minor half circle (HC2) sits on the Vertical axis but it starts at the top of the leg. So, no the major half circle cannot be bigger than than half the radius of the quadrant.

p45cal
07-03-2025, 04:28 AM
The major half circle sits mid way on the horizontal axis of the quadran ( since the radius of the quadrant is 6m and the radius of the major half circle HC1 is 3 m there is no other position for it to occupy. The minor half circle (HC2) sits on the Vertical axis but it starts at the top of the leg. So, no the major half circle be bigger than than half the radius of the quadrant.

Then there is no need to ask for the HalfCircle1Radius in the function arguments since it's always half the Quadrant radius, in which case the function becomes:


Function CalculateQuadrantRemainingArea(QuadrantRadius As Double) As Double
CalculateQuadrantRemainingArea = QuadrantRadius ^ 2 / 4.583662361
End Function

Aussiebear
07-03-2025, 01:28 PM
Respectfully I have to disagree. The first of the half circles is half the radius of the Quadrant and the second is much less.

p45cal
07-03-2025, 02:03 PM
Respectfully I have to disagree. The first of the half circles is half the radius of the Quadrant and the second is much less.

As far as I can tell, the larger half circle size is determined by the quadrant radius - nothing else.
The smaller half circle , if it's to fit by just touching the larger half circle and its top being at the top of the vertical leg of the quadrant, has a diameter about (exactly?) 2/3rds the diameter of the larger half circle. So the linear proportions remain the same regardless of scale, so all areas are in proportion to the square of the linear dimensions.
The function I gave gives the same results as your calculations; have you compared?

Aussiebear
07-03-2025, 08:03 PM
As far as I can tell, the larger half circle size is determined by the quadrant radius - nothing else.
The smaller half circle , if it's to fit by just touching the larger half circle and its top being at the top of the vertical leg of the quadrant, has a diameter about (exactly?) 2/3rds the diameter of the larger half circle. So the linear proportions remain the same regardless of scale, so all areas are in proportion to the square of the linear dimensions.
The function I gave gives the same results as your calculations; have you compared?

For the purpose of this exercise then yes it just happens that the bigger half circle is half the size of the radius of the quadrant. Done the track it may not. In fact I envisage that either the Quadrant or the half circles may differ in dimensions from those supplied in the graphic.

p45cal
07-04-2025, 12:37 AM
For the purpose of this exercise then yes it just happens that the bigger half circle is half the size of the radius of the quadrant. Done the track it may not. In fact I envisage that either the Quadrant or the half circles may differ in dimensions from those supplied in the graphic.

So, back to msg#2:
"when the HalfCircle1Radius is not half the QuadrantRadius:
1. Can it be bigger than half the QuadrantRadius?"
It seems no.
"2. Where along the horizontal leg of the quadrant does it sit?"

Also,
Done the track it may not.I can't work out what this means.

georgiboy
07-04-2025, 02:51 AM
"Down the track it may not"

p45cal
07-04-2025, 03:25 AM
"Down the track it may not"

Ta!

Aussiebear
07-04-2025, 03:33 AM
Sorry, very tired and in a hurry.

No the size of the largest half circle is constrained by the radius of the Quadrant. Both half circles lie within the Quadrant, and never overlap each other.

Down the track it may not be..... in other words the size of the Quadrant and either or both of the half circles may be different.

p45cal
07-04-2025, 03:51 AM
When HC1 diameter is smaller then the quadrant radius where does HC1 sit on the horizontal leg of the quadrant?:
32098

Aussiebear
07-04-2025, 05:17 AM
The midpoint of half circle HC1 will sit somewhere on the horizontal leg providing the arc is always contained within the Area of the Quadrant.
1. For the purpose of this exercise, the radius of the HC1 just happens to be 3m which puts it at the midpoint of the Quadrant horizontal radius.
2. The radius of HC1 can never be bigger than half the radius of the Quadrant (6m)

The midpoint of half circle HC2 will sit somewhere on the vertical leg providing the arc is always contained within the Area of the Quadrant.
1. For the purpose of this exercise, the radius of the half circle HC2 is unknown.
2. Given that the radius of HC1 is 3m, the radius of HC2 will need to be smaller than the radius of HC1 otherwise the half circles will overlap.
3. The half circle HC2's arc start point has been given as the very top of the vertical leg of the quadrant.
4. For the purpose of this exercise, half circles HC1 & HC2 will be tangent (externally) to each other.

Neither of the half circles shall overlap one another.

Neither of the half circles shall extend past the outline of the Quadrant.

Since we know that the radius of the Quadrant is 6m, its area can be calculated by using the formula =(3.14159265358979*6^2)/4 which results in 28.27433388 sq mtrs.

Since we also know that the radius of HC1 is 3m, its area can be calculated by the formula =(3.14159265358979*3)/2 which results in 14.13716694 sq mtrs.

We need to calculate the radius of the half circle HC2 in order to determine the area of HC2. By drawing a line from the midpoint of HC1 on the horizontal leg of the Quadrant to the midpoint of the half circle HC2 on the vertical leg of the Quadrant, we are effectively defining the length of the hypotenuse of a triangle formed by the points Mid point HC1, midpoint HC2 and the joining point of the horizontal and vertical legs of the Quadrant.

From this we can deduce that the following is true:
1. The length of the horizontal leg is 3m.
2. The length of the vertical leg is the radius of HC2 (r2) - 6m.
3. The length of the hypotenuse is the radius of both HC1(R1) & HC2 (R2).
Therefore: (3+(R2-6)) squared = (3 + R2)squared
Which can be written as (3^2)+ (R2^2 + 6R2 + 6R2 + 36) = (3^2 + R2^2) or 9 + R2^2 +12R^2 - 36 = 9 + R2^2
Which results in R2 = 2.
Therefore the following may be deduced;
1. The length of the base is 3m,
2. The length of the vertical leg is 4m.
3. The length of the hypotenuse is 5m.
4. Area of HC2 is 6.283185306 sq mtrs.

Thus the area remaining in the quadrant is 28.27433388 - 14.13716694 - 6.283185306. = 7.853981634 sq mtrs.

Since we are having difficulty in creating a Function, can somebody confirm that my maths is correct and is there a way to write to correct formulas into excel. Once I'm able to move past this point then I shall concentrate on a Function to do the same thing.

Hopefully this clears up any confusion caused by the previous posts.

p45cal
07-04-2025, 06:25 AM
The midpoint of half circle HC1 will sit somewhere on the horizontal leg providing the arc is always contained within the Area of the Quadrant.
1. For the purpose of this exercise, the radius of the HC1 just happens to be 3m which puts it at the midpoint of the Quadrant horizontal radius.
<snip>
Thus the area remaining in the quadrant is 28.27433388 - 14.13716694 - 6.283185306. = 7.853981634 sq mtrs.

Since we are having difficulty in creating a Function, can somebody confirm that my maths is correct and is there a way to write to correct formulas into excel. Once I'm able to move past this point then I shall concentrate on a Function to do the same thing.

I can only say yes, your maths is correct because it agrees with my results.
Because of the size constraint of HC1 then my function in msg#4 holds, because all that maths reduces to that simple equation, no matter what the size of the quadrant.
Test it with values other than 6
32099

georgiboy
07-04-2025, 07:58 AM
I have been playing with this on and off through the day. I am no mathematician but put together my own logic (Formula) to calculate this (I did have a bit of help from a friend I work with (he loves maths) as I was :banghead:), I have then tried to convert that to a VBA function. I will leave the testing to you Aussie.

Formula:
=LET(rQ,A1,r,A2,p,PI(),p*rQ^2/4-p*r^2/2-p*((rQ^2-r^2+9)/(2*(rQ+r)))^2/2)

Function:

Function EvalQuadArea(Rq As Double, r As Double) As Double
Dim p As Double, R2 As Double

p = Application.PI
R2 = (Rq ^ 2 - r ^ 2 + 9) / (2 * (Rq + r))
EvalQuadArea = p * Rq ^ 2 / 4 - p * r ^ 2 / 2 - p * R2 ^ 2 / 2
End Function


I may have completely missed the point here but this really tested my brain and it is what it is, and I have now admitted defeat.

Paul_Hossler
07-04-2025, 08:55 AM
FWIW I get 7.something also

Couple issues with the original macro

1. Input is QuadrantRadius, bur RadiusQuadrant is used ( = 0)
2. RadiusQuadand is Set, but it's not an Object
3. HalfCircleRadius does not need to be passed



Function CalculateQuadrantRemainingArea(QuadrantRadius As Double, HalfCircle1Radius As Double) As Double
' Calculates the remaining area of a quadrant with two non-overlapping half-circles.
' Half-circle 1 (HC1) is on the horizontal leg from the origin.
' Half-circle 2 (HC2) is on the vertical leg from the top of the quadrant.
Const PI As Double = 3.14159265358979 ' Using a more precise PI value
Dim AreaQuadrant As Double
Dim AreaHC1 As Double
Dim AreaHC2 As Double
Dim RadiusQuadrant As Double
Dim RadiusHC1 As Double
Dim RadiusHC2 As Double
Dim RemainingArea As Double
Set RadiusQuadrant = 6
Set RadiusHC1 = 3


' Input validation (optional but recommended)
If QuadrantRadius <= 0 Or HalfCircle1Radius <= 0 Then
CalculateQuadrantRemainingArea = CVErr(xlErrValue) ' Return #VALUE! error for invalid input
Exit Function
End If
If HalfCircle1Radius > QuadrantRadius / 2 Then
' This scenario implies HC1 diameter is larger than the quadrant radius
' or it cannot fit fully on the leg from the origin.
CalculateQuadrantRemainingArea = CVErr(xlErrValue) ' Indicate an impossible scenario
Exit Function
End If

' Step 1: Calculate the area of the quadrant
AreaQuadrant = (1 / 4) * PI * (RadiusQuadrant ^ 2)





My version



Option Explicit


' Calculates the remaining area of a quadrant with two non-overlapping half-circles.
' Half-circle 1 (HC1) is on the horizontal leg from the origin.
' Half-circle 2 (HC2) is on the vertical leg from the top of the quadrant.
Function CalculateQuadrantRemainingArea(QuadrantRadius As Double) As Variant
Const PI As Double = 3.14159265358979 ' Using a more precise PI value
Dim AreaQuadrant As Double
Dim AreaHC1 As Double
Dim AreaHC2 As Double

Dim RadiusHC1 As Double
Dim RadiusHC2 As Double
Dim RemainingArea As Double

' Step 1: Calculate the area of the quadrant
AreaQuadrant = PI * (QuadrantRadius ^ 2) / 4

' Step 2: Calculate the area of the first half-circle (HC1)
' Assuming its diameter spans 2 * HalfCircle1Radius along the leg.
RadiusHC1 = QuadrantRadius / 2
AreaHC1 = PI * (RadiusHC1 ^ 2) / 2

' Step 3: Determine the radius of the second half-circle (HC2)
' Using the non-overlapping (tangency) condition
' (r2^2 - 12r2 + 45 = 9 + 6r2 + r2^2) simplifies to 36 = 18r2 --> r2 = 2
' In the general case, where C1=(r1,0) and C2=(0,R-r2), we solve:
' Sqrt(r1^2 + (R-r2)^2) = r1 + r2
' r1^2 + (R-r2)^2 = (r1+r2)^2
' r1^2 + R^2 - 2*R*r2 + r2^2 = r1^2 + 2*r1*r2 + r2^2
' R^2 - 2*R*r2 = 2*r1*r2
' R^2 = 2*R*r2 + 2*r1*r2
' R^2 = r2 * (2R + 2r1)
' r2 = R^2 / (2 * (R + r1))
RadiusHC2 = (QuadrantRadius ^ 2) / (2 * (QuadrantRadius + RadiusHC1))


' Step 4: Calculate the area of the second half-circle (HC2)
AreaHC2 = PI * (RadiusHC2 ^ 2) / 2


' Step 5: Calculate the Remaining Area
RemainingArea = AreaQuadrant - AreaHC1 - AreaHC2


CalculateQuadrantRemainingArea = RemainingArea


End Function

p45cal
07-04-2025, 10:13 AM
Formula:
=LET(rQ,A1,r,A2,p,PI(),p*rQ^2/4-p*r^2/2-p*((rQ^2-r^2+9)/(2*(rQ+r)))^2/2)

georgiboy, you have a 9 in that formula which has probably lingered from the QuadrantRadius of 6 and HC1 radius of 3; the 9 seems to be HC1r^2, and if I put that in there it becomes:
=LET(rQ,A2,r,B2,p,PI(),p*rQ^2/4-p*r^2/2-p*((rQ^2-r^2+r^2)/(2*(rQ+r)))^2/2)
and it gives answers in agreement with Paul's and mine, but you'll notice a -r^2+r^2 in there which cancels itself out, so they can both be removed leaving:
=LET(rQ,A2,r,B2,p,PI(),p*rQ^2/4-p*r^2/2-p*(rQ^2/(2*(rQ+r)))^2/2)
which leaves the same answers.

The same occurs in your udf:
R2 = (Rq ^ 2 - r ^ 2 + 9) / (2 * (Rq + r))
can become:
R2 = Rq ^ 2 / (2 * (Rq + r))

Picture of comparitive results (before adjustment to georgiboy's formula and udf):

32102

Aussiebear
07-04-2025, 01:54 PM
Then there is no need to ask for the HalfCircle1Radius in the function arguments since it's always half the Quadrant radius, in which case the function becomes:


Function CalculateQuadrantRemainingArea(QuadrantRadius As Double) As Double
CalculateQuadrantRemainingArea = QuadrantRadius ^ 2 / 4.583662361
End Function


I'm sorry P45cal but how did you arrive at this figure "4.583662361"?

Never mind I've found how you arrived at this figure:

The constant 4.583662361 was arrived at by pre-calculating the value of 5π72​.
This means the other member's function is a simplified version of our derived formula, specifically tailored for the case where the first half-circle's radius is always half of the quadrant's radius (r1​=R/2).

Aussiebear
07-04-2025, 02:03 PM
Will the functions created by Paul & P45cal still hold true if there were more than two half circles within the quadrant?

p45cal
07-04-2025, 02:51 PM
I'm sorry P45cal but how did you arrive at this figure "4.583662361"?

Since the area has to be directly proportional to a linear value squared, I looked at the result obtained 'longhand' and divided it by any linear measurement squared, in this case I used the QuadrantRadius so in the case of 6 mtrs for your example case I did:
QuadrantRadius^2/QuadrantRemainingArea
becomes
6^2 /7.853981634
which is
36/7.853981634
which is
4.583662361

Another way to arrive at that value is to look at your longhand way of calculating and simplifying it over and over by rearranging it; I was too lazy to do that.

Paul_Hossler
07-04-2025, 04:58 PM
I was over thinking it

AB comes up with some interesting stuff

It's really just the Pythagrian thereom

(r1 + r2)^2 = (r1)^2 + (2r1 - 2r2+r2)^2




3210332105

Aussiebear
07-04-2025, 06:57 PM
Okay, Thank you to all for your contributions here. The mathematics was quite challenging and given that I'm struggling to remember much about educational maths from my early years.