Update Volume.js

This commit is contained in:
leeyan44
2021-07-19 22:44:12 +08:00
committed by GitHub
parent 3931903733
commit d7626e3b63

View File

@ -39,7 +39,7 @@ const volCube = (length) => {
const volCone = (radius, height) => { const volCone = (radius, height) => {
isNumber(radius, 'Radius') isNumber(radius, 'Radius')
isNumber(height, 'Height') isNumber(height, 'Height')
return (Math.PI * radius ** 2 * height/3) return (Math.PI * radius ** 2 * height/3.0)
} }
/* /*
@ -50,7 +50,7 @@ const volPyramid = (baseLength, baseWidth, height) => {
isNumber(baseLength, 'BaseLength') isNumber(baseLength, 'BaseLength')
isNumber(baseWidth, 'BaseWidth') isNumber(baseWidth, 'BaseWidth')
isNumber(height, 'Height') isNumber(height, 'Height')
return (baseLength * baseWidth * height) / 3 return (baseLength * baseWidth * height) / 3.0
} }
/* /*
@ -91,7 +91,7 @@ const volPentagonalPrism = (pentagonalLength, pentagonalBaseLength, height) => {
*/ */
const volSphere = (radius) => { const volSphere = (radius) => {
isNumber(radius, 'Radius') isNumber(radius, 'Radius')
return (4/3 * PI * radius ** 3) return (4/3 * Math.PI * radius ** 3)
} }
/* /*
@ -100,7 +100,7 @@ const volSphere = (radius) => {
*/ */
const volHemisphere = (radius) => { const volHemisphere = (radius) => {
isNumber(radius, 'Radius') isNumber(radius, 'Radius')
return (2 * PI * radius ** 3)/3 return (2.0 * Math.PI * radius ** 3)/ 3.0
} }
const isNumber = (number, noName = 'number') => { const isNumber = (number, noName = 'number') => {