' Geometric forms
' This file contains functions to calculate
' the area A, circumreference C, and
' Volume V of various geometric forms
' Triangle
A_triangle(b, h) = 1 / 2 * b * h;
' Circle
A_circle(r) = Pi * r²;
C_circle(r) = 2 * Pi * r;
' Sector of a circle
A_sector(r, theta) = 1 / 2 * r² * theta;
s_sector(r, theta) = r * theta; '(theta in radians)
' Sphere
A_sphere(r) = 4 * Pi * r²;
V_sphere(r) = 4 / 3 * Pi * r³;
' Cylinder
V_cylinder(r, h) = Pi * r² * h;
' Cone
V_cone(r, h) = 1 / 3 * Pi * r² * h;
' Example usage:
' calculate the area of a circle with diameter 15 cm
d = 15 cm;
A_circle(d / 2)
Ans = 176.714586764 cm²
' calculate the volume of a sphere with radius 10 cm
V_sphere(10 cm)
Ans = 4188.790204786 cm³
Convert(Ans, litre)
Ans = 4.188790205 litre