File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -884,30 +884,25 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
884884
885885 // Helper: Finds closest rad(x) match for given function (sin or cos)
886886
887- function findClosestRad ( value , funcType ) {
887+ function findClosestRad ( value ) {
888888 let closestKey = null ;
889889 let minDiff = Infinity ;
890890
891891 for ( const key in trig ) {
892- if ( ! trig [ key ] [ funcType ] ) continue ;
893- const keyMatch = key . match ( / r a d \( ( [ \d . ] + ) \) / ) ;
894- if ( ! keyMatch ) continue ;
892+ const match = key . match ( / r a d \( ( [ \d . ] + ) \) / ) ;
893+ if ( ! match ) continue ;
895894
896- const radVal = parseFloat ( keyMatch [ 1 ] ) ;
897- const diff = Math . abs ( radVal - value ) ;
895+ const rad = parseFloat ( match [ 1 ] ) ;
896+ const delta = Math . abs ( rad - value ) ;
898897
899- if ( diff < minDiff ) {
900- minDiff = diff ;
898+ if ( delta < minDiff ) {
899+ minDiff = delta ;
901900 closestKey = key ;
902901 }
903-
904-
905- if ( closestKey ) {
906- const approxVal = trig [ closestKey ] [ funcType ] . value ;
907- return `${ funcType } (${ closestKey } ) ≈ ${ approxVal } ` ;
908902 }
909- }
910- }
903+
904+ return closestKey ?? null ;
905+ }
911906
912907function sin ( input ) {
913908 // Normalize input: remove spaces, handle cases like "sin 0533" or "sin(0.533)"
You can’t perform that action at this time.
0 commit comments