Skip to content

Commit 8abe64f

Browse files
authored
Update geometry.js
1 parent 2590c90 commit 8abe64f

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

adv-math/src/geometry-trigonometry/geometry.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,61 @@ class Geometry {
1818
static circleCircumference(radius) {
1919
return 2 * Math.PI * radius;
2020
}
21+
22+
// Method to calculate the area of a triangle given base and height
23+
static triangleArea(base, height) {
24+
return (base * height) / 2;
25+
}
26+
27+
// Method to calculate the volume of a sphere given its radius
28+
static sphereVolume(radius) {
29+
return (4 / 3) * Math.PI * Math.pow(radius, 3);
30+
}
31+
32+
// Method to calculate the area of an equilateral triangle given its side length
33+
static equilateralTriangleArea(side) {
34+
return (Math.sqrt(3) / 4) * Math.pow(side, 2);
35+
}
36+
37+
// Method to calculate the volume of a cube given its side length
38+
static cubeVolume(side) {
39+
return Math.pow(side, 3);
40+
}
41+
42+
// Method to calculate the volume of a rectangular prism given length, width, and height
43+
static rectangularPrismVolume(length, width, height) {
44+
return length * width * height;
45+
}
46+
47+
// Method to calculate the surface area of a rectangular prism given length, width, and height
48+
static rectangularPrismSurfaceArea(length, width, height) {
49+
return 2 * (length * width + width * height + height * length);
50+
}
51+
52+
// Method to calculate the volume of a cylinder given its radius and height
53+
static cylinderVolume(radius, height) {
54+
return Math.PI * Math.pow(radius, 2) * height;
55+
}
56+
57+
// Method to calculate the surface area of a cylinder given its radius and height
58+
static cylinderSurfaceArea(radius, height) {
59+
const baseArea = Math.PI * Math.pow(radius, 2);
60+
const lateralArea = 2 * Math.PI * radius * height;
61+
return 2 * baseArea + lateralArea;
62+
}
63+
64+
// Method to calculate the volume of a cone given its radius and height
65+
static coneVolume(radius, height) {
66+
return (1 / 3) * Math.PI * Math.pow(radius, 2) * height;
67+
}
68+
69+
// Method to calculate the surface area of a cone given its radius and height
70+
static coneSurfaceArea(radius, height) {
71+
const slantHeight = Math.sqrt(Math.pow(radius, 2) + Math.pow(height, 2));
72+
const baseArea = Math.PI * Math.pow(radius, 2);
73+
const lateralArea = Math.PI * radius * slantHeight;
74+
return baseArea + lateralArea;
75+
}
2176
}
2277

2378
module.exports = Geometry;

0 commit comments

Comments
 (0)