Area of objects

These functions calculate surface areas. Units follow the input: measurements in centimetres produce results in square centimetres.

area functions

Area of circle:

circleArea(x )

Formula:

x ⁣:diameterresult=π(x2)2 \begin{aligned} x &\colon\quad \text{diameter} \\[0.6em] \mathrm{result} &= \pi\cdot \left(\frac{x}{2}\right)^{2} \end{aligned}

Example:

What is the area of an circle with the diameter of 55 cm.

circleArea(55)=2375.829445 cm2


Next function is area of an sphere (ball):

sphereArea(x )

Where

Formula:

x ⁣:outer diameterresult=4π(x2)2 \begin{aligned} x &\colon\quad \text{outer diameter} \\[0.6em] \mathrm{result} &= 4\cdot \pi\cdot \left(\frac{x}{2}\right)^{2} \end{aligned}

Example:

A ball with a diameter of 20 cm, what is the area:

sphereArea(20)=1256.637061

ballSurface(x) is an equivalent library function for the same calculation:

x ⁣:diameterresult=4π(x2)2 \begin{aligned} x &\colon\quad \text{diameter} \\[0.6em] \mathrm{result} &= 4\cdot \pi\cdot \left(\frac{x}{2}\right)^{2} \end{aligned}


The next function is area of cylinder:

cylinder

areaCyl(x; y )

Where

Using the following formulas:

x ⁣:outer diametery ⁣:lengtha=x2result=2πay+2πa2 \begin{aligned} x &\colon\quad \text{outer diameter} \\ y &\colon\quad \text{length} \\[0.6em] a &= \frac{x}{2} \\ \mathrm{result} &= 2\cdot \pi\cdot a\cdot y + 2\cdot \pi\cdot a^{2} \end{aligned}

Example:

An cylinder, 10 cm diameter, 20 cm length:

areaCyl(10;20)=785.3981635


The next function is for hollow cylinder or tube. The calculation includes the area of the ends.

areaHollowCyl(x; y; z )

Where

Using the following formula:

x ⁣:outer diametery ⁣:wall thicknessz ⁣:lengthresult=πxz+πz(x2y)+2(πx24π(x2y)2) \begin{aligned} x &\colon\quad \text{outer diameter} \\ y &\colon\quad \text{wall thickness} \\ z &\colon\quad \text{length} \\[0.6em] \mathrm{result} &= \pi\cdot x\cdot z + \pi\cdot z\cdot \left(x - 2\cdot y\right) + 2\cdot \left(\frac{\pi\cdot x^{2}}{4} - \pi\cdot \left(\frac{x}{2} - y\right)^{2}\right) \end{aligned}

Example:

A tube is 100 cm long, 10 cm in diameter, with a wall thickness of 1 cm. What is its area?

areaHollowCyl(10;1;100)=5711.415445


The next function is for the area of a cone or truncated cone. This function can calculate both regular cone, and truncated cone. If the cone is regular, enter 0 as the top diameter.

areaCone(x; y; z )

Where

The formula includes the bottom and top surfaces and the sloping outer surface. Use 0 for the top diameter of a pointed cone.

x ⁣:bottom diametery ⁣:top diameter (=0)z ⁣:heightresult=π(x2)2+π(y2)2+π(x2+y2)(xy2)2+z2 \begin{aligned} x &\colon\quad \text{bottom diameter} \\ y &\colon\quad \text{top diameter (=0)} \\ z &\colon\quad \text{height} \\[0.6em] \mathrm{result} &= \pi\cdot \left(\frac{x}{2}\right)^{2} + \pi\cdot \left(\frac{y}{2}\right)^{2} + \pi\cdot \left(\frac{x}{2} + \frac{y}{2}\right)\cdot \sqrt{\left(\frac{x - y}{2}\right)^{2} + z^{2}} \end{aligned}

Example:

A truncated cone, with bottom diameter 10 cm, top diameter 8 cm, and 4 cm tick:

areaCone(10;8;4)=245.383364 cm2


The next function calculates the area of a pyramid with a square base.

areaPyramide(x; y )

Where

Using the following formula:

x ⁣:length of one side of squarey ⁣:height from center of base to topresult=2x(x2)2+y2+x2 \begin{aligned} x &\colon\quad \text{length of one side of square} \\ y &\colon\quad \text{height from center of base to top} \\[0.6em] \mathrm{result} &= 2\cdot x\cdot \sqrt{\left(\frac{x}{2}\right)^{2} + y^{2}} + x^{2} \end{aligned}

Example:

A pyramid has a 10 × 10 cm square base and a height of 20 cm.

areaPyramide(10;20)=512.3105626 cm2


The next function is for the area of a triange (any combination of angles. Any sum of two sides must be longer than the third for being a triangle.

***areaTriangle(x; y; z ) ***

Where

Using Heron's formula:

x ⁣:length first sidey ⁣:length of second sidez ⁣:length of third sidec=x+y+z2result=c(cx)(cy)(cz) \begin{aligned} x &\colon\quad \text{length first side} \\ y &\colon\quad \text{length of second side} \\ z &\colon\quad \text{length of third side} \\[0.6em] c &= \frac{x + y + z}{2} \\ \mathrm{result} &= \sqrt{c\cdot \left(c - x\right)\cdot \left(c - y\right)\cdot \left(c - z\right)} \end{aligned}

Example:

areaTriangle(10;12;15)=59.81168364


The next function calculates the area of an ellipse:

areaEllipse(x; y )

Where

Using the following formula:

x ⁣:widthy ⁣:heightresult=πxy4 \begin{aligned} x &\colon\quad \text{width} \\ y &\colon\quad \text{height} \\[0.6em] \mathrm{result} &= \frac{\pi\cdot x\cdot y}{4} \end{aligned}

Example:

areaEllipse(15;20)=235.619449


*The next function is for calculating the area of a regular polygon. *

areaRegPolygon(x; y )

Where

The first formula calculates half of an interior angle. The polygon is then treated as x triangles whose top points meet at the center.

x ⁣:number of sidesy ⁣:distance from center to one of its cornersa=90(x2)xresult=xcos(a)sin(a)y2 \begin{aligned} x &\colon\quad \text{number of sides} \\ y &\colon\quad \text{distance from center to one of its corners} \\[0.6em] a &= \frac{90\cdot \left(x - 2\right)}{x} \\ \mathrm{result} &= x\cdot \cos\left(a\right)\cdot \sin\left(a\right)\cdot y^{2} \end{aligned}

Example:

A pentagon with the length from the center to one angle, is 15 cm. What is the area:

areaRegPolygon(5;15)=534.9692903


The final area function is for a regular star polygon formed by extending the sides of an inner regular polygon until they intersect. A pentagram is one example. The function does not apply to every symmetrical star shape.

areaRegStarPolygon(x; y )

Where

Using the following formulas:

x ⁣:number of sidesy ⁣:distance from center to one of its inner cornersa=90(x2)xresult=xtan(1802a)y2cos(a)2+xsin(a)y2cos(a) \begin{aligned} x &\colon\quad \text{number of sides} \\ y &\colon\quad \text{distance from center to one of its inner corners} \\[0.6em] a &= \frac{90\cdot \left(x - 2\right)}{x} \\ \mathrm{result} &= x\cdot \tan\left(180 - 2\cdot a\right)\cdot y^{2}\cdot \cos\left(a\right)^{2} + x\cdot \sin\left(a\right)\cdot y^{2}\cdot \cos\left(a\right) \end{aligned}

We calculate the triangles that extends from the inner polygon, and then the area of the inner polygon itself.

Example:

areaRegStarPolygon(5;15)=1731.196989


This completes the area functions. Continue with volume of objects.