MCPcopy Create free account
hub / github.com/TheAlgorithms/JavaScript / Cone

Class Cone

Geometry/Cone.js:8–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6 * @param {number} height - The height of the cone
7 */
8export default class Cone {
9 constructor(baseRadius, height) {
10 this.baseRadius = baseRadius
11 this.height = height
12 }
13
14 baseArea = () => {
15 return Math.pow(this.baseRadius, 2) * Math.PI
16 }
17
18 volume = () => {
19 return (this.baseArea() * this.height * 1) / 3
20 }
21
22 surfaceArea = () => {
23 return (
24 this.baseArea() +
25 Math.PI *
26 this.baseRadius *
27 Math.sqrt(Math.pow(this.baseRadius, 2) + Math.pow(this.height, 2))
28 )
29 }
30}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected