• https://me.yahoo.com
COST (GBP)
2.00
0.00
0

# circle

Computes the area of the circular segment within a circle tangent to a reference line.
Controller: CodeCogs
Contents

C++

## Circle

 doublecircle( double r double h )[inline]
This module computes the area of the circular segment formed between a circle tangent to a reference line and a line found at a given distance from this reference line.

The various cases are described by the images given in the following documentation, where the area which we want to compute is that of the filled shape.

### Solution

Consider an orthogonal coordinate system and $\inline&space;&space;\mathcal{C}(O,&space;r)$ a circle so that there exists $\inline&space;&space;P&space;\in&space;\mathcal{C}(O,&space;r)$ with $\inline&space;&space;P$ on the x-axis. Also let $\inline&space;&space;d$ be parallel to the x-axis so that the distance from it to the x-axis is $\inline&space;&space;h&space;\in&space;\mathbb{R}_+$ and $\inline&space;&space;d&space;\cap&space;\mathcal{C}&space;=&space;\{A,&space;B\}$.

Let $\inline&space;&space;S$ be the area which we must determine. Based on the relation between $\inline&space;&space;h$ and $\inline&space;&space;r$ we get the following cases:

1) $\inline&space;&space;h

We notice that

2) $\inline&space;&space;h&space;=&space;r&space;\Rightarrow&space;S&space;=&space;\mathcal{A}_{\mathcal&space;C}&space;/2$

Because $\inline&space;&space;\mathcal{A}_{\mathcal&space;C}&space;=&space;\pi&space;r^2$, we find the solution:
$S&space;=&space;\frac{\pi&space;r^2}{2}$

3) $\inline&space;&space;r

4) $\inline&space;&space;h&space;\geq&space;2r&space;\Rightarrow&space;S&space;=&space;\mathcal{A}_{\mathcal{C}}$

Because $\inline&space;&space;\mathcal{A}_{\mathcal{C}}&space;=&space;\pi&space;r^2$, the solution is:
$S&space;=&space;\pi&space;r^2$

Output:
r = 2.5

h = 0.0   Area = 0.000
h = 0.5   Area = 1.022
h = 1.0   Area = 2.796
h = 1.5   Area = 4.954
h = 2.0   Area = 7.334
h = 2.5   Area = 9.817
h = 3.0   Area = 12.301
h = 3.5   Area = 14.681
h = 4.0   Area = 16.839
h = 4.5   Area = 18.613
h = 5.0   Area = 19.635
h = 5.5   Area = 19.635

### Example 1

#include <codecogs/maths/geometry/area/circle.h>
#include <stdio.h>

int main()
{
// the length of the radius
double r = 2.5;

// display the lenghts of the radius
printf("r = %.1lf\n\n", r);

// display the area for different values of h
for (double h = 0; h < 5.6; h += 0.5)
printf("h = %.1lf   Area = %.3lf\n", h,
Geometry::Area::circle(r, h));

return 0;
}

### Parameters

 r the radius of the circle h the distance between line $\inline&space;d$ and the reference line

### Returns

The value of the desired area.
##### Source Code

Source code is available when you buy a Commercial licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.