File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -998,20 +998,25 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
998998}
999999
10001000function Asin ( x ) {
1001- if ( typeof x !== 'number' || x <= 0 || x > 1 ) return null ;
1001+ if ( typeof x !== 'number' || isNaN ( x ) || x <= 0 || x > 1 ) return null ;
10021002
1003- if ( x >= 0.707 ) {
1004- const match = closestValue ( x , 'sin' ) ;
1005- const parsed = match ?. angle . match ( / r a d \\ ( ( [ \d . ] + ) \\ ) / ) ;
1006- if ( ! parsed ) return null ;
1007- return parseFloat ( parsed [ 1 ] ) ;
1003+ const isSineZone = x >= 0.707 ;
1004+ const sourceFunc = isSineZone ? 'sin' : 'cos' ;
1005+
1006+ const match = closestValue ( x , sourceFunc ) ;
1007+ if ( ! match ?. angle || typeof match . angle !== 'string' ) {
1008+ console . warn ( `Asin: No angle match found for ${ x } in ${ sourceFunc } ` ) ;
1009+ return null ;
10081010 }
10091011
1010- // No reflection — match via cosine
1011- const match = closestValue ( x , 'cos' ) ;
1012- const parsed = match ?. angle . match ( / r a d \\ ( ( [ \d . ] + ) \\ ) / ) ;
1013- if ( ! parsed ) return null ;
1014- return parseFloat ( parsed [ 1 ] ) ;
1012+ const parsed = match . angle . match ( / r a d \( ( [ \d . ] + ) \) / ) ;
1013+ if ( ! parsed ) {
1014+ console . warn ( `Asin: Could not parse radian from "${ match . angle } "` ) ;
1015+ return null ;
1016+ }
1017+
1018+ const radian = parseFloat ( parsed [ 1 ] ) ;
1019+ return isSineZone ? radian : radian ; // no reflection needed
10151020}
10161021
10171022function Acos ( x ) {
You can’t perform that action at this time.
0 commit comments