Skip to content

Commit 6a83eb7

Browse files
authored
Update index.html
1 parent 40fb736 commit 6a83eb7

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

index.html

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -998,20 +998,25 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
998998
}
999999

10001000
function 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(/rad\\(([\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(/rad\\(([\d.]+)\\)/);
1013-
if (!parsed) return null;
1014-
return parseFloat(parsed[1]);
1012+
const parsed = match.angle.match(/rad\(([\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

10171022
function Acos(x) {

0 commit comments

Comments
 (0)