Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions adv-math/src/geometry-trigonometry/geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,61 @@ class Geometry {
static circleCircumference(radius) {
return 2 * Math.PI * radius;
}

// Method to calculate the area of a triangle given base and height
static triangleArea(base, height) {
return (base * height) / 2;
}

// Method to calculate the volume of a sphere given its radius
static sphereVolume(radius) {
return (4 / 3) * Math.PI * Math.pow(radius, 3);
}

// Method to calculate the area of an equilateral triangle given its side length
static equilateralTriangleArea(side) {
return (Math.sqrt(3) / 4) * Math.pow(side, 2);
}

// Method to calculate the volume of a cube given its side length
static cubeVolume(side) {
return Math.pow(side, 3);
}

// Method to calculate the volume of a rectangular prism given length, width, and height
static rectangularPrismVolume(length, width, height) {
return length * width * height;
}

// Method to calculate the surface area of a rectangular prism given length, width, and height
static rectangularPrismSurfaceArea(length, width, height) {
return 2 * (length * width + width * height + height * length);
}

// Method to calculate the volume of a cylinder given its radius and height
static cylinderVolume(radius, height) {
return Math.PI * Math.pow(radius, 2) * height;
}

// Method to calculate the surface area of a cylinder given its radius and height
static cylinderSurfaceArea(radius, height) {
const baseArea = Math.PI * Math.pow(radius, 2);
const lateralArea = 2 * Math.PI * radius * height;
return 2 * baseArea + lateralArea;
}

// Method to calculate the volume of a cone given its radius and height
static coneVolume(radius, height) {
return (1 / 3) * Math.PI * Math.pow(radius, 2) * height;
}

// Method to calculate the surface area of a cone given its radius and height
static coneSurfaceArea(radius, height) {
const slantHeight = Math.sqrt(Math.pow(radius, 2) + Math.pow(height, 2));
const baseArea = Math.PI * Math.pow(radius, 2);
const lateralArea = Math.PI * radius * slantHeight;
return baseArea + lateralArea;
}
}

module.exports = Geometry;