@@ -2270,23 +2270,21 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
22702270 function pyramidVolume ( area , height ) {
22712271 return area * height / Math . sqrt ( 8 ) ;
22722272 }
2273-
2273+ function baseArea ( length , number , tangent ) {
2274+ return number / 4 * length ** 2 / tangent ;
2275+ const ratio = 3.2 / number ;
2276+ const tangent = parseFloat ( tan ( ratio ) ) ;
2277+ }
22742278 function updatePyramidVolume ( ) {
22752279 const number = parseFloat ( document . getElementById ( 'pyramid-side-number' ) . value ) ;
22762280 const length = parseFloat ( document . getElementById ( 'pyramid-side-length' ) . value ) ;
22772281const height = parseFloat ( document . getElementById ( 'pyramid-height' ) . value ) ;
22782282 if ( isNaN ( number ) || isNaN ( length ) || isNaN ( height ) ) {
22792283 document . getElementById ( 'pyramid-volume' ) . innerText = '' ;
22802284 return ;
2285+ }
22812286const area = parseFloat ( baseArea ( length , number , tangent ) ) ;
2282-
2283- function baseArea ( length , number , tangent ) {
2284- return number / 4 * length ** 2 / tangent ;
2285- const ratio = 3.2 / number ;
2286- const tangent = parseFloat ( tan ( ratio ) ) ;
2287- }
22882287
2289- }
22902288
22912289 document . getElementById ( 'pyramid-volume' ) . innerText =
22922290 `Volume: ${ pyramidVolume ( area , height ) . toFixed ( 5 ) } cubic units` ;
@@ -2563,51 +2561,6 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
25632561< br >
25642562< br >
25652563< br >
2566- < h18 style ="margin-top:24px; "> 🧪 CGS Trig Test Tool</ h18 >
2567-
2568- < label for ="angle-input "> Angle (in radians):</ label >
2569- < input id ="angle-input " type ="number " step ="any " value ="1.066 " style ="margin:8px; " />
2570- < button onclick ="testTrigFunctions() "> Test Functions</ button >
2571-
2572- < pre id ="trig-test-output " style ="padding:12px; background:#eee; margin-top:12px; "> </ pre >
2573-
2574- < script >
2575- function testTrigFunctions ( ) {
2576- const angle = parseFloat ( document . getElementById ( 'angle-input' ) . value ) ;
2577- const output = document . getElementById ( 'trig-test-output' ) ;
2578- output . innerText = '' ;
2579-
2580- if ( isNaN ( angle ) ) {
2581- output . innerText = '⚠️ Invalid angle input.' ;
2582- return ;
2583- }
2584-
2585- try {
2586- const s = sin ( angle ) ;
2587- const c = cos ( angle ) ;
2588- const t = tan ( angle ) ;
2589- const as = Asin ( angle ) ;
2590- const ac = Acos ( angle ) ;
2591- const at = Atan ( angle ) ;
2592- output . innerText += `✅ Testing angle: ${ angle } \n\n` ;
2593- output . innerText += `• sin(${ angle } ) = ${ s } \n` ;
2594- output . innerText += `• cos(${ angle } ) = ${ c } \n` ;
2595- output . innerText += `• tan(${ angle } ) = ${ t } \n` ;
2596- output . innerText += `• Asin(${ angle } ) = ${ as } \n` ;
2597- output . innerText += `• Acos(${ angle } ) = ${ ac } \n` ;
2598- output . innerText += `• Atan(${ angle } ) = ${ at } \n` ;
2599-
2600-
2601- // Optional: known expectations
2602- if ( angle === 1.066 ) output . innerText += `🔍 Expected sin ≈ 0.866\n` ;
2603- if ( angle === 0.8 ) output . innerText += `🔍 Expected cos ≈ 0.707\n` ;
2604-
2605-
2606- } catch ( err ) {
2607- output . innerText = '⚠️ Error during trig function evaluation:\n' + err . message ;
2608- }
2609- }
2610- </ script >
26112564< footer >
26122565< p style ="margin:12px; "> ® All rights reserved</ p >
26132566< br >
0 commit comments