mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-08 20:14:00 -04:00
Update scratch3_operators.js
Fix #2198 and #2199 Take angle modulus 360 to avoid issues with floating point decimal accuracy. Round to 10 digits using Math.round and division instead of stringifying.
This commit is contained in:
parent
f74bf88ce3
commit
6ec974f710
1 changed files with 2 additions and 2 deletions
|
@ -136,8 +136,8 @@ class Scratch3OperatorsBlocks {
|
|||
case 'floor': return Math.floor(n);
|
||||
case 'ceiling': return Math.ceil(n);
|
||||
case 'sqrt': return Math.sqrt(n);
|
||||
case 'sin': return parseFloat(Math.sin((Math.PI * n) / 180).toFixed(10));
|
||||
case 'cos': return parseFloat(Math.cos((Math.PI * n) / 180).toFixed(10));
|
||||
case 'sin': return Math.round(Math.sin(n % 360 / 180 * Math.PI) * 1e10) / 1e10;
|
||||
case 'cos': return Math.round(Math.cos(n % 360 / 180 * Math.PI) * 1e10) / 1e10;
|
||||
case 'tan': return MathUtil.tan(n);
|
||||
case 'asin': return (Math.asin(n) * 180) / Math.PI;
|
||||
case 'acos': return (Math.acos(n) * 180) / Math.PI;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue