@@ -2510,48 +2510,41 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
25102510< br >
25112511< h18 style ="margin-top:24px; "> 🧪 CGS Trig Test Tool</ h18 >
25122512
2513- < label for ="input-angle "> Angle (rad):</ label >
2514- < input id ="input-angle " type ="text " value ="rad(1.467) " style ="margin:8px; " />
2515- < br >
2516-
2517- < label for ="input-value "> Value (e.g. 0.991):</ label >
2518- < input id ="input-value " type ="number " step ="any " value ="0.991 " style ="margin:8px; " />
2519- < br >
2520- < button onclick ="runTrigTests() "> Run Tests</ button >
2513+ < label for ="angle-input "> Angle (in radians):</ label >
2514+ < input id ="angle-input " type ="number " step ="any " value ="1.066 " style ="margin:8px; " />
2515+ < button onclick ="testTrigFunctions() "> Test Functions</ button >
25212516
2522- < pre id ="trig-output " style ="padding:12px; background:#eee; margin-top:12px; "> </ pre >
2517+ < pre id ="trig-test- output " style ="padding:12px; background:#eee; margin-top:12px; "> </ pre >
25232518
25242519< script >
2525-
2526-
2527- function runTrigTests ( ) {
2528- const angleInput = document . getElementById ( "input-angle" ) . value ;
2529- const valueInput = parseFloat ( document . getElementById ( "input-value" ) . value ) ;
2530- const output = document . getElementById ( "trig-output" ) ;
2531- output . innerText = "" ;
2532-
2533- // Regular trig
2534- const trigEntry = trig [ angleInput ] ;
2535- if ( ! trigEntry ) {
2536- output . innerText += `⚠️ No entry found for ${ angleInput } \n` ;
2537- } else {
2538- output . innerText += `✅ Found trig entry for ${ angleInput } \n` ;
2539- output . innerText += `• sin: ${ trigEntry . sin } \n` ;
2540- output . innerText += `• cos: ${ trigEntry . cos } \n` ;
2541- output . innerText += `• tan: ${ trigEntry . tan } \n\n` ;
2520+ function testTrigFunctions ( ) {
2521+ const angle = parseFloat ( document . getElementById ( 'angle-input' ) . value ) ;
2522+ const output = document . getElementById ( 'trig-test-output' ) ;
2523+ output . innerText = '' ;
2524+
2525+ if ( isNaN ( angle ) ) {
2526+ output . innerText = '⚠️ Invalid angle input.' ;
2527+ return ;
25422528 }
25432529
2544- // Inverse trig
2545- output . innerText += `🔍 Searching inverse matches for ≈ ${ valueInput } \n\n` ;
2530+ try {
2531+ const s = sin ( angle ) ;
2532+ const c = cos ( angle ) ;
2533+ const t = tan ( angle ) ;
25462534
2547- [ "sin" , "cos" , "tan" ] . forEach ( func => {
2548- const match = findClosestValueMatch ( valueInput , func ) ;
2549- if ( match ) {
2550- output . innerText += `atan⟶${ func } : ${ valueInput } → ${ match . angle } [${ func } =${ match . value } ]\n` ;
2551- } else {
2552- output . innerText += `atan⟶${ func } : No match found for ${ valueInput } \n` ;
2553- }
2554- } ) ;
2535+ output . innerText += `✅ Testing angle: ${ angle } \n\n` ;
2536+ output . innerText += `• sin(${ angle } ) = ${ s } \n` ;
2537+ output . innerText += `• cos(${ angle } ) = ${ c } \n` ;
2538+ output . innerText += `• tan(${ angle } ) = ${ t } \n` ;
2539+
2540+ // Optional: known expectations
2541+ if ( angle === 1.066 ) output . innerText += `🔍 Expected sin ≈ 0.866\n` ;
2542+ if ( angle === 0.8 ) output . innerText += `🔍 Expected cos ≈ 0.707\n` ;
2543+ if ( angle === 1.467 ) output . innerText += `🔍 Expected tan ≈ 7.6\n` ;
2544+
2545+ } catch ( err ) {
2546+ output . innerText = '⚠️ Error during trig function evaluation:\n' + err . message ;
2547+ }
25552548 }
25562549</ script >
25572550< footer >
0 commit comments