Skip to content

Commit

Permalink
Merge pull request #5 from Pedrop19/patch-2
Browse files Browse the repository at this point in the history
Update geometry.js
  • Loading branch information
PB2204 authored Oct 5, 2023
2 parents f6e91aa + 8abe64f commit 35eac41
Showing 1 changed file with 55 additions and 0 deletions.
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;

0 comments on commit 35eac41

Please sign in to comment.