Skip to content

Instantly share code, notes, and snippets.

@ilomon10
Last active February 22, 2021 12:54
Show Gist options
  • Save ilomon10/78b1aeada9d8e3835f87d5e091b782c4 to your computer and use it in GitHub Desktop.
Save ilomon10/78b1aeada9d8e3835f87d5e091b782c4 to your computer and use it in GitHub Desktop.
Finds the volume of the truncated cone
// Ref: https://www.madematika.net/2015/10/rumus-luas-selimut-dan-volume-kerucut.html
function (D1, D2, t) {
const pi = Math.PI;
let r1 = D1/2;
let r2 = D2/2;
return (1/3) * pi * t * (Math.pow(r2, 2) + r2 * r1 + Math.pow(r1, 2));
}
// Ref: https://solusimatematika85.blogspot.com/2017/08/mencari-volume-kerucut-yang-terpotong.html
function (D1, D2, t1) {
const pi = Math.PI;
let r1 = D1 / 2;
let r2 = D2 / 2;
// Find the remaining height of the cone
let t2 = (t1 * r2) / (r2 - r1);
// Find the remaining volume of the cone
let v2 = (1 / 3) * pi * Math.pow(r1, 2) * t2; // cubic
// Find the volume of the whole cone
let V = (1 / 3) * pi * Math.pow(r2, 2) * (t1 + t2); // cubic
// Finds the volume of the truncated cone
let v1 = (V - v2); // cubic
return v1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment